var jxpcookiephp = '5bed1761-8fa3-2668-2516-15/11/18 7:51:13:8234'; var myip = ' 54.91.203.233'; var jxpdata = {fpin: 0} var formnamesynonyms = [ "firstname", ["fornavn", "name", "navn", "fullname"], "lastname", ["lastname", "efternavn"], "email", ["email", "e-mail"], "phone", ["telefon", "mobil", "tlf", "tlf.", "mobile"], "streetname", ["address"], "discard", ["permission"] ] function rewritegender(gender){ gender = gender.toLowerCase(); var malegenders = ["mand", "m", "guy", "man"]; var femalegenders = ["kvinde", "f", "k", "girl", "woman"]; if ( $.inArray(gender, malegenders) > -1 ){ return "male"; } if ( $.inArray(gender, femalegenders) > -1 ){ return "female"; } return gender } function rewritecustomfields(customfields, jxpdata){ $.each(customfields, function(index, value) { jxpdata[index] = jxpdata[value] delete jxpdata[value] }); } function jxpeatformdata(formid){ var jxpform = {}; if ( typeof formid == "number" ){ jxpform = document.forms[formid] } else { jxpform = document.getElementById(formid); } for (jxpi = 0; jxpi < jxpform.length;jxpi++) { var formname = jxpform.elements[jxpi].name; //checks for formname synonyms for (jxpy=1; jxpy -1){ formname = formnamesynonyms[jxpy-1]; } } //If radio button. take only checked radio buttons. if (jxpform.elements[jxpi].type =='radio'){ if ( jxpform.elements[jxpi].checked ){ jxpdata[formname] = jxpform.elements[jxpi].value; } } else { jxpdata[formname] = jxpform.elements[jxpi].value; } } } function getParameterByName(name, url) { if (!url) url = (window.location.href).toLowerCase(); name = name.replace(/[\[\]]/g, "\\$&").toLowerCase(); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function getfpins(){ var fpin = "" var fpintargets = ["reqid", "transaction_id", "transactions_id", "r", "fp", "euroadsid", "regid", "trans", "cible", "uuid"]; for (i=0; i< fpintargets.length; i++){ if (getParameterByName(fpintargets[i]) != null){ fpin = getParameterByName(fpintargets[i]) } } document.cookie = "fpin="+fpin; } function jxpinitialize(){ if (getCookie("fpin") == ""){ getfpins() } if (getCookie("fpin") != ""){ jxpdata["fpin"] = getCookie("fpin") } //jxpcookie() if(window.Adform){ jxpdata["marketing_cookie"] = window.Adform._uid; console.log("adform activated") } //attempt to get did from url, then from cookie jxpdata["did"] = getParameterByName('did') if (jxpdata["did"] != null) { document.cookie = "jxpdid=" + getParameterByName('did') } if ( jxpdata["did"] == null ){ jxpdata["did"] = getCookie("jxpdid") if (jxpdata["did"] == ""){ jxpdata["did"] = 0 } if (jxpdata["did"] == "null"){ jxpdata["did"] = 0 } } console.log("did = " + jxpdata["did"]) jxpdata["ipv4"] = myip jxpdata["jxp_cookie"] = jxpcookiephp console.log(jxpdata["fpin"]) //console.log(jxpdata["jxp_cookie"]) return true; } function jxpsubmitter(jxpdomain, formid, cid, did, sumbitafterapicall, customfields, event){ //fires functions when form is submitted var formtofire = "" if ( !isNaN(formid) ) { formtofire = $('form:eq('+formid+')') } else { formtofire = "#"+formid } console.log(formtofire) if (event !== undefined){ if (event["event"] == "click"){ $(event["target"]).click(function(event) { console.log("click event test") jxpsubmitter2(jxpdomain, formid, cid, did, sumbitafterapicall, customfields); return true; }); } } else { $(formtofire).on("submit", function(e) { console.log(formtofire) /*e.preventDefault();*/ jxpsubmitter2(jxpdomain, formid, cid, did, sumbitafterapicall, customfields) /* if (sumbitafterapicall==true && jxpsubmitter2(jxpdomain, formid, cid, did, sumbitafterapicall, customfields) != "" ){ document.location = $(formtofire)[0]["action"] }*/ }); } } function jxpsubmitter2(jxpdomain, formid, cid, did, sumbitafterapicall, customfields, event){ function jxpajaxcall(e2) { $.ajax({ method: "GET", url: "https://jxp.dk/autosetup/backupdata2.php", data: jxpdata, success: function(jxpresponsedata) { console.log(jxpresponsedata); } }); $.ajax({ method: "GET", // dataType: "jsonp", // crossDomain: true, url: "https://jxp.dk/autosetup/workaroundapi.php?url=https://" + jxpdomain+".journeyxp.com/io/http", data: jxpdata, success: function(jxpresponsedata) { console.log(jxpresponsedata); } }); } //set initial variables jxpdata["cid"] = cid //Set default did. If did var == 0 then cancels script. if ( jxpdata["did"] == 0 && did == 0){ return false } else if ( jxpdata["did"] == 0 ) { jxpdata["did"] = did; } //fires functions var jxpform2 = this; jxpeatformdata(formid); if (typeof customfields !== 'undefined' ) { rewritecustomfields(customfields, jxpdata) } if (typeof jxpdata["gender"] !== 'undefined' ){ jxpdata["gender"] = rewritegender(jxpdata["gender"]) } //Delete the fpin cookie. This prevents the fpin from being reused on other webpages. document.cookie = 'fpin=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'; jxpajaxcall(jxpform2); return true; /* if (sumbitafterapicall != false){ setTimeout(function(){ jxpform2.submit() }, 2000);; } */ } function sharejxpcookie(){ return jxpcookiephp; }