Instantly share code, notes, and snippets.
Created
April 11, 2012 17:53
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
-
Save JDMcKinstry/2360907 to your computer and use it in GitHub Desktop.
Adds the simple ability to create and delete cookies using jQuery
This file contains hidden or 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
| (function($) { // TODO: Addin better error handling on try catch states and add encrypt security option | |
| if (!$.jqCookie) { | |
| $.extend({ | |
| jqCookie: function(getORset) { | |
| var args = Array.prototype.slice.call(arguments).splice(1); | |
| switch(typeof getORset) { | |
| case "string": | |
| switch(getORset) { | |
| case 'get': | |
| if (args.length === 0) { | |
| return $.jqCookie.get('all'); | |
| } | |
| else if (args.length === 1) { | |
| switch(typeof args[0]) { | |
| case "string": | |
| return $.jqCookie.get(args[0]) | |
| break; | |
| case "object": | |
| if (args[0]['name']) { | |
| return $.jqCookie.get(args[0]['name']) | |
| } | |
| else if (args[0]['value']) { | |
| return false; // TODO: | |
| }; | |
| break; | |
| default: | |
| return false; // TODO: | |
| } | |
| } | |
| else if (args.length > 1) { | |
| return false; // TODO: | |
| } | |
| else { | |
| // TODO: ERROR! | |
| return false; // TODO: | |
| }; | |
| break; | |
| case 'remove': | |
| if (args.length === 1) { | |
| if (typeof args[0] === "string") { | |
| return $.jqCookie.remove(args[0]); | |
| } | |
| else if (typeof args[0] === "object") { | |
| if (args[0]['name']) { | |
| return $.jqCookie.remove(args[0]['name']) | |
| } | |
| else if (args[0]['value']) { | |
| }; | |
| }; | |
| }; | |
| break; | |
| case 'set': | |
| if (args.length <= 0) { | |
| // TODO: ERROR! | |
| return false; // TODO: | |
| } | |
| else if (args.length === 1) { | |
| switch(typeof args[0]) { | |
| case "string": | |
| return $.jqCookie.remove(args[0]); | |
| break; | |
| case "object": | |
| if (args[0]['name'] && args[0]['value'] && args[0]['days']) { | |
| return $.jqCookie.set(args[0]['name'], args[0]['value'], args[0]['days']); | |
| } | |
| else if (args[0]['name'] && args[0]['value']) { | |
| return $.jqCookie.set(args[0]['name'], args[0]['value']); | |
| }; | |
| break; | |
| default: | |
| return false; // TODO: | |
| } | |
| } | |
| else if (args.length === 2) { | |
| if (typeof args[0] === "string" && typeof args[1] === "string") { | |
| return $.jqCookie.set(args[0], args[1]); | |
| }; | |
| } | |
| else if (args.length === 3) { | |
| if (typeof args[0] === "string" && typeof args[1] === "string" && typeof args[2] === "string") { | |
| return $.jqCookie.set(args[0], args[1], args[2]); | |
| } | |
| else if (typeof args[0] === "string" && typeof args[1] === "string" && typeof args[2] === "number") { | |
| return $.jqCookie.set(args[0], args[1], parseFloat(args[2])); | |
| }; | |
| } | |
| else if (args.length > 3) { | |
| return false; // TODO: | |
| }; | |
| break; | |
| default: | |
| if (args.length === 0) { | |
| // only a value has been provided | |
| // TODO: write func to add value using namespace+count as key and make retievable func via the value | |
| if (typeof getORset == "string") { | |
| return $.jqCookie.get(getORset); | |
| } | |
| else if (typeof getORset == "object") { | |
| }; | |
| } | |
| else if (args.length === 1) { | |
| // a key and a value have been given, that's enough for a cookie creation, if that value is a string | |
| if (typeof args[0] === "string") return $.jqCookie.set(getORset, args[0]); | |
| var arg0 = args[0]; | |
| if (!$.isPlainObject(arg0) && arg0[0].tagName) { | |
| return $.jqCookie(getORset, '<CHTML>'+arg0[0].outerHTML); | |
| } | |
| else { | |
| return $.jqCookie(getORset, $.jqCookie.serialize(arg0)); | |
| }; | |
| } | |
| else if (args.length > 1) { | |
| // mayhaps the days are set!? | |
| if (typeof args[0] === "string" && typeof args[1] === "number") { | |
| return $.jqCookie.set(getORset, args[0], args[1]); | |
| } | |
| else if (typeof args[0] === "string" && typeof args[1] === "string") { | |
| return $.jqCookie.set(getORset, args[0], parseFloat(args[1])); | |
| } | |
| else if (typeof args[0] === "object" && typeof args[1] === "string") { | |
| }; | |
| } | |
| else { | |
| // TODO: ERROR! | |
| }; | |
| }; | |
| break; | |
| case "object": | |
| if (getORset['type']) { | |
| var typ = getORset["type"]; | |
| delete getORset["type"]; | |
| return $.jqCookie(typ, getORset); | |
| }; | |
| break; | |
| default: | |
| return false; | |
| }; | |
| return false; | |
| } | |
| }); | |
| $.jqCookie.get = function(c_name) { | |
| try { | |
| if (c_name == 'all') { | |
| var args = Array.prototype.slice.call(arguments).splice(1); | |
| var i,x,y,ARRcookies=document.cookie.split(";"),z=new Array(); | |
| for (i=0;i<ARRcookies.length;i++) { | |
| x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); | |
| y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); | |
| x=x.replace(/^\s+|\s+$/g,""); | |
| if (typeof args[0] === "boolean") { | |
| if (args[0] == true && args.length == 2) { | |
| if (typeof args[1] === "string") { | |
| if (x.toLowerCase().indexOf(args[1]) >= 0) { | |
| y = unescape(y).split("<br />"); | |
| z[i] = { | |
| name: unescape(x), | |
| value: y[0].charAt(1)==":" ? $.jqCookie.serialize(y[0], false) : y[0], | |
| exp: { | |
| date: y[1], | |
| count: y[2] | |
| } | |
| }; | |
| }; | |
| }; | |
| }; | |
| } | |
| else { | |
| y = unescape(y).split("<br />"); | |
| z[i] = { | |
| name: unescape(x), | |
| value: y[0].charAt(1)==":" ? $.jqCookie.serialize(y[0], false) : y[0], | |
| exp: { | |
| date: y[1], | |
| count: y[2] | |
| } | |
| }; | |
| }; | |
| }; | |
| return z.length > 0 ? z : false; | |
| }; | |
| var i,x,y,ARRcookies=document.cookie.split(";"), | |
| z = { name: undefined, value: undefined, exp: { count: undefined, date: undefined } }; | |
| for (i=0;i<ARRcookies.length;i++) { | |
| x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); | |
| y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); | |
| x=x.replace(/^\s+|\s+$/g,""); | |
| if (x==c_name) { | |
| z.name = unescape(x); | |
| y = unescape(y).split("<br />"); | |
| z.value = y[0].charAt(1)==":" ? $.jqCookie.serialize(y[0], false) : y[0], | |
| z.exp.date = y[1]; | |
| z.exp.count = y[2]; | |
| }; | |
| if (typeof z.value === "string") { | |
| if (z.value.indexOf("<CHTML>") >= 0) z.value = $(z.value.replace("<CHTML>", "")); | |
| }; | |
| }; | |
| return (z.name && z.value) ? z : undefined; | |
| } | |
| catch(err) { | |
| return false; | |
| }; | |
| return false; | |
| }; | |
| $.jqCookie.remove = function(c_name) { | |
| try { | |
| $.jqCookie.set(c_name,"",-1); | |
| } | |
| catch(err) { | |
| return false; | |
| }; | |
| return true; | |
| }; | |
| $.jqCookie.set = function(c_name, value, exdays) { | |
| try { | |
| if (typeof value === "object") value = $.jqCookie.serialize(value); | |
| var exdate = undefined; | |
| var c_value = escape(value); | |
| if (exdays != null && exdays != undefined) { | |
| exdate = new Date(); | |
| exdate.setDate(exdate.getDate() + exdays); | |
| c_value += "<br />"+exdate.toUTCString()+"<br />"+exdays+"; expires="+exdate.toUTCString(); | |
| } | |
| else { | |
| }; | |
| document.cookie=c_name + "=" + c_value; | |
| return $.jqCookie.get(c_name); | |
| } | |
| catch(err) { | |
| return false; | |
| }; | |
| return true; | |
| }; | |
| $.jqCookie.serialize = function(value, $bool) { | |
| // Thanks to Kevin van Zonneveld & all who helped him for providing the following 3 functions | |
| // http://kevin.vanzonneveld.net | |
| function serialize(b){var h=function(a){for(var g=0,e=0,c=a.length,d="",e=0;e<c;e++)d=a.charCodeAt(e),g=128>d?g+1:2048>d?g+2:g+3;return g},i=function(a){var d=typeof a,e,c;if("object"===d&&!a)return"null";if("object"===d){if(!a.constructor)return"object";a=a.constructor.toString();(e=a.match(/(\w+)\(/))&&(a=e[1].toLowerCase());e=["boolean","number","string","array"];for(c in e)if(a==e[c]){d=e[c];break}}return d},k=i(b),j="";switch(k){case "function":h="";break;case "boolean":h="b:"+(b?"1":"0");break; | |
| case "number":h=(Math.round(b)==b?"i":"d")+":"+b;break;case "string":h="s:"+h(b)+':"'+b+'"';break;case "array":case "object":var h="a",d=0,l="",a;for(a in b)b.hasOwnProperty(a)&&(j=i(b[a]),"function"!==j&&(j=a.match(/^[0-9]+$/)?parseInt(a,10):a,l+=serialize(j)+serialize(b[a]),d++));h+=":"+d+":{"+l+"}";break;default:h="N"}"object"!==k&&"array"!==k&&(h+=";");return h} | |
| function unserialize(b){var h=this,i=function(d,b,a){for(var f=[],g=d.slice(b,b+1),e=2;g!=a;){if(e+b>d.length)return d;f.push(g);g=d.slice(b+(e-1),b+e);e+=1}return[f.length,f.join("")]},k=function(d,b,a){var f;f=[];for(var g=0;g<a;g++){var e=d.slice(b+(g-1),b+g);f.push(e);e=e.charCodeAt(0);a-=128>e?0:2048>e?1:2}return[f.length,f.join("")]},j=function(d,b){var a,f=0,g;b||(b=0);var e=d.slice(b,b+1).toLowerCase(),c=b+2,n=function(a){return a};switch(e){case "i":n=function(a){return parseInt(a,10)};a= | |
| i(d,c,";");f=a[0];a=a[1];c+=f+1;break;case "b":n=function(a){return 0!==parseInt(a,10)};a=i(d,c,";");f=a[0];a=a[1];c+=f+1;break;case "d":n=function(a){return parseFloat(a)};a=i(d,c,";");f=a[0];a=a[1];c+=f+1;break;case "n":a=null;break;case "s":a=i(d,c,":");f=a[0];g=a[1];c+=f+2;a=k(d,c+1,parseInt(g,10));f=a[0];a=a[1];c+=f+2;if(f!=parseInt(g,10)&&f!=a.length)throw new h.window.SyntaxError("String length mismatch",void 0,void 0);a=utf8_decode(a);break;case "a":a={};g=i(d,c,":");f=g[0];g=g[1];c+=f+2; | |
| for(f=0;f<parseInt(g,10);f++){var m=j(d,c),o=m[2],c=c+m[1],m=j(d,c),p=m[2],c=c+m[1];a[o]=p}c+=1;break;default:throw new h.window.SyntaxError("Unknown / Unhandled data type(s): "+e,void 0,void 0);}return[e,c-b,n(a)]};return""!=j(b+"",0)[2]?j(b+"",0)[2]:b} | |
| function utf8_decode(b){for(var h=[],i=0,k=0,j=0,d=0,l=0,b=b+"";i<b.length;)j=b.charCodeAt(i),128>j?(h[k++]=String.fromCharCode(j),i++):191<j&&224>j?(d=b.charCodeAt(i+1),h[k++]=String.fromCharCode((j&31)<<6|d&63),i+=2):(d=b.charCodeAt(i+1),l=b.charCodeAt(i+2),h[k++]=String.fromCharCode((j&15)<<12|(d&63)<<6|l&63),i+=3);return h.join("")}; | |
| if ($bool === true) { | |
| return serialize(value); | |
| } | |
| else if ($bool === undefined) { | |
| return serialize(value); | |
| } | |
| else { | |
| var un = unserialize(value); | |
| return un==true?value:un; | |
| }; | |
| return false; | |
| } | |
| }; | |
| })(jQuery); |
This file contains hidden or 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
| (function($) { // TODO: Addin better error handling on try catch states and add encrypt security option | |
| if (!$.jqCookie) { | |
| $.extend({ | |
| jqCookie: function(getORset) { | |
| var args = Array.prototype.slice.call(arguments).splice(1); | |
| switch(typeof getORset) { | |
| case "string": | |
| switch(getORset) { | |
| case 'get': | |
| if (args.length === 0) { | |
| return $.jqCookie.get('all'); | |
| } | |
| else if (args.length === 1) { | |
| switch(typeof args[0]) { | |
| case "string": | |
| return $.jqCookie.get(args[0]) | |
| break; | |
| case "object": | |
| if (args[0]['name']) { | |
| return $.jqCookie.get(args[0]['name']) | |
| } | |
| else if (args[0]['value']) { | |
| return false; // TODO: | |
| }; | |
| break; | |
| default: | |
| return false; // TODO: | |
| } | |
| } | |
| else if (args.length > 1) { | |
| return false; // TODO: | |
| } | |
| else { | |
| // TODO: ERROR! | |
| return false; // TODO: | |
| }; | |
| break; | |
| case 'remove': | |
| if (args.length === 1) { | |
| if (typeof args[0] === "string") { | |
| return $.jqCookie.remove(args[0]); | |
| } | |
| else if (typeof args[0] === "object") { | |
| if (args[0]['name']) { | |
| return $.jqCookie.remove(args[0]['name']) | |
| } | |
| else if (args[0]['value']) { | |
| }; | |
| }; | |
| }; | |
| break; | |
| case 'set': | |
| if (args.length <= 0) { | |
| // TODO: ERROR! | |
| return false; // TODO: | |
| } | |
| else if (args.length === 1) { | |
| switch(typeof args[0]) { | |
| case "string": | |
| return $.jqCookie.remove(args[0]); | |
| break; | |
| case "object": | |
| if (args[0]['name'] && args[0]['value'] && args[0]['days']) { | |
| return $.jqCookie.set(args[0]['name'], args[0]['value'], args[0]['days']); | |
| } | |
| else if (args[0]['name'] && args[0]['value']) { | |
| return $.jqCookie.set(args[0]['name'], args[0]['value']); | |
| }; | |
| break; | |
| default: | |
| return false; // TODO: | |
| } | |
| } | |
| else if (args.length === 2) { | |
| if (typeof args[0] === "string" && typeof args[1] === "string") { | |
| return $.jqCookie.set(args[0], args[1]); | |
| }; | |
| } | |
| else if (args.length === 3) { | |
| if (typeof args[0] === "string" && typeof args[1] === "string" && typeof args[2] === "string") { | |
| return $.jqCookie.set(args[0], args[1], args[2]); | |
| } | |
| else if (typeof args[0] === "string" && typeof args[1] === "string" && typeof args[2] === "number") { | |
| return $.jqCookie.set(args[0], args[1], parseFloat(args[2])); | |
| }; | |
| } | |
| else if (args.length > 3) { | |
| return false; // TODO: | |
| }; | |
| break; | |
| default: | |
| if (args.length === 0) { | |
| // only a value has been provided | |
| // TODO: write func to add value using namespace+count as key and make retievable func via the value | |
| if (typeof getORset == "string") { | |
| return $.jqCookie.get(getORset); | |
| } | |
| else if (typeof getORset == "object") { | |
| }; | |
| } | |
| else if (args.length === 1) { | |
| // a key and a value have been given, that's enough for a cookie creation, if that value is a string | |
| if (typeof args[0] === "string") return $.jqCookie.set(getORset, args[0]); | |
| var arg0 = args[0]; | |
| if (!$.isPlainObject(arg0) && arg0[0].tagName) { | |
| return $.jqCookie(getORset, '<CHTML>'+arg0[0].outerHTML); | |
| } | |
| else { | |
| return $.jqCookie(getORset, $.jqCookie.serialize(arg0)); | |
| }; | |
| } | |
| else if (args.length > 1) { | |
| // mayhaps the days are set!? | |
| if (typeof args[0] === "string" && typeof args[1] === "number") { | |
| return $.jqCookie.set(getORset, args[0], args[1]); | |
| } | |
| else if (typeof args[0] === "string" && typeof args[1] === "string") { | |
| return $.jqCookie.set(getORset, args[0], parseFloat(args[1])); | |
| } | |
| else if (typeof args[0] === "object" && typeof args[1] === "string") { | |
| }; | |
| } | |
| else { | |
| // TODO: ERROR! | |
| }; | |
| }; | |
| break; | |
| case "object": | |
| if (getORset['type']) { | |
| var typ = getORset["type"]; | |
| delete getORset["type"]; | |
| return $.jqCookie(typ, getORset); | |
| }; | |
| break; | |
| default: | |
| return false; | |
| }; | |
| return false; | |
| } | |
| }); | |
| $.jqCookie.get = function(c_name) { | |
| try { | |
| if (c_name == 'all') { | |
| var args = Array.prototype.slice.call(arguments).splice(1); | |
| var i,x,y,ARRcookies=document.cookie.split(";"),z=new Array(); | |
| for (i=0;i<ARRcookies.length;i++) { | |
| x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); | |
| y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); | |
| x=x.replace(/^\s+|\s+$/g,""); | |
| if (typeof args[0] === "boolean") { | |
| if (args[0] == true && args.length == 2) { | |
| if (typeof args[1] === "string") { | |
| if (x.toLowerCase().indexOf(args[1]) >= 0) { | |
| y = unescape(y).split("<br />"); | |
| z[i] = { | |
| name: unescape(x), | |
| value: y[0].charAt(1)==":" ? $.jqCookie.serialize(y[0], false) : y[0], | |
| exp: { | |
| date: y[1], | |
| count: y[2] | |
| } | |
| }; | |
| }; | |
| }; | |
| }; | |
| } | |
| else { | |
| y = unescape(y).split("<br />"); | |
| z[i] = { | |
| name: unescape(x), | |
| value: y[0].charAt(1)==":" ? $.jqCookie.serialize(y[0], false) : y[0], | |
| exp: { | |
| date: y[1], | |
| count: y[2] | |
| } | |
| }; | |
| }; | |
| }; | |
| return z.length > 0 ? z : false; | |
| }; | |
| var i,x,y,ARRcookies=document.cookie.split(";"), | |
| z = { name: undefined, value: undefined, exp: { count: undefined, date: undefined } }; | |
| for (i=0;i<ARRcookies.length;i++) { | |
| x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); | |
| y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); | |
| x=x.replace(/^\s+|\s+$/g,""); | |
| if (x==c_name) { | |
| z.name = unescape(x); | |
| y = unescape(y).split("<br />"); | |
| z.value = y[0].charAt(1)==":" ? $.jqCookie.serialize(y[0], false) : y[0], | |
| z.exp.date = y[1]; | |
| z.exp.count = y[2]; | |
| }; | |
| if (typeof z.value === "string") { | |
| if (z.value.indexOf("<CHTML>") >= 0) z.value = $(z.value.replace("<CHTML>", "")); | |
| }; | |
| }; | |
| return (z.name && z.value) ? z : undefined; | |
| } | |
| catch(err) { | |
| return false; | |
| }; | |
| return false; | |
| }; | |
| $.jqCookie.remove = function(c_name) { | |
| try { | |
| $.jqCookie.set(c_name,"",-1); | |
| } | |
| catch(err) { | |
| return false; | |
| }; | |
| return true; | |
| }; | |
| $.jqCookie.set = function(c_name, value, exdays) { | |
| try { | |
| if (typeof value === "object") value = $.jqCookie.serialize(value); | |
| var exdate = undefined; | |
| var c_value = escape(value); | |
| if (exdays != null && exdays != undefined) { | |
| exdate = new Date(); | |
| exdate.setDate(exdate.getDate() + exdays); | |
| c_value += "<br />"+exdate.toUTCString()+"<br />"+exdays+"; expires="+exdate.toUTCString(); | |
| } | |
| else { | |
| }; | |
| document.cookie=c_name + "=" + c_value; | |
| return $.jqCookie.get(c_name); | |
| } | |
| catch(err) { | |
| return false; | |
| }; | |
| return true; | |
| }; | |
| $.jqCookie.serialize = function(value, $bool) { | |
| // Thanks to Kevin van Zonneveld & all who helped him for providing the following 3 functions | |
| // http://kevin.vanzonneveld.net | |
| function serialize(b){var h=function(a){for(var g=0,e=0,c=a.length,d="",e=0;e<c;e++)d=a.charCodeAt(e),g=128>d?g+1:2048>d?g+2:g+3;return g},i=function(a){var d=typeof a,e,c;if("object"===d&&!a)return"null";if("object"===d){if(!a.constructor)return"object";a=a.constructor.toString();(e=a.match(/(\w+)\(/))&&(a=e[1].toLowerCase());e=["boolean","number","string","array"];for(c in e)if(a==e[c]){d=e[c];break}}return d},k=i(b),j="";switch(k){case "function":h="";break;case "boolean":h="b:"+(b?"1":"0");break; | |
| case "number":h=(Math.round(b)==b?"i":"d")+":"+b;break;case "string":h="s:"+h(b)+':"'+b+'"';break;case "array":case "object":var h="a",d=0,l="",a;for(a in b)b.hasOwnProperty(a)&&(j=i(b[a]),"function"!==j&&(j=a.match(/^[0-9]+$/)?parseInt(a,10):a,l+=serialize(j)+serialize(b[a]),d++));h+=":"+d+":{"+l+"}";break;default:h="N"}"object"!==k&&"array"!==k&&(h+=";");return h} | |
| function unserialize(b){var h=this,i=function(d,b,a){for(var f=[],g=d.slice(b,b+1),e=2;g!=a;){if(e+b>d.length)return d;f.push(g);g=d.slice(b+(e-1),b+e);e+=1}return[f.length,f.join("")]},k=function(d,b,a){var f;f=[];for(var g=0;g<a;g++){var e=d.slice(b+(g-1),b+g);f.push(e);e=e.charCodeAt(0);a-=128>e?0:2048>e?1:2}return[f.length,f.join("")]},j=function(d,b){var a,f=0,g;b||(b=0);var e=d.slice(b,b+1).toLowerCase(),c=b+2,n=function(a){return a};switch(e){case "i":n=function(a){return parseInt(a,10)};a= | |
| i(d,c,";");f=a[0];a=a[1];c+=f+1;break;case "b":n=function(a){return 0!==parseInt(a,10)};a=i(d,c,";");f=a[0];a=a[1];c+=f+1;break;case "d":n=function(a){return parseFloat(a)};a=i(d,c,";");f=a[0];a=a[1];c+=f+1;break;case "n":a=null;break;case "s":a=i(d,c,":");f=a[0];g=a[1];c+=f+2;a=k(d,c+1,parseInt(g,10));f=a[0];a=a[1];c+=f+2;if(f!=parseInt(g,10)&&f!=a.length)throw new h.window.SyntaxError("String length mismatch",void 0,void 0);a=utf8_decode(a);break;case "a":a={};g=i(d,c,":");f=g[0];g=g[1];c+=f+2; | |
| for(f=0;f<parseInt(g,10);f++){var m=j(d,c),o=m[2],c=c+m[1],m=j(d,c),p=m[2],c=c+m[1];a[o]=p}c+=1;break;default:throw new h.window.SyntaxError("Unknown / Unhandled data type(s): "+e,void 0,void 0);}return[e,c-b,n(a)]};return""!=j(b+"",0)[2]?j(b+"",0)[2]:b} | |
| function utf8_decode(b){for(var h=[],i=0,k=0,j=0,d=0,l=0,b=b+"";i<b.length;)j=b.charCodeAt(i),128>j?(h[k++]=String.fromCharCode(j),i++):191<j&&224>j?(d=b.charCodeAt(i+1),h[k++]=String.fromCharCode((j&31)<<6|d&63),i+=2):(d=b.charCodeAt(i+1),l=b.charCodeAt(i+2),h[k++]=String.fromCharCode((j&15)<<12|(d&63)<<6|l&63),i+=3);return h.join("")}; | |
| if ($bool === true) { | |
| return serialize(value); | |
| } | |
| else if ($bool === undefined) { | |
| return serialize(value); | |
| } | |
| else { | |
| var un = unserialize(value); | |
| return un==true?value:un; | |
| }; | |
| return false; | |
| } | |
| }; | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment