{"version":3,"sources":["apbct-public.js"],"names":["apbct_js_keys__set_input_value","result","data","params","obj","document","getElementById","input_name","ct_input_value","value","replace","js_key","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","ctSetCookieSec","c_name","cookie","encodeURIComponent","apbct_attach_event_handler","elem","event","callback","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","Math","floor","setTimeout","getTimezoneOffset","ctFunctionFirstKey","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","JSON","stringify","ctFunctionMouseMove","push","round","clientY","clientX","clearInterval","i","forms","length","form","classList","contains","onsubmit_prev","onsubmit","elements","key","this","isNaN","visible_fields_count","filter","getComputedStyle","display","visibility","opacity","getAttribute","forEach","el","j","els","visible_fields","trim","target","Function","call","jQuery","apbct_sendAJAXRequest","notJson","timeout","_ajax_nonce","ctPublic","ajax","type","url","_ajax_url","success","parse","error","jqXHR","textStatus","errorThrown","console","log","ajaxComplete","xhr","settings","responseText","indexOf","response","apbct","blocked","alert","comment","stop_script","stop"],"mappings":"AAkKA,SAASA,+BAA+BC,EAAQC,EAAMC,EAAQC,GAC7D,GAAmD,OAA/CC,SAASC,eAAeH,EAAOI,YAAsB,CACxD,IAAIC,EAAiBH,SAASC,eAAeH,EAAOI,YAAYE,MAChEJ,SAASC,eAAeH,EAAOI,YAAYE,MAAQJ,SAASC,eAAeH,EAAOI,YAAYE,MAAMC,QAAQF,EAAgBP,EAAOU,SAIrI,GAzKC,WAEA,IAAIC,EAAU,IAAIC,KACjBC,GAAW,IAAID,MAAOE,UACtBC,GAAwB,EACxBC,EAAc,GACdC,EAAqB,EAEtB,SAASC,EAAeC,EAAQX,GAC/BJ,SAASgB,OAASD,EAAS,IAAME,mBAAmBb,GAAS,WAG9D,SAASc,EAA2BC,EAAMC,EAAOC,GACV,mBAA5BC,OAAOC,iBAAiCJ,EAAKI,iBAAiBH,EAAOC,GAC7BF,EAAKK,YAAYJ,EAAOC,GAG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C,QAAQC,IAAI,oBACZD,QAAQC,IAAI5F,GACZ2F,QAAQC,IAAIJ,GACZG,QAAQC,IAAIH,GACZE,QAAQC,IAAIF,IAEbZ,QAASA,IA5CXH,OAAOxE,UAAU0F,aAAa,SAAUtE,EAAOuE,EAAKC,GACnD,GAAID,EAAIE,eAAwD,IAAxCF,EAAIE,aAAaC,QAAQ,UAAkB,CAClE,IAAIC,EAAW3D,KAAK+C,MAAMQ,EAAIE,mBACA,IAAnBE,EAASC,QACnBD,EAAWA,EAASC,OACPC,UACZC,MAAMH,EAASI,SACa,IAAxBJ,EAASK,aACZ9E,OAAO+E","file":"apbct-public.min.js","sourcesContent":["(function() {\n\n\tvar ct_date = new Date(),\n\t\tctTimeMs = new Date().getTime(),\n\t\tctMouseEventTimerFlag = true, //Reading interval flag\n\t\tctMouseData = [],\n\t\tctMouseDataCounter = 0;\n\n\tfunction ctSetCookieSec(c_name, value) {\n\t\tdocument.cookie = c_name + \"=\" + encodeURIComponent(value) + \"; path=/\";\n\t}\n\n\tfunction apbct_attach_event_handler(elem, event, callback){\n\t\tif(typeof window.addEventListener === \"function\") elem.addEventListener(event, callback);\n\t\telse elem.attachEvent(event, callback);\n\t}\n\n\tfunction apbct_remove_event_handler(elem, event, callback){\n\t\tif(typeof window.removeEventListener === \"function\") elem.removeEventListener(event, callback);\n\t\telse elem.detachEvent(event, callback);\n\t}\n\n\tctSetCookieSec(\"ct_ps_timestamp\", Math.floor(new Date().getTime()/1000));\n\tctSetCookieSec(\"ct_fkp_timestamp\", \"0\");\n\tctSetCookieSec(\"ct_pointer_data\", \"0\");\n\tctSetCookieSec(\"ct_timezone\", \"0\");\n\n\tsetTimeout(function(){\n\t\tctSetCookieSec(\"ct_timezone\", ct_date.getTimezoneOffset()/60*(-1));\n\t},1000);\n\n\t//Writing first key press timestamp\n\tvar ctFunctionFirstKey = function output(event){\n\t\tvar KeyTimestamp = Math.floor(new Date().getTime()/1000);\n\t\tctSetCookieSec(\"ct_fkp_timestamp\", KeyTimestamp);\n\t\tctKeyStopStopListening();\n\t};\n\n\t//Reading interval\n\tvar ctMouseReadInterval = setInterval(function(){\n\t\tctMouseEventTimerFlag = true;\n\t}, 150);\n\n\t//Writting interval\n\tvar ctMouseWriteDataInterval = setInterval(function(){\n\t\tctSetCookieSec(\"ct_pointer_data\", JSON.stringify(ctMouseData));\n\t}, 1200);\n\n\t//Logging mouse position each 150 ms\n\tvar ctFunctionMouseMove = function output(event){\n\t\tif(ctMouseEventTimerFlag === true){\n\n\t\t\tctMouseData.push([\n\t\t\t\tMath.round(event.clientY),\n\t\t\t\tMath.round(event.clientX),\n\t\t\t\tMath.round(new Date().getTime() - ctTimeMs)\n\t\t\t]);\n\n\t\t\tctMouseDataCounter++;\n\t\t\tctMouseEventTimerFlag = false;\n\t\t\tif(ctMouseDataCounter >= 50){\n\t\t\t\tctMouseStopData();\n\t\t\t}\n\t\t}\n\t};\n\n\t//Stop mouse observing function\n\tfunction ctMouseStopData(){\n\t\tapbct_remove_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\t\tclearInterval(ctMouseReadInterval);\n\t\tclearInterval(ctMouseWriteDataInterval);\n\t}\n\n\t//Stop key listening function\n\tfunction ctKeyStopStopListening(){\n\t\tapbct_remove_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\t\tapbct_remove_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\t}\n\n\tapbct_attach_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\tapbct_attach_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\tapbct_attach_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\n\t// Ready function\n\tfunction apbct_ready(){\n\t\tctSetCookieSec(\"apbct_visible_fields\", 0);\n\t\tctSetCookieSec(\"apbct_visible_fields_count\", 0);\n\t\tsetTimeout(function(){\n\t\t\tfor(var i = 0; i < document.forms.length; i++){\n\t\t\t\tvar form = document.forms[i];\n\n\t\t\t\t//Exclusion for StoreLocatorPlus form\n\t\t\t\tif (form.classList.contains('slp_search_form'))\n\t\t\t\t\tcontinue;\n\t\t\t\t\n\t\t\t\tform.onsubmit_prev = form.onsubmit;\n\t\t\t\tform.onsubmit = function(event){\n\n\t\t\t\t\t// Get only fields\n\t\t\t\t\tvar elements = [];\n\t\t\t\t\tfor(var key in this.elements){\n\t\t\t\t\t\tif(!isNaN(+key))\n\t\t\t\t\t\t\telements[key] = this.elements[key];\n\t\t\t\t\t}\n\n\t\t\t\t\t// Filter fields\n\t\t\t\t\telements = elements.filter(function(elem){\n\n\t\t\t\t\t\tvar pass = true;\n\n\t\t\t\t\t\t// Filter fields\n\t\t\t\t\t\tif( getComputedStyle(elem).display === \"none\" || // hidden\n\t\t\t\t\t\t\tgetComputedStyle(elem).visibility === \"hidden\" || // hidden\n\t\t\t\t\t\t\tgetComputedStyle(elem).opacity === \"0\" || // hidden\n\t\t\t\t\t\t\telem.getAttribute(\"type\") === \"hidden\" || // type == hidden\n\t\t\t\t\t\t\telem.getAttribute(\"type\") === \"submit\" || // type == submit\n\t\t\t\t\t\t\telem.value === \"\" || // empty value\n\t\t\t\t\t\t\telem.getAttribute('name') === null\n\t\t\t\t\t\t){\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Filter elements with same names for type == radio\n\t\t\t\t\t\tif(elem.getAttribute(\"type\") === \"radio\"){\n\t\t\t\t\t\t\telements.forEach(function(el, j, els){\n\t\t\t\t\t\t\t\tif(elem.getAttribute('name') === el.getAttribute('name')){\n\t\t\t\t\t\t\t\t\tpass = false;\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t});\n\n\t\t\t\t\t// Visible fields count\n\t\t\t\t\tvar visible_fields_count = elements.length;\n\n\t\t\t\t\t// Visible fields\n\t\t\t\t\tvar visible_fields = '';\n\t\t\t\t\telements.forEach(function(elem, i, elements){\n\t\t\t\t\t\tvisible_fields += \" \" + elem.getAttribute(\"name\");\n\t\t\t\t\t});\n\t\t\t\t\tvisible_fields = visible_fields.trim();\n\n\t\t\t\t\tctSetCookieSec(\"apbct_visible_fields\", visible_fields);\n\t\t\t\t\tctSetCookieSec(\"apbct_visible_fields_count\", visible_fields_count);\n\n\t\t\t\t\t// Call previous submit action\n\t\t\t\t\tif(event.target.onsubmit_prev instanceof Function){\n\t\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\t\tevent.target.onsubmit_prev.call(event.target, event);\n\t\t\t\t\t\t}, 500);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t}, 1000);\n\t}\n\tapbct_attach_event_handler(window, \"DOMContentLoaded\", apbct_ready);\n\n}());\n\nfunction apbct_js_keys__set_input_value(result, data, params, obj){\n\tif (document.getElementById(params.input_name) !== null) {\n\t\tvar ct_input_value = document.getElementById(params.input_name).value;\n\t\tdocument.getElementById(params.input_name).value = document.getElementById(params.input_name).value.replace(ct_input_value, result.js_key);\n\t}\n}\n\nif(typeof jQuery !== 'undefined') {\n\n\t// Capturing responses and output block message for unknown AJAX forms\n\tjQuery(document).ajaxComplete(function (event, xhr, settings) {\n\t\tif (xhr.responseText && xhr.responseText.indexOf('\"apbct') !== -1) {\n\t\t\tvar response = JSON.parse(xhr.responseText);\n\t\t\tif (typeof response.apbct !== 'undefined') {\n\t\t\t\tresponse = response.apbct;\n\t\t\t\tif (response.blocked) {\n\t\t\t\t\talert(response.comment);\n\t\t\t\t\tif(+response.stop_script == 1)\n\t\t\t\t\t\twindow.stop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tfunction apbct_sendAJAXRequest(data, params, obj) {\n\n\t\t// Default params\n\t\tvar callback = params.callback || null;\n\t\tvar notJson = params.notJson || null;\n\t\tvar timeout = params.timeout || 15000;\n\t\tvar obj = obj || null;\n\n\t\tdata._ajax_nonce = ctPublic._ajax_nonce;\n\n\t\tjQuery.ajax({\n\t\t\ttype: \"POST\",\n\t\t\turl: ctPublic._ajax_url,\n\t\t\tdata: data,\n\t\t\tsuccess: function (result) {\n\t\t\t\tif (!notJson) result = JSON.parse(result);\n\t\t\t\tif (result.error) {\n\n\t\t\t\t} else {\n\t\t\t\t\tif (callback)\n\t\t\t\t\t\tcallback(result, data, params, obj);\n\t\t\t\t}\n\t\t\t},\n\t\t\terror: function (jqXHR, textStatus, errorThrown) {\n\t\t\t\tconsole.log('APBCT_AJAX_ERROR');\n\t\t\t\tconsole.log(data);\n\t\t\t\tconsole.log(jqXHR);\n\t\t\t\tconsole.log(textStatus);\n\t\t\t\tconsole.log(errorThrown);\n\t\t\t},\n\t\t\ttimeout: timeout\n\t\t});\n\t}\n}"]}