forked from firstandthird/cookie-monster
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
93 additions
and
115 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,54 @@ | ||
/*! | ||
* Cookie Monster - A javascript cookie library | ||
* v0.0.2 | ||
* v0.0.3 | ||
* https://github.com/jgallen23/cookie-monster | ||
* copyright JGA 2011 | ||
* MIT License | ||
*/ | ||
|
||
!function (name, definition) { | ||
if (typeof module != 'undefined' && module.exports) module.exports = definition(); | ||
else if (typeof define == 'function' && typeof define.amd == 'object') define(definition); | ||
else this[name] = definition(); | ||
}('monster', function() { | ||
|
||
var monster = function() { | ||
return { | ||
set: function(name, value, days, path) { | ||
var date = new Date(), | ||
expires = '', | ||
type = typeof(value), | ||
valueToUse = ''; | ||
path = path || "/"; | ||
if (days) { | ||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | ||
expires = "; expires=" + date.toGMTString(); | ||
} | ||
if(type !== "string" && type !== "undefined"){ | ||
if(!("JSON" in window)) throw "Bummer, your browser doesn't support JSON parsing."; | ||
valueToUse = JSON.stringify({v:value}); | ||
} | ||
else | ||
valueToUse = escape(value); | ||
|
||
document.cookie = name + "=" + valueToUse + expires + "; path=" + path; | ||
}, | ||
get: function(name) { | ||
var nameEQ = name + "=", | ||
ca = document.cookie.split(';'), | ||
value = '', | ||
firstChar = '', | ||
parsed={}; | ||
for (var i = 0; i < ca.length; i++) { | ||
var c = ca[i]; | ||
while (c.charAt(0) == ' ') c = c.substring(1, c.length); | ||
if (c.indexOf(nameEQ) === 0) { | ||
value = c.substring(nameEQ.length, c.length); | ||
firstChar = value.substring(0, 1); | ||
if(firstChar=="{"){ | ||
parsed = JSON.parse(value); | ||
if("v" in parsed) return parsed.v; | ||
} | ||
if(value=="undefined") return undefined; | ||
return unescape(value); | ||
var monster = { | ||
set: function(name, value, days, path) { | ||
var date = new Date(), | ||
expires = '', | ||
type = typeof(value), | ||
valueToUse = ''; | ||
path = path || "/"; | ||
if (days) { | ||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | ||
expires = "; expires=" + date.toGMTString(); | ||
} | ||
if(type === "object" && type !== "undefined"){ | ||
if(!("JSON" in window)) throw "Bummer, your browser doesn't support JSON parsing."; | ||
valueToUse = JSON.stringify({v:value}); | ||
} | ||
else | ||
valueToUse = escape(value); | ||
|
||
document.cookie = name + "=" + valueToUse + expires + "; path=" + path; | ||
}, | ||
get: function(name) { | ||
var nameEQ = name + "=", | ||
ca = document.cookie.split(';'), | ||
value = '', | ||
firstChar = '', | ||
parsed={}; | ||
for (var i = 0; i < ca.length; i++) { | ||
var c = ca[i]; | ||
while (c.charAt(0) == ' ') c = c.substring(1, c.length); | ||
if (c.indexOf(nameEQ) === 0) { | ||
value = c.substring(nameEQ.length, c.length); | ||
firstChar = value.substring(0, 1); | ||
if(firstChar=="{"){ | ||
parsed = JSON.parse(value); | ||
if("v" in parsed) return parsed.v; | ||
} | ||
if(value=="undefined") return undefined; | ||
return unescape(value); | ||
} | ||
return null; | ||
}, | ||
remove: function(name) { | ||
this.set(name, "", -1); | ||
} | ||
}; | ||
}(); | ||
|
||
return monster; | ||
}); | ||
return null; | ||
}, | ||
remove: function(name) { | ||
this.set(name, "", -1); | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/*! | ||
* Cookie Monster - A javascript cookie library | ||
* v0.0.2 | ||
* v0.0.3 | ||
* https://github.com/jgallen23/cookie-monster | ||
* copyright JGA 2011 | ||
* MIT License | ||
*/ | ||
!function(a,b){typeof module!="undefined"&&module.exports?module.exports=b():typeof define=="function"&&typeof define.amd=="object"?define(b):this[a]=b()}("monster",function(){var a=function(){return{set:function(a,b,c,d){var e=new Date,f="",g=typeof b,h="";d=d||"/",c&&(e.setTime(e.getTime()+c*24*60*60*1e3),f="; expires="+e.toGMTString());if(g!=="string"&&g!=="undefined")if("JSON"in window)h=JSON.stringify({v:b});else throw"Bummer, your browser doesn't support JSON parsing.";else h=escape(b);document.cookie=a+"="+h+f+"; path="+d},get:function(a){var b=a+"=",c=document.cookie.split(";"),d="",e="",f={};for(var g=0;g<c.length;g++){var h=c[g];while(h.charAt(0)==" ")h=h.substring(1,h.length);if(h.indexOf(b)===0){d=h.substring(b.length,h.length),e=d.substring(0,1);if(e=="{"){f=JSON.parse(d);if("v"in f)return f.v}return d=="undefined"?undefined:unescape(d)}}return null},remove:function(a){this.set(a,"",-1)}}}();return a}) | ||
var monster={set:function(a,b,c,d){var e=new Date,f="",g=typeof b,h="";d=d||"/",c&&(e.setTime(e.getTime()+c*24*60*60*1e3),f="; expires="+e.toGMTString());if(g==="object"&&g!=="undefined")if("JSON"in window)h=JSON.stringify({v:b});else throw"Bummer, your browser doesn't support JSON parsing.";else h=escape(b);document.cookie=a+"="+h+f+"; path="+d},get:function(a){var b=a+"=",c=document.cookie.split(";"),d="",e="",f={};for(var g=0;g<c.length;g++){var h=c[g];while(h.charAt(0)==" ")h=h.substring(1,h.length);if(h.indexOf(b)===0){d=h.substring(b.length,h.length),e=d.substring(0,1);if(e=="{"){f=JSON.parse(d);if("v"in f)return f.v}return d=="undefined"?undefined:unescape(d)}}return null},remove:function(a){this.set(a,"",-1)}} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,46 @@ | ||
var monster = function() { | ||
return { | ||
set: function(name, value, days, path) { | ||
var date = new Date(), | ||
expires = '', | ||
type = typeof(value), | ||
valueToUse = ''; | ||
path = path || "/"; | ||
if (days) { | ||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | ||
expires = "; expires=" + date.toGMTString(); | ||
} | ||
if(type === "object" && type !== "undefined"){ | ||
if(!("JSON" in window)) throw "Bummer, your browser doesn't support JSON parsing."; | ||
valueToUse = JSON.stringify({v:value}); | ||
} | ||
else | ||
valueToUse = escape(value); | ||
|
||
document.cookie = name + "=" + valueToUse + expires + "; path=" + path; | ||
}, | ||
get: function(name) { | ||
var nameEQ = name + "=", | ||
ca = document.cookie.split(';'), | ||
value = '', | ||
firstChar = '', | ||
parsed={}; | ||
for (var i = 0; i < ca.length; i++) { | ||
var c = ca[i]; | ||
while (c.charAt(0) == ' ') c = c.substring(1, c.length); | ||
if (c.indexOf(nameEQ) === 0) { | ||
value = c.substring(nameEQ.length, c.length); | ||
firstChar = value.substring(0, 1); | ||
if(firstChar=="{"){ | ||
parsed = JSON.parse(value); | ||
if("v" in parsed) return parsed.v; | ||
} | ||
if(value=="undefined") return undefined; | ||
return unescape(value); | ||
var monster = { | ||
set: function(name, value, days, path) { | ||
var date = new Date(), | ||
expires = '', | ||
type = typeof(value), | ||
valueToUse = ''; | ||
path = path || "/"; | ||
if (days) { | ||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | ||
expires = "; expires=" + date.toGMTString(); | ||
} | ||
if(type === "object" && type !== "undefined"){ | ||
if(!("JSON" in window)) throw "Bummer, your browser doesn't support JSON parsing."; | ||
valueToUse = JSON.stringify({v:value}); | ||
} | ||
else | ||
valueToUse = escape(value); | ||
|
||
document.cookie = name + "=" + valueToUse + expires + "; path=" + path; | ||
}, | ||
get: function(name) { | ||
var nameEQ = name + "=", | ||
ca = document.cookie.split(';'), | ||
value = '', | ||
firstChar = '', | ||
parsed={}; | ||
for (var i = 0; i < ca.length; i++) { | ||
var c = ca[i]; | ||
while (c.charAt(0) == ' ') c = c.substring(1, c.length); | ||
if (c.indexOf(nameEQ) === 0) { | ||
value = c.substring(nameEQ.length, c.length); | ||
firstChar = value.substring(0, 1); | ||
if(firstChar=="{"){ | ||
parsed = JSON.parse(value); | ||
if("v" in parsed) return parsed.v; | ||
} | ||
if(value=="undefined") return undefined; | ||
return unescape(value); | ||
} | ||
return null; | ||
}, | ||
remove: function(name) { | ||
this.set(name, "", -1); | ||
} | ||
}; | ||
}(); | ||
return null; | ||
}, | ||
remove: function(name) { | ||
this.set(name, "", -1); | ||
} | ||
}; |
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
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