EnPulse2
by Oliver Kelso
JavaScript
var EnPulse = {
params: {},
// ======= UTILS ========
pEncode: function(string){
if(typeof encodeURIComponent == "function"){
return encodeURIComponent(string);
}else{
return escape(string);
}
},
// ======== PAGE DATA ========
getTitle: function (){
this.params.ti = document.title;
},
getScreenRes: function(){
this.params.sr = screen.width + "x" + screen.height;
},
// ======== CONSTRUCT =======
createQuery: function(obj){
var string = "";
for(var key in obj){
if(obj.hasOwnProperty(key)){
string += key + "=" + obj[key] + "&"; // add params to string
}
}
string = string.replace(/&+$/, ""); // remove trailing ampersand
return string; // return string
},
track: function(){
this.getScreenRes();
this.getTitle();
return this.createQuery(this.params);
}
};
EnPulse.params.test = "test1;test2;test3;test4";
console.log(EnPulse.track());