JSFiddle - React, Tailwind, and code Playground
cref (test1 old)
by web-nfo.com
HTML
<div id="output"></div>
CSS
* { font-family:courier; }
JavaScript
/*
* Custom script for cref tracking on photoservice homepage
* Note: prefix 'cwInfinity_' is used for global variables/functions
*/
// Set Operator
if(typeof cwInfinity_operator == 'undefined') {
switch(window.location.hostname) {
case "nl.kruidvat.be": {
var cwInfinity_operator = "85001287"; // When switching to infinity - change to 85701287
break;
}
case "fr.kruidvat.be": {
var cwInfinity_operator = "85001286"; // When switching to infinity - change to 85701286
break;
}
default: {
var cwInfinity_operator = "85100005";
}
}
}
// Set Keyaccount
if(typeof cwInfinity_keyaccount == 'undefined') {
switch(cwInfinity_operator) {
case "85001287":
case "85701287": {
var cwInfinity_keyaccount = "1287";
break;
}
case "85001286":
case "85701286": {
var cwInfinity_keyaccount = "1286";
break;
}
default: {
var cwInfinity_keyaccount = "5";
}
}
}
// Console log (for debugging)
function cwInfinity_cLog(msg) { // Console log (if available)
if(typeof console == 'object' && typeof console.log == 'function') {
console.log(msg);
}
}
// Fetch the cref from the url
function cwInfinity_fetchCrefFromUrl()
{
// Fetch an url parameter
var parameter = 'cref';
HTTP_GET_VARS = new Array();
strGET = document.location.search.substr(1, document.location.search.length);
if (strGET != '') {
gArr = strGET.split('&');
for(var i=0; i<gArr.length; ++i) {
v = '';
vArr = gArr[i].split('=');
if(vArr.length > 1) {
v = vArr[1];
}
HTTP_GET_VARS[unescape(vArr[0])] = unescape(v);
}
}
if (!HTTP_GET_VARS[parameter]) {
return '';
}
return HTTP_GET_VARS[parameter];
}
// Generate an unique cref hash
function cwInfinity_generateCrefHash()
{
var letters = 'abcdefghijklmnopqrstuvwxyz';
var numbers = '1234567890';
var charset = letters + letters.toUpperCase() + numbers;
// Add date-time to uid, for more 'uniqueness'
var now = new Date();
var day ...