From 8b6a133358d320daa1528d019afaea27c0a461ea Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Mon, 30 Jan 2012 16:41:10 -0800 Subject: [PATCH] 0.0.3 - removed amd wrapper --- build.json | 4 +- dist/monster.js | 99 ++++++++++++++++++++------------------------- dist/monster.min.js | 4 +- lib/amd-bottom.js | 2 - lib/amd-top.js | 5 --- lib/copyright.js | 2 +- lib/monster.js | 88 ++++++++++++++++++++-------------------- package.json | 2 +- test/index.html | 2 +- 9 files changed, 93 insertions(+), 115 deletions(-) delete mode 100644 lib/amd-bottom.js delete mode 100644 lib/amd-top.js diff --git a/build.json b/build.json index 814c7e9..96eea06 100644 --- a/build.json +++ b/build.json @@ -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": { diff --git a/dist/monster.js b/dist/monster.js index 00e3454..d2a1737 100644 --- a/dist/monster.js +++ b/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); + } +}; diff --git a/dist/monster.min.js b/dist/monster.min.js index 22c1187..125f10e 100644 --- a/dist/monster.min.js +++ b/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 (http://jga.me)", "repository": { diff --git a/test/index.html b/test/index.html index 5b4b8e2..4d3e469 100644 --- a/test/index.html +++ b/test/index.html @@ -7,7 +7,7 @@ - +