Skip to content

Commit

Permalink
0.0.3 - removed amd wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jgallen23 committed Jan 31, 2012
1 parent 25134dd commit 8b6a133
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 115 deletions.
4 changes: 1 addition & 3 deletions build.json
Expand Up @@ -3,9 +3,7 @@
"DIST_DIR": "./dist",
"monster": [
"./lib/copyright.js",
"./lib/amd-top.js",
"./lib/monster.js",
"./lib/amd-bottom.js"
"./lib/monster.js"
]
},
"JSHINT_OPTS": {
Expand Down
99 changes: 44 additions & 55 deletions dist/monster.js
@@ -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);
}
};
4 changes: 2 additions & 2 deletions dist/monster.min.js
@@ -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)}}
2 changes: 0 additions & 2 deletions lib/amd-bottom.js

This file was deleted.

5 changes: 0 additions & 5 deletions lib/amd-top.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/copyright.js
@@ -1,6 +1,6 @@
/*!
* Cookie Monster - A javascript cookie library
* v0.0.2
* v0.0.3
* https://github.com/jgallen23/cookie-monster
* copyright JGA 2011
* MIT License
Expand Down
88 changes: 43 additions & 45 deletions lib/monster.js
@@ -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);
}
};
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "cookie-monster",
"description": "a simple cookie library",
"version": "0.0.2",
"version": "0.0.3",
"homepage": "https://github.com/jgallen23/cookie-monster",
"author": "Greg Allen <@jgaui> (http://jga.me)",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion test/index.html
Expand Up @@ -7,7 +7,7 @@
<script src="../node_modules/chai/chai.js"></script>
<script>mocha.setup('bdd')</script>
<script type="text/javascript" src="live.js"></script>
<script type="text/javascript" src="../lib/monster.js"></script>
<script type="text/javascript" src="../dist/monster.js"></script>
<script type="text/javascript" src="monster.test.js"></script>
<style>
#fixture { display: none; }
Expand Down

0 comments on commit 8b6a133

Please sign in to comment.