/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ !function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0="==e.substr(0,2)?(a="gte",n=e.substr(2)):"<="==e.substr(0,2)?(a="lte",n=e.substr(2)):">"==e.substr(0,1)?(a="gt",n=e.substr(1)):"<"==e.substr(0,1)?(a="lt",n=e.substr(1)):"!"==e.substr(0,1)?(a="not",n=e.substr(1)):(a="eq",n=e),n&&n in t.list)if(i=t.list[n],Array.isArray(i)){if(r=parseInt(i[0]),d=parseInt(i[1]),isNaN(r)){if(isNaN(d))return;c=i[1].substr(String(d).length)}else c=i[0].substr(String(r).length);if(isNaN(r))switch(a){case"gte":s="screen";break;case"lte":s="screen and (max-width: "+d+c+")";break;case"gt":s="screen and (min-width: "+(d+1)+c+")";break;case"lt":s="screen and (max-width: -1px)";break;case"not":s="screen and (min-width: "+(d+1)+c+")";break;default:s="screen and (max-width: "+d+c+")"}else if(isNaN(d))switch(a){case"gte":s="screen and (min-width: "+r+c+")";break;case"lte":s="screen";break;case"gt":s="screen and (max-width: -1px)";break;case"lt":s="screen and (max-width: "+(r-1)+c+")";break;case"not":s="screen and (max-width: "+(r-1)+c+")";break;default:s="screen and (min-width: "+r+c+")"}else switch(a){case"gte":s="screen and (min-width: "+r+c+")";break;case"lte":s="screen and (max-width: "+d+c+")";break;case"gt":s="screen and (min-width: "+(d+1)+c+")";break;case"lt":s="screen and (max-width: "+(r-1)+c+")";break;case"not":s="screen and (max-width: "+(r-1)+c+"), screen and (min-width: "+(d+1)+c+")";break;default:s="screen and (min-width: "+r+c+") and (max-width: "+d+c+")"}}else s="("==i.charAt(0)?"screen and "+i:i;t.media[e]=!!s&&s}return t.media[e]!==!1&&window.matchMedia(t.media[e]).matches},on:function(e,n){t.events.push({query:e,handler:n,state:!1}),t.active(e)&&n()},poll:function(){var e,n;for(e=0;e-1) { tmp = result.split('RES:OK:wechat[:]'); tmp = tmp[1].split('[:]'); AjaxCall('?atf-payment&p=43t3tfvsdfewrf&type=create_payment_request&provider=wechat&local_id='+window.uniqueid+'&item_name='+tmp[0]+'&item_id='+tmp[1]+'&item_amount='+tmp[2]+'&item_currency='+tmp[3],false,'qrCodeHandling'); setInterval(function() { checkUpdate(purchase_desc,purchase_id,currency); }, 1000); } if(result.indexOf('RES:OK:card')>-1) { tmp = result.split('RES:OK:card[:]'); tmp = tmp[1].split('[:]'); } if(result.indexOf('RES:OK:paypal')>-1) { //start pinging atf every 2 seconds for an update window.paid = false; setInterval(function() { AjaxCall('?atf-payment&p=43t3tfvsdfewrf&type=check_payment&uniqueid='+window.uniqueid,false,'paymentResponse'); }, 2000); } if(result.indexOf('RES:OK:alipay')>-1) { //start pinging atf every 2 seconds for an update window.paid = false; setInterval(function() { AjaxCall('?atf-payment&p=43t3tfvsdfewrf&type=check_payment&uniqueid='+window.uniqueid,false,'paymentResponse'); }, 2000); } } function checkUpdate() { if(window.last_payment_amount!=document.getElementById('amount').value) { clearInterval(window.check_payment_handle); AjaxCall('?new_payment_request&type='+window.last_payment_type+'&price='+document.getElementById('amount').value+'&desc='+document.getElementById('purchase_desc').value+'¤cy='+document.getElementById('currency').value+'&id='+document.getElementById(purchase_id).value,false,'showResponse'); } } function cardPaymentHandling(result) { //it worked or it didnt if(result.indexOf('<[RES[OK')>-1) { paymentSuccessful(); } else { document.getElementById('status_image').src = 'https://cdn.atfgroup.com.cn/l4CK7K7N5YpGfJwKnyRXLOQLGgA9Eq7R.png'; document.getElementById('status_image').width = '110'; document.getElementById('status_image').height = '100%'; document.getElementById('payment_status').innerHTML = 'Sorry, your payment was not accepted. try again'; } } function paymentSuccessful() { document.getElementById('status_image').src = 'https://cdn.atfgroup.com.cn/FtaTgKhXMlAlecKoiKky3J6TzYQ0i7Ct.png'; document.getElementById('status_image').width = '115'; document.getElementById('status_image').height = '115'; document.getElementById('payment_status').innerHTML = 'Payment successful!'; document.getElementById('back_to_payment_options').style.display = 'none'; window.paid = true; clearInterval(); } function reloadPaymentOptions() { if(window.payment_options!='') { document.getElementById('payment_div').innerHTML = window.payment_options; //reload stripe scripts showCardPayment(); } } function checkPaymentSuccess(payment_id) { //ping paymentid back, is it paid yet? payment_id AjaxCall('?atf-payment&p=43t3tfvsdfewrf&type=check_payment&payment_id='+payment_id,false,'paymentResponse'); } function paymentResponse(payload) { if(payload.indexOf('<[RES[PAID')>-1) { if(!window.paid) { paymentSuccessful(); } } } function qrCodeHandling(payload) { if(payload.indexOf('<[RES[SUCCESS[[')>-1) { tmp = payload.split('SUCCESS[['); tmp = tmp[1].split(']]]'); payload = JSON.parse(tmp[0]); document.getElementById('status_image').src = payload['qr_code']; //ping every 2 seconds for an update for payment window.paid = false; window.check_payment_handle = setInterval(function() { checkPaymentSuccess(payload.payment_id); }, 4000); } } function showCardPayment() { window.paymentHandler = StripeCheckout.configure({ key: 'pk_live_c6Pocns6JlCg5svExofTLjbP', image: 'https://stripe.com/img/documentation/checkout/marketplace.png', locale: 'auto', token: function(token) { //show charging card message and send token to core document.getElementById('payment_status').innerHTML = 'Charging your card... please wait'; AjaxCall('?type=charge_card&uniqueid='+window.uniqueid+'&token='+token.id,false,'cardPaymentHandling'); } }); document.getElementById('cardPayment').addEventListener('click', function(e) { window.last_payment_type='card'; // Open Checkout with further options: window.paymentHandler.open({ name: document.getElementById('purchase_desc').value, description: document.getElementById('purchase_desc').value, currency: document.getElementById('currency').value, amount: parseFloat(document.getElementById('amount').value+"00") }); // send update to us AjaxCall('?new_payment_request&type=card&price='+document.getElementById('amount').value+'&desc='+document.getElementById('purchase_desc').value+'¤cy='+document.getElementById('currency').value+'&id='+document.getElementById('purchase_id').value,false,'showResponse'); e.preventDefault(); }); // Close Checkout on page navigation: window.addEventListener('popstate', function() { window.paymentHandler.close(); }); } function loadScript(url, callback){ var script = document.createElement("script"); script.type = "text/javascript"; if (script.readyState){ //IE script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } }; } else { //Others script.onload = function(){ callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } window.job_title = ''; window.account_id = 0; window.stored_html = ''; function showLogin() { window.login_div = createWindow("Login", '

Login
Haven\'t registered yet? register.

Username:
Password:
'); //detect enter key press detectKeyPress('lbpass','doLogin'); //login leadbox animate start /**var current = null; document.getElementById('lbemail').addEventListener('focus', function(e) { if (current) current.pause(); current = anime({ targets: '.check1', strokeDashoffset: { value: 0, duration: 700, easing: 'easeOutQuart' }, strokeDasharray: { value: '240 1386', duration: 700, easing: 'easeOutQuart' } }); }); document.getElementById('lbpass').addEventListener('focus', function(e) { if (current) current.pause(); current = anime({ targets: '.check1', strokeDashoffset: { value: -336, duration: 700, easing: 'easeOutQuart' }, strokeDasharray: { value: '240 1386', duration: 700, easing: 'easeOutQuart' } }); }); **/ //login leadbox animate end }; function doLogin() { window.username = document.getElementById('lbemail').value; password = document.getElementById('lbpass').value; if(window.username.length>3&&password.length>3) { //show waiting window.stored_html = document.getElementById('login_div').innerHTML; if(document.getElementById('login_button')){ //if login_button, just change that document.getElementById('login_button').value = "Logging in..."; document.getElementById('login_button').disabled = true; } else { document.getElementById('login_div').innerHTML = '



Checking credentials...'; } AjaxCall("?atf_do_login&username="+btoa(encodeURIComponent(window.username))+"&password="+btoa(encodeURIComponent(password)),false,"loginReply"); } else { if(document.getElementById('lbpass').value==''&&/^\d+$/.test(document.getElementById('lbemail').value)&&document.getElementById('lbemail').value.length>6) { sendCode(); } else { message = 'Please enter your phone number / username and password.'; if(document.getElementById('lbpass').placeholder=='密码'||window.lang=='cn') { window.lang = 'cn'; message = '请输入您的电话号码和密码。'; } document.getElementById('code_error').innerHTML = message; } } }; function loginReply(data) { if(data.indexOf('[RES[OK')>-1) { //show success //document.getElementById('biscuitsDialog').style.textAlign = 'center'; //document.getElementById('biscuitsDialog').style.padding = '8px'; if(document.getElementById('login_success')){ document.getElementById('login_success').innerHTML = "
Login successful!
"; document.getElementById('login_success').style.textAlign = 'center'; } else { document.getElementById('login_div').innerHTML = "


Login successful!
"; document.getElementById('login_div').style.textAlign = 'center'; } window.loggedin = true; //get the account_id tmp = data.split('[OK:'); tmp = tmp[1].split(']]'); window.account_id = tmp[0]; if(window.job_id>0) { sendAccountDetailsToClient(window.job_id,window.employer_id,window.job_title); } //wait 1 seconds and reload setTimeout(function(){ window.location.reload(1); }, 1000); } else { document.getElementById('login_div').innerHTML = window.stored_html; document.getElementById('lbemail').value = window.username; window.stored_html = ''; document.getElementById('code_error').innerHTML = "Sorry your username or password is incorrect."; } }; function sendAccountDetailsToClient(job_id,employer_id,account_id,job_title) { //show applying closeRegister(); var div = document.createElement('div'); div.setAttribute('id','biscuitsDialog'); div.style.position = 'fixed'; div.style.zIndex = '20'; div.style.background = '#fff'; div.style.color = 'black'; div.style.boxShadow = '2px 3px 2px #dde2ea'; div.style.textAlign = 'center'; div.style.padding = '8px'; div.style.paddingBottom = '25px'; document.body.appendChild(div); document.getElementById('biscuitsDialog').innerHTML = "



Sending your application to the employer..."; try { centerDialog('biscuitsDialog'); } catch(err) {} account_details = ""; if(typeof account_id != null&&account_id>0) { account_details = "&account_id="+account_id; } if(typeof job_title != null&&job_title!='') { account_details += "&title="+btoa(job_title); } if(typeof window.subject_prefix != null&&window.subject_prefix!='') { account_details += "&subject_prefix="+btoa(window.subject_prefix); } AjaxCall("?atf_send_application&job_id="+job_id+"&employer_id="+employer_id+account_details,false,"applicationReply"); }; function applicationReply(reply) { if(reply.indexOf('ERROR:notloggedin')>-1) { showLogin(); } else if(reply.indexOf('RES[nocv]')>-1) { showFinalStep(); } else if(reply.indexOf('RES[alreadyapplied]')>-1) { document.getElementById('biscuitsDialog').innerHTML = "

You\'ve already applied for this job. Please wait for a reply from the employer shortly."; } else if(reply.indexOf('RES[OK')>-1) { document.getElementById('biscuitsDialog').innerHTML = "



Application sent successfully!"; } else { document.getElementById('biscuitsDialog').innerHTML = "

Sorry, we couldnt process your application right now, please try again."; } if(reply.indexOf('ERROR:notloggedin')==-1) { window.loggedin = true; } try { centerDialog('biscuitsDialog'); } catch(err) { console.log("Dialog Error check") } }; function isLoggedIn() { if(!window.loggedin) { return window.loggedin; } else { return true; } }; function closeRegister() { if(document.getElementById('biscuitsDialog')) { var elem = document.getElementById("biscuitsDialog"); elem.parentElement.removeChild(elem); } }; function doFinalizeAccount() { //handle file var fileSelect = document.getElementById('cv'); var files = fileSelect.files; var formData = new FormData(); var validated = true; var validationErrors = ''; // Loop through each of the selected files. var filesAttachedCount = 0; for (var i = 0; i < files.length; i++) { var file = files[i]; // Check the file type. if (file.name.indexOf('.doc')==-1&&file.name.indexOf('.docx')==-1&&file.name.indexOf('.pdf')==-1&&file.name.indexOf('*.txt')==-1&&file.name.indexOf('.odt')==-1) { validationErrors += 'Sorry, could not add file: '+file.name+' because it is not a .doc, .docx, .pdf, .odt or .txt file'; continue; } // Add the file to the request. formData.append('cvs[]', file, file.name); filesAttachedCount++; } //sort out qualification and nationality nationality = document.getElementById('lbnationality').value; if(document.getElementById('lbnationality').value=='other') { nationality = document.getElementById('lbnationalitycustom').value; } qualification = document.getElementById('lbqualification').value; if(document.getElementById('lbqualification').value=='other') { qualification = document.getElementById('lbqualificationcustom').value; } //validation if(!(qualification.length>1)) { validated = false; validationErrors += 'You must select a qualification
'; } else if(!(nationality.length>3)) { validated = false; validationErrors += 'You must select your nationality
'; } else if(!(filesAttachedCount>0)) { validated = false; validationErrors += 'You must choose your C.V. or resume
'; } if(validated) { // add nationality and qualification formData.append('nationality', nationality); formData.append('qualification', qualification); formData.append('id', window.account_id); //send data AjaxPostCall('?upload_cv_nationality_qualification',formData,'doAccountFinalStep'); } else { document.getElementById('code_error').innerHTML = "Sorry, please check the following and click done again: "+validationErrors; } }; function doAccountFinalStep(res) { if (res.indexOf('RES[OK')>-1) { //handle final action if(window.job_id>0) { sendAccountDetailsToClient(window.job_id,window.employer_id,window.account_id); } else { //show success message document.getElementById('biscuitsDialog').style.textAlign = 'center'; document.getElementById('biscuitsDialog').style.padding = '8px'; document.getElementById('biscuitsDialog').innerHTML = "


Registration success!"; } } else { document.getElementById('code_error').innerHTML = 'Sorry, that didn\'t work, please try again.'; } }; function doNationality() { if(document.getElementById('lbnationality').value=='other') { document.getElementById('lbnationality').style.display = 'none'; document.getElementById('lbnationalitycustom').style.display = 'block'; } }; function doQualification() { if(document.getElementById('lbqualification').value=='other') { document.getElementById('lbqualification').style.display = 'none'; document.getElementById('lbqualificationcustom').style.display = 'block'; } }; function showFinalStep() { //go to next step div_html = "Your nationality:
Highest qualification:
Upload C.V. or Resume

"; try { document.getElementById('registration_fields').innerHTML = div_html; } catch(err) { document.getElementById('biscuitsDialog').innerHTML = '
Please complete your details to continue:

'+div_html; document.getElementById('biscuitsDialog').style.width = '200px'; document.getElementById('biscuitsDialog').style.textAlign = 'left'; } detectKeyPress('cv','doFinalizeAccount'); }; function _accountSettings(title, contentHtmlorLink) { //open a popup and point it at core createWindow(title, contentHtmlorLink); }; function codeReply(res) { if (res.indexOf('RES[ERROR:wait 60 seconds')>-1) { if(document.getElementById('code_error')) { document.getElementById('code_error').innerHTML = 'Code was sent, Please wait 60 seconds before sending another code'; } else { alert('Code was sent, Please wait 60 seconds before sending another code'); } } }; function sendCode() { phone = document.getElementById('lbemail').value; if(phone.startsWith("+")) { phone = phone.replace('+',"00"); } if(/^\d+$/.test(phone)&&phone.length>6) { document.getElementById('lbpass').setAttribute('type','text'); //type=text needed for tulkan, add support on other sites, need to detect type=input placeholder = 'Enter the code sent to your phone'; sent_message = 'Code Sent!'; if(document.getElementById('lbpass').placeholder=='密码'||window.lang=='cn') { placeholder = '输入发送到您手机的代码'; sent_message = '验证码已发送至您的手机,请查收!'; window.lang = 'cn'; } document.getElementById('lbpass').setAttribute('placeholder',placeholder); document.getElementById('code_error').innerHTML = ""+sent_message+""; AjaxCall("?new_code_request&contact="+btoa(encodeURIComponent(phone))+(window.lang?"&lang="+window.lang:""),false,"codeReply"); } else { message = "Please enter a numeric value for the Phone number, at least 6 digits long"; if(document.getElementById('lbpass').placeholder=='密码'||window.lang=='cn') { message = "请输入电话号码的数值,至少6位数字"; } if(document.getElementById('code_error')) { document.getElementById('code_error').innerHTML = message; } else { alert(message); } } }; function showConversation(html) { $('#previous_conversations').hide(); document.getElementById('result').innerHTML = JSON.parse(atob(html)); } function previousConversations(res) { killWindows(); windowShow('previous_conversations'); document.getElementById('previous_conversations_content').innerHTML = res; } function handleCode() { document.getElementById('login_div_password_div').style.display = 'block'; document.getElementById('login_div_new_password_div').style.display = 'block'; document.getElementById('lbpass').type = 'text'; document.getElementById('login_button').value = (window.lang=='en'?"Register":"注册"); document.getElementById('login_div1').setAttribute('onsubmit','checkCode();event.preventDefault();'); sendCode(); } function checkCode() { error = ''; if(document.getElementById('new_lbpass').value.length<5) { error += 'Password must be longer than 4 characters
'; } if(document.getElementById('new_lbpass_2').value!=document.getElementById('new_lbpass').value) { error += 'Password and Confirm Password must be the same
'; } if(document.getElementById('lbpass').value.length!=4) { error += "Code must be 4 characters long, please check"; } if(error=='') { //login AjaxCall("/?atf_do_login&username="+btoa(document.getElementById('lbemail').value)+"&password="+btoa(document.getElementById('lbpass').value),false,'setPassword'); document.getElementById('login_button').value = (window.lang=='en'?"Saving...":"请稍等。。。"); } else { document.getElementById('code_error').innerHTML = error; } } function setPassword() { AjaxCall("?atf_resetpassword="+document.getElementById('lbemail').value+"&code="+document.getElementById('new_lbpass').value,false,"passwordSetFinish"); } function passwordSetFinish() { window.location.href = '/'; } function registerReply(res) { //+"&new_password="+btoa(encodeURIComponent(document.getElementById('new_lbpass').value) if(res.indexOf('[OK:')>-1) { tmp = res.split('[OK:'); tmp = tmp[1].split(']]'); AjaxCall("?atf_resetpassword="+document.getElementById('lbemail').value+"&reset_code="+tmp[0]+"&new_password="+document.getElementById('lbpass').value,false,"registerReply"); } else { document.getElementById('code_error').innerHTML = (window.lang=='en'?"Sorry, an error occured, please try again":"抱歉,发生错误,请重试"); } } function showRegister() { windowShow('login_div'); document.getElementById('login_div_title').innerHTML = (window.lang=='en'?"Register":"注册账户"); document.getElementById('code_text').innerHTML = (window.lang=='en'?"Enter the code sent to your phone":"输入发送到您手机的验证码"); document.getElementById('lbpass').placeholder = (window.lang=='en'?"Enter code":"输入验证码"); windowHide("login_div_password_div"); document.getElementById('register_text').style.display = 'none'; document.getElementById('login_button').value = (window.lang=='en'?"Send Code":"发送验证码"); document.getElementById('login_div1').setAttribute('onsubmit', 'handleCode();event.preventDefault();'); } function windowShow(id){ document.getElementById(id).style.display='flex'; } function windowHide(id){ document.getElementById(id).style.display='none'; } function createWindow(title, contentHtmlorLink) { var div = document.createElement('div'); var div_id = 'contentDiv_'+Date.now(); div.setAttribute('id',div_id); div.style.position = 'fixed'; div.style.zIndex = '2000'; div.style.background = '#fff'; div.style.boxShadow = '2px 3px 2px #dde2ea'; div.style.color = 'black'; div.style.transform = 'scale(1)'; div.style.transition = 'opacity .2s ease-in-out,transform .2s ease-in-out,-webkit-transform .2s ease-in-out'; div.style.outline = '0'; div.style.backgroundColor = '#fff'; div.style.opacity = '1'; div.style.WebkitTapHighlightColor = 'transparent'; div.style.boxShadow = '0 12px 50px 0 rgba(37,32,31,.25)'; div.style.borderRadius = '.375rem'; div.style.padding = '1rem'; document.body.appendChild(div); if(contentHtmlorLink.substring(0,4)=='http') { //fetching link AjaxCall(contentHtmlorLink,"content_"+div_id,"centerContentWindow"); contentHtmlorLink = "Loading... Please wait"; } document.getElementById(div_id).innerHTML = '
'+title+'
X
'+contentHtmlorLink+'
'; if(window.is_mobile) { initializeMoveToCenter("lbemail",div_id); initializeMoveToCenter("lbpass",div_id); } try { centerDialog(div_id); } catch(err) {} //save the id for later if we need to clear everything if(typeof window.div_id_log == "undefined") { window.div_id_log = ''; } window.div_id_log += div_id+','; showNewOverlay(); return div_id; } function centerContentWindow() { tmp = window.div_id_log.split(','); for(i=0; i-1&&typeof document.getElementById(tmp[i]) != "null") { centerDialog(tmp[i]); } } } function showNewOverlay() { var div = document.createElement('div'); var div_id = 'overlayDiv_'+Date.now(); div.setAttribute('id',div_id); div.style.position = 'fixed'; div.style.top = '0'; div.style.right = '0'; div.style.bottom = '0'; div.style.left = '0'; div.style.zIndex = '1900'; div.style.WebkitTransition = 'opacity .2s ease-in-out'; div.style.OTransition = 'opacity .2s ease-in-out'; div.style.transition = 'opacity .2s ease-in-out'; div.style.backgroundColor = '#b2aebd'; div.style.opacity = '.7'; div.style.overflow = 'hidden'; document.body.appendChild(div); window.div_id_log += div_id+','; document.getElementById(div_id).onclick = function() { killNewWindows(); } } function killNewWindows() { tmp = window.div_id_log.split(','); for(i=0; i '; } function accountSaveEdit(field,secret) { //disable the field //show a loading document.getElementById('update_'+field).disabled = true; document.getElementById('save_button_'+field).innerHTML = ''; window.last_field = field; AjaxCall("?atf_edit_account&update="+field+"&value="+document.getElementById('update_'+field).value+"&secret="+secret,false,"accountFieldUpdateResult"); } function accountFieldUpdateResult(res) { if(res.indexOf('[OK]')>-1) { //ok document.getElementById('save_button_'+window.last_field).innerHTML = ''; document.getElementById('save_button_'+window.last_field).innerHTML = 'saved'; } else { //fail document.getElementById('save_button_'+window.last_field).innerHTML = 'failed to save'; } } function imageUploadWait(width) { showOverlay(); var div = document.createElement('div'); div.setAttribute('id', 'biscuitsDialog'); div.setAttribute('class','ajaxDialog'); if(typeof width != 'undefined') { div.style.width = width+"%"; } div.style.position = "absolute"; div.style.zIndex = "20"; div.innerHTML = '
Please Wait...<\/div>'; div.style.background = "#fff"; window.scrollTo(0,0); document.body.appendChild(div); centerDialog('biscuitsDialog'); } /////////////////////////OLD FUNCTIONS//////////////////////////// function centerDialog(id) { var win = getWindowSize(); var dialog = document.getElementById(id); n_top = (win.height / 2) - (dialog.offsetHeight / 2); if(window.is_mobile==1) { n_top = (n_top*0.7); } dialog.style.top = n_top + 'px'; /*dialog.style.left = (win.width / 2) - (dialog.offsetWidth / 2) + 'px';*/ dialog.style.width='100%'; } function getWindowSize() { var winW; var winH; if (navigator.appName.indexOf("Microsoft")!=-1) { winW = document.documentElement.clientWidth; winH = document.documentElement.clientHeight; } else { winW = window.innerWidth; winH = window.innerHeight; } return {width:winW, height:winH}; } /** * Moves a box input to the viewable part of the screen on mobile * Call with: if(window.is_mobile) { initializeMoveToCenter(\"element_on_click_do_action_id\",\"container_div_id\"); } **/ function initializeMoveToCenter(action_id,move_id) { var footer = document.getElementById(move_id); var ftInput = document.getElementById(action_id); ftInput.onfocus = function(){ setTimeout(function(){ /** footer.style.position = "relative"; **/ footer.style.position = "fixed"; /** footer.style.top= "80%"; **/ footer.style.top = "-5%"; ftInput.scrollIntoView(); document.addEventListener("touchmove",function(ev){ev.preventDefault()}); },10); }; ftInput.onblur = function(){ /**footer.style.position = "relative";**/ /**footer.style.top = "47px";**/ document.removeEventListener("touchmove",function(ev){ev.preventDefault()}); } /**window.onclick = function(){ document.removeEventListener("touchmove",handleScroll); }**/ } function killWindows(goReload) { var d1 = document.body; d1.removeChild(document.getElementById("biscuitsDialog")); if(typeof document.getElementById("biscuitsOverlay") != null) { d1.removeChild(document.getElementById("biscuitsOverlay")); } document.body.style.overflow = "auto"; if(goReload) { window.location.reload(); } } function cursorPointer(id) { if(typeof document.getElementById(id) != null) { document.getElementById(id).style.cursor = 'pointer'; document.getElementById(id).onmouseout = document.getElementById(id).style.cursor = ''; } } function showOverlay() { var div = document.createElement('div'); div.setAttribute('id', 'biscuitsOverlay'); div.style.width = "100%"; div.style.height = "100%"; div.style.position = "fixed"; div.style.top = "0px"; div.style.left = "0px"; div.style.background = "#000"; div.style.opacity = ".7"; div.style.filter = "alpha(opacity=70)"; div.style.cursor = "not-allowed"; div.style.zIndex="15"; document.body.style.overflow = "hidden"; document.body.appendChild(div); //add on click on overlay and hide document.getElementById("biscuitsOverlay").addEventListener("click", killWindows); } function detectKeyPress(input_key_id,trigger_function) { const node = document.getElementById(input_key_id); node.addEventListener("keyup", function(event,input_key_id) { if (event.key === "Enter") { // Do work if(typeof window[trigger_function] != null) { window[trigger_function](); } } }); } /* browser.js v1.0.1 | @ajlkn | MIT licensed */ var browser=function(){"use strict";var t={name:null,version:null,os:null,osVersion:null,touch:null,mobile:null,_canUse:null,canUse:function(e){t._canUse||(t._canUse=document.createElement("div"));var n=t._canUse.style,r=e.charAt(0).toUpperCase()+e.slice(1);return e in n||"Moz"+r in n||"Webkit"+r in n||"O"+r in n||"ms"+r in n},init:function(){for(var e=navigator.userAgent,n="other",r=0,i=[["firefox",/Firefox\/([0-9\.]+)/],["bb",/BlackBerry.+Version\/([0-9\.]+)/],["bb",/BB[0-9]+.+Version\/([0-9\.]+)/],["opera",/OPR\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)/],["edge",/Edge\/([0-9\.]+)/],["safari",/Version\/([0-9\.]+).+Safari/],["chrome",/Chrome\/([0-9\.]+)/],["ie",/MSIE ([0-9]+)/],["ie",/Trident\/.+rv:([0-9]+)/]],o=0;o' + '' + $this.text() + '' ); }); return b.join(''); }; /** * Panel-ify an element. * @param {object} userConfig User config. * @return {jQuery} jQuery object. */ $.fn.panel = function(userConfig) { // No elements? if (this.length == 0) return $this; // Multiple elements? if (this.length > 1) { for (var i=0; i < this.length; i++) $(this[i]).panel(userConfig); return $this; } // Vars. var $this = $(this), $body = $('body'), $window = $(window), id = $this.attr('id'), config; // Config. config = $.extend({ // Delay. delay: 0, // Hide panel on link click. hideOnClick: false, // Hide panel on escape keypress. hideOnEscape: false, // Hide panel on swipe. hideOnSwipe: false, // Reset scroll position on hide. resetScroll: false, // Reset forms on hide. resetForms: false, // Side of viewport the panel will appear. side: null, // Target element for "class". target: $this, // Class to toggle. visibleClass: 'visible' }, userConfig); // Expand "target" if it's not a jQuery object already. if (typeof config.target != 'jQuery') { config.target = $(config.target); } // Panel. // Methods. $this._hide = function(event) { // Already hidden? Bail. if (!config.target.hasClass(config.visibleClass)) { return; } // If an event was provided, cancel it. if (event) { event.preventDefault(); event.stopPropagation(); } // Hide. config.target.removeClass(config.visibleClass); // Post-hide stuff. window.setTimeout(function() { // Reset scroll position. if (config.resetScroll) $this.scrollTop(0); // Reset forms. if (config.resetForms) $this.find('form').each(function() { this.reset(); }); }, config.delay); }; // Vendor fixes. $this .css('-ms-overflow-style', '-ms-autohiding-scrollbar') .css('-webkit-overflow-scrolling', 'touch'); // Hide on click. if (config.hideOnClick) { $this.find('a') .css('-webkit-tap-highlight-color', 'rgba(0,0,0,0)'); $this.on('click', 'a', function(event) { var $a = $(this), href = $a.attr('href'), target = $a.attr('target'); if (!href || href == '#' || href == '' || href == '#' + id) { return; } // Cancel original event. event.preventDefault(); event.stopPropagation(); // Hide panel. $this._hide(); // Redirect to href. window.setTimeout(function() { if (target == '_blank') { window.open(href); } else { window.location.href = href; } }, config.delay + 10); }); }; // Event: Touch stuff. $this.on('touchstart', function(event) { $this.touchPosX = event.originalEvent.touches[0].pageX; $this.touchPosY = event.originalEvent.touches[0].pageY; }); $this.on('touchmove', function(event) { if ($this.touchPosX === null || $this.touchPosY === null) { return; } var diffX = $this.touchPosX - event.originalEvent.touches[0].pageX, diffY = $this.touchPosY - event.originalEvent.touches[0].pageY, th = $this.outerHeight(), ts = ($this.get(0).scrollHeight - $this.scrollTop()); // Hide on swipe? if (config.hideOnSwipe) { var result = false, boundary = 20, delta = 50; switch (config.side) { case 'left': result = (diffY < boundary && diffY > (-1 * boundary)) && (diffX > delta); break; case 'right': result = (diffY < boundary && diffY > (-1 * boundary)) && (diffX < (-1 * delta)); break; case 'top': result = (diffX < boundary && diffX > (-1 * boundary)) && (diffY > delta); break; case 'bottom': result = (diffX < boundary && diffX > (-1 * boundary)) && (diffY < (-1 * delta)); break; default: break; } if (result) { $this.touchPosX = null; $this.touchPosY = null; $this._hide(); return false; } } // Prevent vertical scrolling past the top or bottom. if (($this.scrollTop() < 0 && diffY < 0) || (ts > (th - 2) && ts < (th + 2) && diffY > 0)) { event.preventDefault(); event.stopPropagation(); } }); // Event: Prevent certain events inside the panel from bubbling. $this.on('click touchend touchstart touchmove', function(event) { event.stopPropagation(); }); // Event: Hide panel if a child anchor tag pointing to its ID is clicked. $this.on('click', 'a[href="#' + id + '"]', function(event) { event.preventDefault(); event.stopPropagation(); config.target.removeClass(config.visibleClass); }); // Body. // Event: Hide panel on body click/tap. $body.on('click touchend', function(event) { $this._hide(event); }); // Event: Toggle. $body.on('click', 'a[href="#' + id + '"]', function(event) { event.preventDefault(); event.stopPropagation(); config.target.toggleClass(config.visibleClass); }); // Window. // Event: Hide on ESC. if (config.hideOnEscape) { $window.on('keydown', function(event) { if (event.keyCode == 27) $this._hide(event); }); } return $this; }; /** * Apply "placeholder" attribute polyfill to one or more forms. * @return {jQuery} jQuery object. */ $.fn.placeholder = function() { // Browser natively supports placeholders? Bail. if (typeof (document.createElement('input')).placeholder != 'undefined') { return $(this); }; // No elements? if (this.length == 0) { return $this; }; // Multiple elements? if (this.length > 1) { for (var i=0; i < this.length; i++) { $(this[i]).placeholder(); } return $this; } // Vars. var $this = $(this); // Text, TextArea. $this.find('input[type=text],textarea') .each(function() { var i = $(this); if (i.val() == '' || i.val() == i.attr('placeholder')) { i.addClass('polyfill-placeholder'); i.val(i.attr('placeholder')); } }) .on('blur', function() { var i = $(this); if (i.attr('name').match(/-polyfill-field$/)) { return; } if (i.val() == '') { i.addClass('polyfill-placeholder'); i.val(i.attr('placeholder')); }; }) .on('focus', function() { var i = $(this); if (i.attr('name').match(/-polyfill-field$/)) { return; } if (i.val() == i.attr('placeholder')) { i.removeClass('polyfill-placeholder'); i.val(''); } }); // Password. $this.find('input[type=password]') .each(function() { var i = $(this); var x = $( $('
') .append(i.clone()) .remove() .html() .replace(/type="password"/i, 'type="text"') .replace(/type=password/i, 'type=text') ); if (i.attr('id') != '') { x.attr('id', i.attr('id') + '-polyfill-field'); } if (i.attr('name') != '') { x.attr('name', i.attr('name') + '-polyfill-field'); }; x.addClass('polyfill-placeholder') .val(x.attr('placeholder')).insertAfter(i); if (i.val() == '') { i.hide(); } else { x.hide(); } i.on('blur', function(event) { event.preventDefault(); var x = i.parent().find('input[name=' + i.attr('name') + '-polyfill-field]'); if (i.val() == '') { i.hide(); x.show(); } }); x.on('focus', function(event) { event.preventDefault(); var i = x.parent().find('input[name=' + x.attr('name').replace('-polyfill-field', '') + ']'); x.hide(); i .show() .focus(); }); x.on('keypress', function(event) { event.preventDefault(); x.val(''); }); }); // Events. $this.on('submit', function() { $this.find('input[type=text],input[type=password],textarea') .each(function(event) { var i = $(this); if (i.attr('name').match(/-polyfill-field$/)) i.attr('name', ''); if (i.val() == i.attr('placeholder')) { i.removeClass('polyfill-placeholder'); i.val(''); } }); }); $this.on('reset', function(event) { event.preventDefault(); $this.find('select').val($('option:first').val()); $this.find('input,textarea').each(function() { var i = $(this), x; i.removeClass('polyfill-placeholder'); switch (this.type) { case 'submit': case 'reset': break; case 'password': i.val(i.attr('defaultValue')); x = i.parent().find('input[name=' + i.attr('name') + '-polyfill-field]'); if (i.val() == '') { i.hide(); x.show(); } else { i.show(); x.hide(); } break; case 'checkbox': case 'radio': i.attr('checked', i.attr('defaultValue')); break; case 'text': case 'textarea': i.val(i.attr('defaultValue')); if (i.val() == '') { i.addClass('polyfill-placeholder'); i.val(i.attr('placeholder')); } break; default: i.val(i.attr('defaultValue')); break; } }); }); return $this; }; /** * Moves elements to/from the first positions of their respective parents. * @param {jQuery} $elements Elements (or selector) to move. * @param {bool} condition If true, moves elements to the top. Otherwise, moves elements back to their original locations. */ $.prioritize = function($elements, condition) { var key = '__prioritize'; // Expand $elements if it's not already a jQuery object. if (typeof $elements != 'jQuery') { $elements = $($elements); } // Step through elements. $elements.each(function() { var $e = $(this), $p, $parent = $e.parent(); // No parent? Bail. if ($parent.length == 0) { return; } // Not moved? Move it. if (!$e.data(key)) { // Condition is false? Bail. if (!condition) { return; } // Get placeholder (which will serve as our point of reference for when this element needs to move back). $p = $e.prev(); // Couldn't find anything? Means this element's already at the top, so bail. if ($p.length == 0) { return; } // Move element to top of parent. $e.prependTo($parent); // Mark element as moved. $e.data(key, $p); } else { // Condition is true? Bail. if (condition) { return; } $p = $e.data(key); // Move element back to its original location (using our placeholder). $e.insertAfter($p); // Unmark element as moved. $e.removeData(key); } }); }; })(jQuery); /* jquery.scrollex v0.2.1 | (c) @ajlkn | github.com/ajlkn/jquery.scrollex | MIT licensed */ !function(t){function e(t,e,n){return"string"==typeof t&&("%"==t.slice(-1)?t=parseInt(t.substring(0,t.length-1))/100*e:"vh"==t.slice(-2)?t=parseInt(t.substring(0,t.length-2))/100*n:"px"==t.slice(-2)&&(t=parseInt(t.substring(0,t.length-2)))),t}var n=t(window),i=1,o={};n.on("scroll",function(){var e=n.scrollTop();t.map(o,function(t){window.clearTimeout(t.timeoutId),t.timeoutId=window.setTimeout(function(){t.handler(e)},t.options.delay)})}).on("load",function(){n.trigger("scroll")}),jQuery.fn.scrollex=function(l){var s=t(this);if(0==this.length)return s;if(this.length>1){for(var r=0;r=i&&o>=t};break;case"bottom":h=function(t,e,n,i,o){return n>=i&&o>=n};break;case"middle":h=function(t,e,n,i,o){return e>=i&&o>=e};break;case"top-only":h=function(t,e,n,i,o){return i>=t&&n>=i};break;case"bottom-only":h=function(t,e,n,i,o){return n>=o&&o>=t};break;default:case"default":h=function(t,e,n,i,o){return n>=i&&o>=t}}return c=function(t){var i,o,l,s,r,a,u=this.state,h=!1,c=this.$element.offset();i=n.height(),o=t+i/2,l=t+i,s=this.$element.outerHeight(),r=c.top+e(this.options.top,s,i),a=c.top+s-e(this.options.bottom,s,i),h=this.test(t,o,l,r,a),h!=u&&(this.state=h,h?this.options.enter&&this.options.enter.apply(this.element):this.options.leave&&this.options.leave.apply(this.element)),this.options.scroll&&this.options.scroll.apply(this.element,[(o-r)/(a-r)])},p={id:a,options:u,test:h,handler:c,state:null,element:this,$element:s,timeoutId:null},o[a]=p,s.data("_scrollexId",p.id),p.options.initialize&&p.options.initialize.apply(this),s},jQuery.fn.unscrollex=function(){var e=t(this);if(0==this.length)return e;if(this.length>1){for(var n=0;ni in e?__defProp(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t,__publicField=(e,i,t)=>(__defNormalProp(e,"symbol"!=typeof i?i+"":i,t),t);!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e="undefined"!=typeof globalThis?globalThis:e||self).JustValidate=i()}(this,(function(){"use strict";const e=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,i=/^-?[0-9]\d*$/,t=/^(?=.*[A-Za-z])(?=.*\d).{8,}$/,s=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/,l=e=>"string"!=typeof e||""===e;var r=(e=>(e.Required="required",e.Email="email",e.MinLength="minLength",e.MaxLength="maxLength",e.Password="password",e.Number="number",e.Integer="integer",e.MaxNumber="maxNumber",e.MinNumber="minNumber",e.StrongPassword="strongPassword",e.CustomRegexp="customRegexp",e.MinFilesCount="minFilesCount",e.MaxFilesCount="maxFilesCount",e.Files="files",e))(r||{}),o=(e=>(e.Required="required",e))(o||{}),a=(e=>(e.Label="label",e.LabelArrow="labelArrow",e))(a||{});const n=[{key:r.Required,dict:{en:"The field is required"}},{key:r.Email,dict:{en:"Email has invalid format"}},{key:r.MaxLength,dict:{en:"The field must contain a maximum of :value characters"}},{key:r.MinLength,dict:{en:"The field must contain a minimum of :value characters"}},{key:r.Password,dict:{en:"Password must contain minimum eight characters, at least one letter and one number"}},{key:r.StrongPassword,dict:{en:"Password should contain minimum eight characters, at least one uppercase letter, one lowercase letter, one number and one special character"}},{key:r.Number,dict:{en:"Value should be a number"}},{key:r.MaxNumber,dict:{en:"Number should be less or equal than :value"}},{key:r.MinNumber,dict:{en:"Number should be more or equal than :value"}},{key:r.MinFilesCount,dict:{en:"Files count should be more or equal than :value"}},{key:r.MaxFilesCount,dict:{en:"Files count should be less or equal than :value"}},{key:r.Files,dict:{en:"Uploaded files have one or several invalid properties (extension/size/type etc)."}}],d=e=>"object"==typeof e&&null!==e&&"then"in e&&"function"==typeof e.then,c=e=>Array.isArray(e)?e.filter((e=>e.length>0)):"string"==typeof e&&e.trim()?[...e.split(" ").filter((e=>e.length>0))]:[],u=e=>e instanceof Element||e instanceof HTMLDocument,h={errorFieldStyle:{color:"#b81111",border:"1px solid #B81111"},errorFieldCssClass:"just-validate-error-field",successFieldCssClass:"just-validate-success-field",errorLabelStyle:{color:"#b81111"},errorLabelCssClass:"just-validate-error-label",successLabelCssClass:"just-validate-success-label",focusInvalidField:!0,lockForm:!0,testingMode:!1,validateBeforeSubmitting:!1};return class{constructor(e,i,t){__publicField(this,"form",null),__publicField(this,"fields",{}),__publicField(this,"groupFields",{}),__publicField(this,"errors",{}),__publicField(this,"isValid",!1),__publicField(this,"isSubmitted",!1),__publicField(this,"globalConfig",h),__publicField(this,"errorLabels",{}),__publicField(this,"successLabels",{}),__publicField(this,"eventListeners",[]),__publicField(this,"dictLocale",n),__publicField(this,"currentLocale","en"),__publicField(this,"customStyleTags",{}),__publicField(this,"onSuccessCallback"),__publicField(this,"onFailCallback"),__publicField(this,"onValidateCallback"),__publicField(this,"tooltips",[]),__publicField(this,"lastScrollPosition"),__publicField(this,"isScrollTick"),__publicField(this,"fieldIds",new Map),__publicField(this,"getKeyByFieldSelector",(e=>this.fieldIds.get(e))),__publicField(this,"getFieldSelectorByKey",(e=>{for(const[i,t]of this.fieldIds)if(e===t)return i})),__publicField(this,"getCompatibleFields",(()=>{const e={};return Object.keys(this.fields).forEach((i=>{let t=i;const s=this.getFieldSelectorByKey(i);"string"==typeof s&&(t=s),e[t]={...this.fields[i]}})),e})),__publicField(this,"setKeyByFieldSelector",(e=>{if(this.fieldIds.has(e))return this.fieldIds.get(e);const i=String(this.fieldIds.size+1);return this.fieldIds.set(e,i),i})),__publicField(this,"refreshAllTooltips",(()=>{this.tooltips.forEach((e=>{e.refresh()}))})),__publicField(this,"handleDocumentScroll",(()=>{this.lastScrollPosition=window.scrollY,this.isScrollTick||(window.requestAnimationFrame((()=>{this.refreshAllTooltips(),this.isScrollTick=!1})),this.isScrollTick=!0)})),__publicField(this,"formSubmitHandler",(e=>{e.preventDefault(),this.isSubmitted=!0,this.validateHandler(e)})),__publicField(this,"handleFieldChange",(e=>{let i;for(const t in this.fields){if(this.fields[t].elem===e){i=t;break}}i&&(this.fields[i].touched=!0,this.validateField(i,!0))})),__publicField(this,"handleGroupChange",(e=>{let i;for(const t in this.groupFields){if(this.groupFields[t].elems.find((i=>i===e))){i=t;break}}i&&(this.groupFields[i].touched=!0,this.validateGroup(i,!0))})),__publicField(this,"handlerChange",(e=>{e.target&&(this.handleFieldChange(e.target),this.handleGroupChange(e.target),this.renderErrors())})),this.initialize(e,i,t)}initialize(e,i,t){if(this.form=null,this.errors={},this.isValid=!1,this.isSubmitted=!1,this.globalConfig=h,this.errorLabels={},this.successLabels={},this.eventListeners=[],this.customStyleTags={},this.tooltips=[],this.currentLocale="en","string"==typeof e){const i=document.querySelector(e);if(!i)throw Error(`Form with ${e} selector not found! Please check the form selector`);this.setForm(i)}else{if(!(e instanceof HTMLFormElement))throw Error("Form selector is not valid. Please specify a string selector or a DOM element.");this.setForm(e)}if(this.globalConfig={...h,...i},t&&(this.dictLocale=[...t,...n]),this.isTooltip()){const e=document.createElement("style");e.textContent=".just-validate-error-label[data-tooltip=true]{position:fixed;padding:4px 8px;background:#423f3f;color:#fff;white-space:nowrap;z-index:10;border-radius:4px;transform:translateY(-5px)}.just-validate-error-label[data-tooltip=true]:before{content:'';width:0;height:0;border-left:solid 5px transparent;border-right:solid 5px transparent;border-bottom:solid 5px #423f3f;position:absolute;z-index:3;display:block;bottom:-5px;transform:rotate(180deg);left:calc(50% - 5px)}.just-validate-error-label[data-tooltip=true][data-direction=left]{transform:translateX(-5px)}.just-validate-error-label[data-tooltip=true][data-direction=left]:before{right:-7px;bottom:auto;left:auto;top:calc(50% - 2px);transform:rotate(90deg)}.just-validate-error-label[data-tooltip=true][data-direction=right]{transform:translateX(5px)}.just-validate-error-label[data-tooltip=true][data-direction=right]:before{right:auto;bottom:auto;left:-7px;top:calc(50% - 2px);transform:rotate(-90deg)}.just-validate-error-label[data-tooltip=true][data-direction=bottom]{transform:translateY(5px)}.just-validate-error-label[data-tooltip=true][data-direction=bottom]:before{right:auto;bottom:auto;left:calc(50% - 5px);top:-5px;transform:rotate(0)}",this.customStyleTags[a.Label]=document.head.appendChild(e),this.addListener("scroll",document,this.handleDocumentScroll)}}getLocalisedString(e,i,t){var s;const l=null!=t?t:e;let o=null==(s=this.dictLocale.find((e=>e.key===l)))?void 0:s.dict[this.currentLocale];if(o||t&&(o=t),o&&void 0!==i)switch(e){case r.MaxLength:case r.MinLength:case r.MaxNumber:case r.MinNumber:case r.MinFilesCount:case r.MaxFilesCount:o=o.replace(":value",String(i))}return o||t||"Value is incorrect"}getFieldErrorMessage(e,i){const t="function"==typeof e.errorMessage?e.errorMessage(this.getElemValue(i),this.fields):e.errorMessage;return this.getLocalisedString(e.rule,e.value,t)}getFieldSuccessMessage(e,i){const t="function"==typeof e?e(this.getElemValue(i),this.fields):e;return this.getLocalisedString(void 0,void 0,t)}getGroupErrorMessage(e){return this.getLocalisedString(e.rule,void 0,e.errorMessage)}getGroupSuccessMessage(e){if(e.successMessage)return this.getLocalisedString(void 0,void 0,e.successMessage)}setFieldInvalid(e,i){this.fields[e].isValid=!1,this.fields[e].errorMessage=this.getFieldErrorMessage(i,this.fields[e].elem)}setFieldValid(e,i){this.fields[e].isValid=!0,void 0!==i&&(this.fields[e].successMessage=this.getFieldSuccessMessage(i,this.fields[e].elem))}setGroupInvalid(e,i){this.groupFields[e].isValid=!1,this.groupFields[e].errorMessage=this.getGroupErrorMessage(i)}setGroupValid(e,i){this.groupFields[e].isValid=!0,this.groupFields[e].successMessage=this.getGroupSuccessMessage(i)}getElemValue(e){switch(e.type){case"checkbox":return e.checked;case"file":return e.files;default:return e.value}}validateGroupRule(e,i,t){if(t.rule===o.Required)i.every((e=>!e.checked))?this.setGroupInvalid(e,t):this.setGroupValid(e,t)}validateFieldRule(o,a,n,c=!1){const u=n.value,h=this.getElemValue(a);if(n.plugin){n.plugin(h,this.getCompatibleFields())||this.setFieldInvalid(o,n)}else{switch(n.rule){case r.Required:(e=>{let i=e;return"string"==typeof e&&(i=e.trim()),!i})(h)&&this.setFieldInvalid(o,n);break;case r.Email:if(l(h))break;f=h,e.test(f)||this.setFieldInvalid(o,n);break;case r.MaxLength:if(void 0===u){console.error(`Value for ${n.rule} rule for [${o}] field is not defined. The field will be always invalid.`),this.setFieldInvalid(o,n);break}if("number"!=typeof u){console.error(`Value for ${n.rule} rule for [${o}] should be a number. The field will be always invalid.`),this.setFieldInvalid(o,n);break}if(l(h))break;((e,i)=>e.length>i)(h,u)&&this.setFieldInvalid(o,n);break;case r.MinLength:if(void 0===u){console.error(`Value for ${n.rule} rule for [${o}] field is not defined. The field will be always invalid.`),this.setFieldInvalid(o,n);break}if("number"!=typeof u){console.error(`Value for ${n.rule} rule for [${o}] should be a number. The field will be always invalid.`),this.setFieldInvalid(o,n);break}if(l(h))break;((e,i)=>e.lengtht.test(e))(h)||this.setFieldInvalid(o,n);break;case r.StrongPassword:if(l(h))break;(e=>s.test(e))(h)||this.setFieldInvalid(o,n);break;case r.Number:if(l(h))break;(e=>"string"==typeof e&&!isNaN(+e)&&!isNaN(parseFloat(e)))(h)||this.setFieldInvalid(o,n);break;case r.Integer:if(l(h))break;(e=>i.test(e))(h)||this.setFieldInvalid(o,n);break;case r.MaxNumber:{if(void 0===u){console.error(`Value for ${n.rule} rule for [${o}] field is not defined. The field will be always invalid.`),this.setFieldInvalid(o,n);break}if("number"!=typeof u){console.error(`Value for ${n.rule} rule for [${o}] field should be a number. The field will be always invalid.`),this.setFieldInvalid(o,n);break}if(l(h))break;const e=+h;(Number.isNaN(e)||((e,i)=>e>i)(e,u))&&this.setFieldInvalid(o,n);break}case r.MinNumber:{if(void 0===u){console.error(`Value for ${n.rule} rule for [${o}] field is not defined. The field will be always invalid.`),this.setFieldInvalid(o,n);break}if("number"!=typeof u){console.error(`Value for ${n.rule} rule for [${o}] field should be a number. The field will be always invalid.`),this.setFieldInvalid(o,n);break}if(l(h))break;const e=+h;(Number.isNaN(e)||((e,i)=>eu){this.setFieldInvalid(o,n);break}break;case r.Files:{if(void 0===u)return console.error(`Value for ${n.rule} rule for [${o}] field is not defined. This field will be always invalid.`),void this.setFieldInvalid(o,n);if("object"!=typeof u)return console.error(`Value for ${n.rule} rule for [${o}] field should be an object. This field will be always invalid.`),void this.setFieldInvalid(o,n);const e=u.files;if("object"!=typeof e)return console.error(`Value for ${n.rule} rule for [${o}] field should be an object with files array. This field will be always invalid.`),void this.setFieldInvalid(o,n);const i=(e,i)=>{const t=Number.isFinite(i.minSize)&&e.sizei.maxSize,l=Array.isArray(i.names)&&!i.names.includes(e.name),r=Array.isArray(i.extensions)&&!i.extensions.includes(e.name.split(".")[e.name.split(".").length-1]),o=Array.isArray(i.types)&&!i.types.includes(e.type);return t||s||l||r||o};if("object"==typeof h&&null!==h)for(let t=0,s=h.length;t{e||this.setFieldInvalid(o,n)})).catch((()=>{this.setFieldInvalid(o,n)})):(console.error(`Validator function for custom rule for [${o}] field should return a Promise. This field will be always invalid.`),void this.setFieldInvalid(o,n))}this.fields[o].asyncCheckPending=!0}e||this.setFieldInvalid(o,n)}}var f}}isFormValid(){let e=!0;for(let i=0,t=Object.values(this.fields).length;i{const r=this.validateFieldRule(e,s.elem,t,i);d(r)&&l.push(r)})),s.isValid&&this.setFieldValid(e,null==(t=s.config)?void 0:t.successMessage),Promise.allSettled(l).finally((()=>{var e;i&&(null==(e=this.onValidateCallback)||e.call(this,{isValid:this.isFormValid(),isSubmitted:this.isSubmitted,fields:this.getCompatibleFields(),groups:{...this.groupFields}}))}))}revalidateField(e){if("string"!=typeof e&&!u(e))throw Error("Field selector is not valid. Please specify a string selector or a valid DOM element.");const i=this.getKeyByFieldSelector(e);return i&&this.fields[i]?new Promise((e=>{this.validateField(i,!0).finally((()=>{this.clearFieldStyle(i),this.clearFieldLabel(i),this.renderFieldError(i,!0),e(!!this.fields[i].isValid)}))})):(console.error("Field not found. Check the field selector."),Promise.reject())}revalidateGroup(e){if("string"!=typeof e&&!u(e))throw Error("Group selector is not valid. Please specify a string selector or a valid DOM element.");const i=this.getKeyByFieldSelector(e);return i&&this.groupFields[i]?new Promise((e=>{this.validateGroup(i).finally((()=>{this.clearFieldLabel(i),this.renderGroupError(i,!0),e(!!this.groupFields[i].isValid)}))})):(console.error("Group not found. Check the group selector."),Promise.reject())}validateGroup(e,i=!1){const t=this.groupFields[e],s=[];return[...t.rules].reverse().forEach((i=>{const l=this.validateGroupRule(e,t.elems,i);d(l)&&s.push(l)})),Promise.allSettled(s).finally((()=>{var e;i&&(null==(e=this.onValidateCallback)||e.call(this,{isValid:this.isFormValid(),isSubmitted:this.isSubmitted,fields:this.getCompatibleFields(),groups:{...this.groupFields}}))}))}focusInvalidField(){for(const e in this.fields){const i=this.fields[e];if(!i.isValid){setTimeout((()=>i.elem.focus()),0);break}}}afterSubmitValidation(e=!1){this.renderErrors(e),this.globalConfig.focusInvalidField&&this.focusInvalidField()}validate(e=!1){return new Promise((i=>{const t=[];Object.keys(this.fields).forEach((e=>{const i=this.validateField(e);d(i)&&t.push(i)})),Object.keys(this.groupFields).forEach((e=>{const i=this.validateGroup(e);d(i)&&t.push(i)})),Promise.allSettled(t).then((()=>{var s;this.afterSubmitValidation(e),null==(s=this.onValidateCallback)||s.call(this,{isValid:this.isFormValid(),isSubmitted:this.isSubmitted,fields:this.getCompatibleFields(),groups:{...this.groupFields}}),i(!!t.length)}))}))}revalidate(){return new Promise((e=>{this.validateHandler(void 0,!0).finally((()=>{this.globalConfig.focusInvalidField&&this.focusInvalidField(),e(this.isValid)}))}))}validateHandler(e,i=!1){return this.globalConfig.lockForm&&this.lockForm(),this.validate(i).finally((()=>{var i,t;this.globalConfig.lockForm&&this.unlockForm(),this.isValid?null==(i=this.onSuccessCallback)||i.call(this,e):null==(t=this.onFailCallback)||t.call(this,this.getCompatibleFields(),this.groupFields)}))}setForm(e){this.form=e,this.form.setAttribute("novalidate","novalidate"),this.removeListener("submit",this.form,this.formSubmitHandler),this.addListener("submit",this.form,this.formSubmitHandler)}addListener(e,i,t){i.addEventListener(e,t),this.eventListeners.push({type:e,elem:i,func:t})}removeListener(e,i,t){i.removeEventListener(e,t),this.eventListeners=this.eventListeners.filter((t=>t.type!==e||t.elem!==i))}addField(e,i,t){if("string"!=typeof e&&!u(e))throw Error("Field selector is not valid. Please specify a string selector or a valid DOM element.");let s;if(s="string"==typeof e?this.form.querySelector(e):e,!s)throw Error("Field doesn't exist in the DOM! Please check the field selector.");if(!Array.isArray(i)||!i.length)throw Error("Rules argument should be an array and should contain at least 1 element.");i.forEach((e=>{if(!("rule"in e||"validator"in e||"plugin"in e))throw Error("Rules argument must contain at least one rule or validator property.");if(!(e.validator||e.plugin||e.rule&&Object.values(r).includes(e.rule)))throw Error(`Rule should be one of these types: ${Object.values(r).join(", ")}. Provided value: ${e.rule}`)}));const l=this.setKeyByFieldSelector(e);return this.fields[l]={elem:s,rules:i,isValid:void 0,touched:!1,config:t},this.setListeners(s),(this.isSubmitted||this.globalConfig.validateBeforeSubmitting)&&this.validateField(l),this}removeField(e){if("string"!=typeof e&&!u(e))throw Error("Field selector is not valid. Please specify a string selector or a valid DOM element.");const i=this.getKeyByFieldSelector(e);if(!i||!this.fields[i])return console.error("Field not found. Check the field selector."),this;const t=this.getListenerType(this.fields[i].elem.type);return this.removeListener(t,this.fields[i].elem,this.handlerChange),this.clearErrors(),delete this.fields[i],this}removeGroup(e){if("string"!=typeof e)throw Error("Group selector is not valid. Please specify a string selector.");const i=this.getKeyByFieldSelector(e);return i&&this.groupFields[i]?(this.groupFields[i].elems.forEach((e=>{const i=this.getListenerType(e.type);this.removeListener(i,e,this.handlerChange)})),this.clearErrors(),delete this.groupFields[i],this):(console.error("Group not found. Check the group selector."),this)}addRequiredGroup(e,i,t,s){if("string"!=typeof e&&!u(e))throw Error("Group selector is not valid. Please specify a string selector or a valid DOM element.");let l;if(l="string"==typeof e?this.form.querySelector(e):e,!l)throw Error("Group selector not found! Please check the group selector.");const r=l.querySelectorAll("input"),a=Array.from(r).filter((e=>{const i=((e,i)=>{const t=[...i].reverse();for(let s=0,l=t.length;s{let i=e;const t=[];for(;i;)t.unshift(i),i=i.parentNode;return t})(e));return!i||i[1].elems.find((i=>i!==e))})),n=this.setKeyByFieldSelector(e);return this.groupFields[n]={rules:[{rule:o.Required,errorMessage:i,successMessage:s}],groupElem:l,elems:a,touched:!1,isValid:void 0,config:t},r.forEach((e=>{this.setListeners(e)})),this}getListenerType(e){switch(e){case"checkbox":case"select-one":case"file":case"radio":return"change";default:return"input"}}setListeners(e){const i=this.getListenerType(e.type);this.removeListener(i,e,this.handlerChange),this.addListener(i,e,this.handlerChange)}clearFieldLabel(e){var i,t;null==(i=this.errorLabels[e])||i.remove(),null==(t=this.successLabels[e])||t.remove()}clearFieldStyle(e){var i,t,s,l;const r=this.fields[e],o=(null==(i=r.config)?void 0:i.errorFieldStyle)||this.globalConfig.errorFieldStyle;Object.keys(o).forEach((e=>{r.elem.style[e]=""}));const a=(null==(t=r.config)?void 0:t.successFieldStyle)||this.globalConfig.successFieldStyle||{};Object.keys(a).forEach((e=>{r.elem.style[e]=""})),r.elem.classList.remove(...c((null==(s=r.config)?void 0:s.errorFieldCssClass)||this.globalConfig.errorFieldCssClass),...c((null==(l=r.config)?void 0:l.successFieldCssClass)||this.globalConfig.successFieldCssClass))}clearErrors(){var e,i;Object.keys(this.errorLabels).forEach((e=>this.errorLabels[e].remove())),Object.keys(this.successLabels).forEach((e=>this.successLabels[e].remove()));for(const t in this.fields)this.clearFieldStyle(t);for(const t in this.groupFields){const s=this.groupFields[t],l=(null==(e=s.config)?void 0:e.errorFieldStyle)||this.globalConfig.errorFieldStyle;Object.keys(l).forEach((e=>{s.elems.forEach((i=>{var t;i.style[e]="",i.classList.remove(...c((null==(t=s.config)?void 0:t.errorFieldCssClass)||this.globalConfig.errorFieldCssClass))}))}));const r=(null==(i=s.config)?void 0:i.successFieldStyle)||this.globalConfig.successFieldStyle||{};Object.keys(r).forEach((e=>{s.elems.forEach((i=>{var t;i.style[e]="",i.classList.remove(...c((null==(t=s.config)?void 0:t.successFieldCssClass)||this.globalConfig.successFieldCssClass))}))}))}this.tooltips=[]}isTooltip(){return!!this.globalConfig.tooltip}lockForm(){const e=this.form.querySelectorAll("input, textarea, button, select");for(let i=0,t=e.length;i{this.renderTooltip(e,i,t)}}}createErrorLabelElem(e,i,t){const s=document.createElement("div");s.innerHTML=i;const l=this.isTooltip()?null==t?void 0:t.errorLabelStyle:(null==t?void 0:t.errorLabelStyle)||this.globalConfig.errorLabelStyle;return Object.assign(s.style,l),s.classList.add(...c((null==t?void 0:t.errorLabelCssClass)||this.globalConfig.errorLabelCssClass),"just-validate-error-label"),this.isTooltip()&&(s.dataset.tooltip="true"),this.globalConfig.testingMode&&(s.dataset.testId=`error-label-${e}`),this.errorLabels[e]=s,s}createSuccessLabelElem(e,i,t){if(void 0===i)return null;const s=document.createElement("div");s.innerHTML=i;const l=(null==t?void 0:t.successLabelStyle)||this.globalConfig.successLabelStyle;return Object.assign(s.style,l),s.classList.add(...c((null==t?void 0:t.successLabelCssClass)||this.globalConfig.successLabelCssClass),"just-validate-success-label"),this.globalConfig.testingMode&&(s.dataset.testId=`success-label-${e}`),this.successLabels[e]=s,s}renderErrorsContainer(e,i){const t=i||this.globalConfig.errorsContainer;if("string"==typeof t){const i=this.form.querySelector(t);if(i)return i.appendChild(e),!0;console.error(`Error container with ${t} selector not found. Errors will be rendered as usual`)}return t instanceof Element?(t.appendChild(e),!0):(void 0!==t&&console.error("Error container not found. It should be a string or existing Element. Errors will be rendered as usual"),!1)}renderGroupLabel(e,i,t,s){if(!s){if(this.renderErrorsContainer(i,t))return}e.appendChild(i)}renderFieldLabel(e,i,t,s){var l,r,o,a,n,d,c;if(!s){if(this.renderErrorsContainer(i,t))return}if("checkbox"===e.type||"radio"===e.type){const t=document.querySelector(`label[for="${e.getAttribute("id")}"]`);"label"===(null==(r=null==(l=e.parentElement)?void 0:l.tagName)?void 0:r.toLowerCase())?null==(a=null==(o=e.parentElement)?void 0:o.parentElement)||a.appendChild(i):t?null==(n=t.parentElement)||n.appendChild(i):null==(d=e.parentElement)||d.appendChild(i)}else null==(c=e.parentElement)||c.appendChild(i)}showLabels(e,i){Object.keys(e).forEach(((t,s)=>{const l=e[t],r=this.getKeyByFieldSelector(t);if(!r||!this.fields[r])return void console.error("Field not found. Check the field selector.");const o=this.fields[r];o.isValid=!i,this.clearFieldStyle(r),this.clearFieldLabel(r),this.renderFieldError(r,!1,l),0===s&&this.globalConfig.focusInvalidField&&setTimeout((()=>o.elem.focus()),0)}))}showErrors(e){if("object"!=typeof e)throw Error("[showErrors]: Errors should be an object with key: value format");this.showLabels(e,!0)}showSuccessLabels(e){if("object"!=typeof e)throw Error("[showSuccessLabels]: Labels should be an object with key: value format");this.showLabels(e,!1)}renderFieldError(e,i=!1,t){var s,l,r,o,a,n;const d=this.fields[e];if(!1===d.isValid&&(this.isValid=!1),void 0===d.isValid||!i&&!this.isSubmitted&&!d.touched&&void 0===t)return;if(d.isValid){if(!d.asyncCheckPending){const i=this.createSuccessLabelElem(e,void 0!==t?t:d.successMessage,d.config);i&&this.renderFieldLabel(d.elem,i,null==(s=d.config)?void 0:s.errorsContainer,!0),d.elem.classList.add(...c((null==(l=d.config)?void 0:l.successFieldCssClass)||this.globalConfig.successFieldCssClass))}return}d.elem.classList.add(...c((null==(r=d.config)?void 0:r.errorFieldCssClass)||this.globalConfig.errorFieldCssClass));const u=this.createErrorLabelElem(e,void 0!==t?t:d.errorMessage,d.config);this.renderFieldLabel(d.elem,u,null==(o=d.config)?void 0:o.errorsContainer),this.isTooltip()&&this.tooltips.push(this.renderTooltip(d.elem,u,null==(n=null==(a=d.config)?void 0:a.tooltip)?void 0:n.position))}renderGroupError(e,i=!0){var t,s,l,r;const o=this.groupFields[e];if(!1===o.isValid&&(this.isValid=!1),void 0===o.isValid||!i&&!this.isSubmitted&&!o.touched)return;if(o.isValid){o.elems.forEach((e=>{var i,t;Object.assign(e.style,(null==(i=o.config)?void 0:i.successFieldStyle)||this.globalConfig.successFieldStyle),e.classList.add(...c((null==(t=o.config)?void 0:t.successFieldCssClass)||this.globalConfig.successFieldCssClass))}));const i=this.createSuccessLabelElem(e,o.successMessage,o.config);return void(i&&this.renderGroupLabel(o.groupElem,i,null==(t=o.config)?void 0:t.errorsContainer,!0))}this.isValid=!1,o.elems.forEach((e=>{var i,t;Object.assign(e.style,(null==(i=o.config)?void 0:i.errorFieldStyle)||this.globalConfig.errorFieldStyle),e.classList.add(...c((null==(t=o.config)?void 0:t.errorFieldCssClass)||this.globalConfig.errorFieldCssClass))}));const a=this.createErrorLabelElem(e,o.errorMessage,o.config);this.renderGroupLabel(o.groupElem,a,null==(s=o.config)?void 0:s.errorsContainer),this.isTooltip()&&this.tooltips.push(this.renderTooltip(o.groupElem,a,null==(r=null==(l=o.config)?void 0:l.tooltip)?void 0:r.position))}renderErrors(e=!1){if(this.isSubmitted||e||this.globalConfig.validateBeforeSubmitting){this.clearErrors(),this.isValid=!0;for(const e in this.groupFields)this.renderGroupError(e);for(const e in this.fields)this.renderFieldError(e)}}destroy(){this.eventListeners.forEach((e=>{this.removeListener(e.type,e.elem,e.func)})),Object.keys(this.customStyleTags).forEach((e=>{this.customStyleTags[e].remove()})),this.clearErrors(),this.globalConfig.lockForm&&this.unlockForm()}refresh(){this.destroy(),this.form?(this.initialize(this.form,this.globalConfig),Object.keys(this.fields).forEach((e=>{const i=this.getFieldSelectorByKey(e);i&&this.addField(i,[...this.fields[e].rules],this.fields[e].config)}))):console.error("Cannot initialize the library! Form is not defined")}setCurrentLocale(e){"string"==typeof e||void 0===e?(this.currentLocale=e,this.isSubmitted&&this.validate()):console.error("Current locale should be a string")}onSuccess(e){return this.onSuccessCallback=e,this}onFail(e){return this.onFailCallback=e,this}onValidate(e){return this.onValidateCallback=e,this}}})); (function($) { // Play initial animations on page load. $(window).on('load', function() { window.setTimeout(function() { $('body').removeClass('is-preload'); }, 100); }); })(jQuery); $(document).ready(function(){ function addValidation() { validator.addField('#ask_input', [ { rule: 'minLength', value: 6, }, ]); } let validator = new JustValidate('#ask', { validateBeforeSubmitting: true, }); addValidation(); }); function newQuestion() { if($('#go_button').val().indexOf('stop')>-1) { $('#go_button').attr('value',go_button_text); window.end_detected = true; } else if($('#ask_input').val().length>5) { error_count = 0; formData = new FormData(); $('#ask_input').val($('#ask_input').val().replace(/[\u00A0-\u9999\<\>\&]/g, function(i) { return '&#'+i.charCodeAt(0)+';';})); formData.append("q",$('#ask_input').val()); window.last_question = $('#ask_input').val(); AjaxPostCall('/',formData,'responseReturn'); $('#result').append(new_question_text+$('#ask_input').val()+'
'); $('#ask_input').val(''); $('#go_button').attr('value','Loading...'); window.final_text = ''; window.end_detected = false; window.finished_typing = false; window.last_index_length = 0; window.type_speed = 60; } } function responseReturn(result) { //console.log("At response return"); //console.log(result); if(result.indexOf('[RES[ERROR:Login')>-1) { windowShow('login_div'); document.cookie = "pending_question=" + btoa(window.last_question) + "; expires=" + new Date(Date.now() + 60 * 60 * 1000).toUTCString() + "; path=/"; document.getElementById('code_error').innerHTML = response_code_error_text; } else if(result.indexOf('[RES[ERROR:no credit')>-1) { windowShow('no_credit'); document.cookie = "pending_question=" + btoa(window.last_question) + "; expires=" + new Date(Date.now() + 60 * 60 * 1000).toUTCString() + "; path=/"; } else if(result.indexOf('[RES[prun:')>-1) { tmp = result.split('prun:'); tmp = tmp[1].split(']'); if(tmp[0].length==8) { AjaxCall('?q_status='+tmp[0],false,'responseReturn'); window.status_code = tmp[0]; } } else if(result.indexOf('[RES[')>-1) { tmp = result.split('[RES['); tmp = tmp[1].split(']]>'); result = tmp[0]; done = false; last_i = 0; for(i=1; i<15; i++) { if(i>1&&!done) { break; } if(result.indexOf(i+'. ')>-1&&i>last_i&&(last_i+1)==i) { result = result.replace(i+'. ','
'+i+'. '); done = true; last_i = i; } else if(result.indexOf(i+'.')>-1&&i>last_i) { //check next character is not a number try { if(!Number.isNaN(result.split(i+'.')[1][0])&&(last_i+1)==i) { result = result.replace(i+'.','
'+i+'.'); last_i = i; } else { i = 15; break; } } catch (err) { // index not found console.log(err); } done=true; } } in_code = false; while(result.indexOf('```')>-1) { result = result.replace('```markdown',''); result = result.replace('```text',''); if(result.indexOf('```')>-1&&!in_code) { in_code = true; result = result.replace('```','
');
            }
            if(result.indexOf('```')>-1) {
                if(in_code) {
                    in_code = false;
                    result = result.replace('```','
'); } else { result = result.replace('```',''); } } } if(result.indexOf('-1) { tmp = result.split('>'); for(i=0; i'+tmp[i].replace('---','').trim().replace("###","").replace("##","").replace("#","")+">-1) { result = result.replace(' A.','
A.'); } if(result.indexOf(' B.')>-1) { result = result.replace(' B.','
B.'); } result = result.replace("\.",".").replace("\'","'"); console.log('>> raw:'+result); if(result.indexOf('<\/think')>-1) { tmp = result.split("<\/think>"); if(tmp[1].length>0) { result = tmp[1]; } } if(result.indexOf('###')>-1) { result = result.replace("###","
"); tmp = result.split("
"); result = tmp[1].replace("\n","\n"); } if(result.indexOf('[THINKING]')>-1||result.indexOf('\[THINKING')>-1) { result = result.replace('[THINKING]',''); if(result.trim()=="") { $('#go_button').attr('value','Thinking... (click to stop)'); console.log("> LLM is thinking..."); } } result=result.replace('','[END]'); if(result.indexOf('[END')>-1) { result = result.replace('[END][END]',''); result = result.replace('[END]',''); $('#go_button').attr('value',go_button_text); window.end_detected = true; } if(result.indexOf('[END')>-1) { result = result.replace('[END]',''); } if(result.length>5) { $('#go_button').attr('value','Responding... (click to stop)'); if((result.length-window.final_text.length)>2) { result_length = countChinese(result); if(result_length==0) { result_length = result.length; } final_text_length = countChinese(window.final_text); if(final_text_length==0) { final_text_length = window.final_text.length; } window.last_text_length = result_length-final_text_length; // console.log("last text length:"+window.last_text_length); } // console.log("last text length:"+window.last_text_length); if(window.final_text=='') { window.final_text = result; $('#current_response').removeAttr('id'); $('#result').append('
'); type_next_element(0); } else { window.final_text = result; if(window.finished_typing) { window.finished_typing = false; if($('#current_response').length>window.last_index_length) { type_next_element($('#current_response').length); } else { type_next_element(window.last_index_length); } } } //check if it has scrolled out of view var div = document.getElementById("ask_input"); var divBottom = div.offsetTop + div.offsetHeight; // console.log("> divbottom:"+divBottom); var windowHeight = window.innerHeight; var scrollY = window.pageYOffset; // console.log("scrolly:"+scrollY+" windowheight:"+windowHeight); if (divBottom > windowHeight + scrollY) { window.scrollTo(0, divBottom - windowHeight); } } else { if(typeof error_count === 'undefined') { error_count = 0; } if(error_count>30){ alert(general_error_text); error_count = 0; window.end_detected = true; } error_count+=1; } if(!window.end_detected) { //call again setTimeout(function(){ AjaxCall('?q_status='+window.status_code,false,'responseReturn'); }, 500); } else { window.status_code = ''; $('#go_button').attr('value',go_button_text); } } } function countChinese(str) { let chineseCount = 0; for (let i = 0; i < str.length; i++) { if (str.charCodeAt(i) >= 19968 && str.charCodeAt(i) <= 40959) { chineseCount++; } } return chineseCount; } function type_next_element(index) { var current_element = $('#current_response'); if(window.last_index_length==0) { current_element.html("").show(); } function type_next_character(element, i) { if(i>window.last_index_length) { window.last_index_length = i; } element.html( window.final_text.substr(0, i) ); if(typeof window.type_speed === 'undefined') { window.type_speed = 30; //slower while loading } //watch difference between current output and the cache if(($('#current_response').html().length*1.2)0) { window.type_speed-=0.1; //console.log(">> current response length is < 1.2x of the current reply, increasing write speed, output len:"+$('#current_response').html().length+" cache len:"+window.final_text.length+" type speed now:"+window.type_speed); } if(($('#current_response').html().length*1.1)>window.final_text.length&&window.type_speed<100) { window.type_speed+=0.1; //console.log(">> current response length is > 1.1x of the current reply, slowing write speed, output len:"+$('#current_response').html().length+" cache len:"+window.final_text.length+" type speed now:"+window.type_speed); } if(window.end_detected) { window.type_speed = 10; //faster once full result is detected } if (window.final_text.length >= i) { //console.log("Type speed:"+window.type_speed); setTimeout(function() { type_next_character(element, i+1); }, window.type_speed); } else { if (++index < $('#current_response').length) { type_next_element(index); } else { window.finished_typing = true; if($('#current_response').html().length>window.last_index_length) { window.last_index_length = $('#current_response').html().length; } } } } if(window.last_index_length>0) { type_next_character(current_element, window.last_index_length); } else { type_next_character(current_element, 0); } } $(document).ready(function() { var $window = $(window), $body = $('body'), $header = $('#header'), $banner = $('#banner'); // Breakpoints. breakpoints({ xlarge: '(max-width: 1680px)', large: '(max-width: 1280px)', medium: '(max-width: 980px)', small: '(max-width: 736px)', xsmall: '(max-width: 480px)' }); // Header. if ($('#banner').length > 0 && $('#header').hasClass('alt')) { $(window).on('resize', function() { $window.trigger('scroll'); }); $('#banner').scrollex({ bottom: $header.outerHeight(), terminate: function() { $header.removeClass('alt'); }, enter: function() { $header.addClass('alt'); }, leave: function() { $header.removeClass('alt'); } }); } // Menu. var $menu = $('#menu'); $menu._locked = false; $menu._lock = function() { if ($menu._locked) return false; $menu._locked = true; window.setTimeout(function() { $menu._locked = false; }, 350); return true; }; $menu._show = function() { if ($menu._lock()) $body.addClass('is-menu-visible'); }; $menu._hide = function() { if ($menu._lock()) $body.removeClass('is-menu-visible'); }; $menu._toggle = function() { if ($menu._lock()) $body.toggleClass('is-menu-visible'); }; $menu .appendTo($body) .on('click', function(event) { event.stopPropagation(); // Hide. $menu._hide(); }) .find('.inner') .on('click', '.close', function(event) { event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation(); // Hide. $menu._hide(); }) .on('click', function(event) { event.stopPropagation(); }) .on('click', 'a', function(event) { var href = $(this).attr('href'); event.preventDefault(); event.stopPropagation(); // Hide. $menu._hide(); // Redirect. window.setTimeout(function() { window.location.href = href; }, 350); }); $body .on('click', 'a[href="#menu"]', function(event) { event.stopPropagation(); event.preventDefault(); // Toggle. $menu._toggle(); }) .on('keydown', function(event) { // Hide on escape. if (event.keyCode == 27) $menu._hide(); }); $(this).dequeue(); });