-
Notifications
You must be signed in to change notification settings - Fork 1
/
cookie-min.js
1 lines (1 loc) · 1.06 KB
/
cookie-min.js
1
(function(e,d,a){var b=function(g){return encodeURIComponent(g).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A");},f=function(g){return decodeURIComponent(g).replace(/%21/g,"!").replace(/%27/g,"'").replace(/%28/g,"(").replace(/%29/g,")").replace(/%2A/g,"*");},c=function(g,h,i){this.name=g;this.value=h||this.get();this.params=i||{};};c.get=function(j){var m=d.cookie.match(/\w+=[^;]+/g),g=m!==null?m.length:0,h=[],l,k;for(k=0;k<g;k++){l=m[k].match(/(\w+)=(.+)/);if(j===l[1]){h.push(f(l[2]));}}return h;};c.set=function(g,h,i){i=i||{};d.cookie=g+"="+b(h)+(i.expires!==a?"; expires="+i.expires:"")+(i.max_age!==a?"; max-age="+i.max_age:"")+(i.domain!==a?"; domain="+i.domain:"")+(i.path!==a?"; path="+i.path:"")+(i.secure?"; secure":"");return h;};c.clear=function(g,h){h=h||{};h.max_age=0;c.set(g,a,h);};c.prototype.get=function(){return c.get(this.name);};c.prototype.set=function(g,h){return c.set(this.name,g||this.value[0],h||this.params);};c.prototype.clear=function(g){return c.clear(this.name,g);};e.Cookie=c;}(window,document));