mirror of
https://github.com/Investigamer/cardconjurer.git
synced 2025-07-26 21:04:58 -05:00
24 lines
899 B
JavaScript
24 lines
899 B
JavaScript
function setCookie(cookieName, cookieValue, cookieTime = (5 * 365 * 24 * 60 * 60 * 1000)) { //years*days*hours*minutes*seconds*milliseconds
|
|
var tempDate = new Date()
|
|
tempDate.setTime(tempDate.getTime() + cookieTime)
|
|
document.cookie = cookieName + '=' + cookieValue + ';expires=' + tempDate.toUTCString() + ';path=/'
|
|
}
|
|
function getCookie(cookieName) {
|
|
var name = cookieName + '='
|
|
var cookieArray = document.cookie.split(';')
|
|
for(var i = 0; i < cookieArray.length; i++) {
|
|
var tempCookie = cookieArray[i]
|
|
while (tempCookie.charAt(0) == ' ') {
|
|
tempCookie = tempCookie.substring(1)
|
|
}
|
|
if (tempCookie.indexOf(name) == 0) {
|
|
return tempCookie.substring(name.length, tempCookie.length)
|
|
}
|
|
}
|
|
return ''
|
|
}
|
|
function checkCookies() {
|
|
if (getCookie('colorPalette') != undefined) {
|
|
loadScript('data/scripts/' + getCookie('colorPalette') + '.js')
|
|
}
|
|
} |