/** * Handles the cookie used by several JavaScript functions * * Only a single cookie is written and read. You may only save * sime name-value pairs - no complex types! * * * @author Andreas Gohr * @author Michal Rezler */ var setDokuCookie, getDokuCookie; (function ($) { var init, setCookie, fixDate; var data = Array(); var name = 'DOKU_PREFS'; /** * Save a value to the cookie * * @author Andreas Gohr */ setDokuCookie = function(key,val){ init(); data[key] = val; // prepare expire date var now = new Date(); fixDate(now); now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); //expire in a year //save the whole data array var text = ''; for(var key in data){ if (!data.hasOwnProperty(key)) continue; text += '#'+escape(key)+'#'+data[key]; } setCookie(name,text.substr(1),now,DOKU_BASE); }; /** * Get a Value from the Cookie * * @author Andreas Gohr */ getDokuCookie = function(key){ init(); return data[key]; }; /** * Loads the current set cookie * * @author Andreas Gohr */ init = function(){ if(data.length) return; var text = $.cookie(name); if(text){ var parts = text.split('#'); for(var i=0; i 0){ date.setTime(date.getTime() - skew); } }; }(jQuery));