Last active
December 21, 2015 19:28
-
-
Save yahelc/6354070 to your computer and use it in GitHub Desktop.
BSD SPUD-less Sourcing Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var get = (function() { | |
var map = {}; | |
location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, k, v) { | |
map[k] = v; | |
}); | |
return map; | |
} ()); | |
function readCookie(a){return(RegExp("(?:^|; )"+a+"=([^;]*)").exec(document.cookie)||[]).pop();} | |
function createCookie(name,value,days) { | |
var expires = days ? "; expires=" + (new Date(days*864E5 + (new Date()).getTime())).toGMTString() :""; | |
document.cookie = name+"="+value+expires+"; path=/; domain="+ location.hostname.split(".").slice(-2).join("."); | |
} | |
if(get.source && get.source !== readCookie("source")){ | |
createCookie("source", get.source, 180); | |
} | |
if(get.subsource && get.subsource !== readCookie("subsource")){ | |
createCookie("subsource", get.subsource, 180); | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment