/*! * jQuery SuperCookie v1 -- https://github.com/tantau-horia/jquery-SuperCookie -- Copyright 2012, Tantau Horia -- Dual licensed under the MIT or GPL Version 2 licenses * */ (function(b,k,l,i){var h={expires:7,path:"/"},j={};b.super_cookie=function(a){b.extend(h,a);b.extend(this,j);if("undefined"===typeof console||"undefined"===typeof console.log)k.console||(console={log:function(){}});return this};j={create:function(a,d,e){e=b.extend({},h,e);b.cookie(a,JSON.stringify(d),e)},check:function(a){if(null!==a&&a!==i)return null===b.cookie(a)?(console.log("No cookie."),!1):!0;console.log("No cookie selected.");return!1},verify:function(a){if(null!==a&&a!==i){a=b.cookie(a); if(null===a)return console.log("No cookie."),!1;if(jQuery.isEmptyObject(a))return console.log("Invalid values."),!1;try{JSON.parse(a)}catch(d){return console.log("Not JSON."),!1}return!0}console.log("No cookie selected.");return!1},check_index:function(a,d){var e=b.super_cookie().read_JSON(a),c=null;b.each(e,function(a){d===a&&(c="ok")});return null===c?!1:!0},read_values:function(a){return b.super_cookie().verify(a)?b.cookie(a):!1},read_indexes:function(a){var a=b.super_cookie().read_JSON(a),d=[]; b.each(a,function(a){d.push(a)});return d},read_JSON:function(a){return b.super_cookie().verify(a)?JSON.parse(b.cookie(a)):!1},read_value:function(a,d){var e=b.super_cookie().read_JSON(a),c=null;b.each(e,function(a,b){d==a&&(c=b)});return null===c?!1:c},replace_value:function(a,d,e,c){var f=b.super_cookie().read_JSON(a),g=[];b.each(f,function(a,b){field='"'+a+'": "'+b+'"';d===a&&(field='"'+a+'": "'+e+'"');g.push(field)});g="{"+g.join(", ")+"}";f={};f=JSON.stringify(g);c=b.extend({},h,c);b.removeCookie(a); b.cookie(a,JSON.parse(f),c)},add_value:function(a,d,e,c){var f=b.super_cookie().read_JSON(a),g=[];b.each(f,function(a,b){field='"'+a+'": "'+b+'"';g.push(field)});g.push('"'+d+'": "'+e+'"');g="{"+g.join(", ")+"}";d={};d=JSON.stringify(g);c=b.extend({},h,c);b.removeCookie(a);b.cookie(a,JSON.parse(d),c)},remove_value:function(a,d,e){var c=b.super_cookie().read_JSON(a),f=[];b.each(c,function(a,b){field='"'+a+'": "'+b+'"';d!==a&&f.push(field)});f="{"+f.join(", ")+"}";c={};c=JSON.stringify(f);e=b.extend({}, h,e);b.removeCookie(a);b.cookie(a,JSON.parse(c),e)}}})(jQuery,document);