2 * Handles the cookie used by several JavaScript functions
4 * Only a single cookie is written and read. You may only save
5 * simple name-value pairs - no complex types!
7 * You should only use the getValue and setValue methods
9 * @author Andreas Gohr <andi@splitbrain.org>
10 * @author Michal Rezler <m.rezler@centrum.cz>
17 * Save a value to the cookie
19 * @author Andreas Gohr <andi@splitbrain.org>
21 setValue: function(key,val){
26 delete this.data[key];
33 //save the whole data array
34 jQuery.each(_this.data, function (key, val) {
35 if (_this.data.hasOwnProperty(key)) {
36 text.push(encodeURIComponent(key)+'#'+encodeURIComponent(val));
39 jQuery.cookie(this.name, text.join('#'), {expires: 365, path: DOKU_COOKIE_PARAM.path, secure: DOKU_COOKIE_PARAM.secure});
43 * Get a Value from the Cookie
45 * @author Andreas Gohr <andi@splitbrain.org>
46 * @param def default value if key does not exist; if not set, returns undefined by default
48 getValue: function(key, def){
50 return this.data.hasOwnProperty(key) ? this.data[key] : def;
54 * Loads the current set cookie
56 * @author Andreas Gohr <andi@splitbrain.org>
60 if(!jQuery.isEmptyObject(this.data)) {
63 text = jQuery.cookie(this.name);
65 parts = text.split('#');
66 for(i = 0; i < parts.length; i += 2){
67 this.data[decodeURIComponent(parts[i])] = decodeURIComponent(parts[i+1]);