function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i < vars.length; i++) { var pair = vars[i].split("="); if(pair[0] == variable){return pair[1];} } return(false); } function JqueryDotEvent(store) { var $this = this; this.store = store this.createNonceStr = function() { return Date.now().toString(36) + '-' +Math.random().toString(36).substr(2); }; this.getNonce = function() { var nonce; nonce = getQueryVariable('nonce'); if (!nonce) { nonce = $this.store.getItem('_dot_nonce'); } if (!nonce) { nonce = $this.createNonceStr(); } if (nonce) { $this.store.setItem('_dot_nonce', nonce); } return nonce; }; this.getReferralCode = function() { var referral_code; referral_code = getQueryVariable('referral_code'); if (referral_code) { $this.store.setItem('_dot_referral_code', referral_code); } else { referral_code = $this.store.getItem('_dot_referral_code'); } return referral_code; }; /** add Event */ this.addEvent = function(name, params, nonce, referral_code) { var enp = params ? encodeURIComponent(JSON.stringify(params)) : ''; var script = document.createElement('script'); var referrer = encodeURIComponent(window.location.origin + window.location.pathname); nonce = nonce || $this.getNonce(); referral_code = referral_code || $this.getReferralCode(); script.setAttribute("type","text/javascript"); script.src = 'https://tkb.thekillboxgame.com/db/dot.php?name='+name+'&nonce='+nonce+'¶ms=' + enp +'&referrer=' + referrer + '&referral_code=' + referral_code; document.body.appendChild(script); } } if (!window.dotEvent_) { window.dotEvent_ = new JqueryDotEvent(window.localStorage); window.dotEvent_.addEvent('open'); }