From fdfb9c6a2877dcbadeab697aad779bea76780965 Mon Sep 17 00:00:00 2001 From: Michal Rezler Date: Sat, 26 Mar 2011 15:42:22 +0100 Subject: cookie.js is jQueryfied, added jQuery-cookie-plugin --- lib/scripts/cookie.js | 99 ++++++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 57 deletions(-) (limited to 'lib/scripts/cookie.js') diff --git a/lib/scripts/cookie.js b/lib/scripts/cookie.js index d7e6b3550..1fccf85ba 100644 --- a/lib/scripts/cookie.js +++ b/lib/scripts/cookie.js @@ -4,109 +4,94 @@ * Only a single cookie is written and read. You may only save * sime name-value pairs - no complex types! * - * You should only use the getValue and setValue methods * * @author Andreas Gohr + * @author Michal Rezler */ -DokuCookie = { - data: Array(), - name: 'DOKU_PREFS', + +var setDokuCookie, getDokuCookie; + +(function ($) { + var init, setCookie, fixDate; + + var data = Array(); + var name = 'DOKU_PREFS'; /** * Save a value to the cookie * * @author Andreas Gohr */ - setValue: function(key,val){ - DokuCookie.init(); - DokuCookie.data[key] = val; + setDokuCookie = function(key,val){ + init(); + data[key] = val; // prepare expire date var now = new Date(); - DokuCookie.fixDate(now); + 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 DokuCookie.data){ - if (!DokuCookie.data.hasOwnProperty(key)) continue; - text += '#'+escape(key)+'#'+DokuCookie.data[key]; + for(var key in data){ + if (!data.hasOwnProperty(key)) continue; + text += '#'+escape(key)+'#'+data[key]; } - DokuCookie.setCookie(DokuCookie.name,text.substr(1),now,DOKU_BASE); - }, + setCookie(name,text.substr(1),now,DOKU_BASE); + }; /** * Get a Value from the Cookie * * @author Andreas Gohr */ - getValue: function(key){ - DokuCookie.init(); - return DokuCookie.data[key]; - }, + getDokuCookie = function(key){ + init(); + return data[key]; + }; /** * Loads the current set cookie * * @author Andreas Gohr */ - init: function(){ - if(DokuCookie.data.length) return; - var text = DokuCookie.getCookie(DokuCookie.name); + 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)); -- cgit v1.2.3 From 2ed49e2ac1bc9ed8a9d514d3ea9515e455768152 Mon Sep 17 00:00:00 2001 From: Michal Rezler Date: Mon, 28 Mar 2011 23:09:13 +0200 Subject: JS API is corrected to the original state --- lib/scripts/cookie.js | 97 +++++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 46 deletions(-) (limited to 'lib/scripts/cookie.js') diff --git a/lib/scripts/cookie.js b/lib/scripts/cookie.js index 1fccf85ba..4904117ee 100644 --- a/lib/scripts/cookie.js +++ b/lib/scripts/cookie.js @@ -1,97 +1,102 @@ /** - * 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'; +* 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! +* +* You should only use the getValue and setValue methods +* +* @author Andreas Gohr +* @author Michal Rezler +*/ +DokuCookie = { + data: Array(), + name: 'DOKU_PREFS', /** * Save a value to the cookie * * @author Andreas Gohr */ - setDokuCookie = function(key,val){ - init(); - data[key] = val; + setValue: function(key,val){ + this.init(); + this.data[key] = val; // prepare expire date var now = new Date(); - fixDate(now); + this.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]; + for(var key in this.data){ + if (!this.data.hasOwnProperty(key)) continue; + text += '#'+escape(key)+'#'+this.data[key]; } - setCookie(name,text.substr(1),now,DOKU_BASE); - }; + this.setCookie(this.name,text.substr(1),now,DOKU_BASE); + }, /** * Get a Value from the Cookie * * @author Andreas Gohr */ - getDokuCookie = function(key){ - init(); - return data[key]; - }; + getValue: function(key){ + this.init(); + return this.data[key]; + }, /** * Loads the current set cookie * * @author Andreas Gohr */ - init = function(){ - if(data.length) return; - var text = $.cookie(name); - + init: function(){ + if(this.data.length) return; + var text = this.getCookie(this.name); if(text){ var parts = text.split('#'); for(var i=0; i 0){ date.setTime(date.getTime() - skew); } - }; - -}(jQuery)); + } +}; \ No newline at end of file -- cgit v1.2.3 From 9de3b5710719658ef75740c0bd930423cc7c209c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 21 Aug 2011 02:16:39 +0300 Subject: issue #44 uploader fixes, #45 browser testing --- lib/scripts/cookie.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts/cookie.js') diff --git a/lib/scripts/cookie.js b/lib/scripts/cookie.js index f7d9b5ffb..e7ba620c7 100644 --- a/lib/scripts/cookie.js +++ b/lib/scripts/cookie.js @@ -72,7 +72,7 @@ DokuCookie = { expires: expires_, path: path_, domain: domain_, - secure: secure_, + secure: secure_ }; jQuery.cookie(name, value, params); -- cgit v1.2.3 From 1c5f7481f4e685ad3ffe9ba48ed47ed75196e64a Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 22 Aug 2011 16:10:05 +0200 Subject: Update jquery-cookie, cleanup dw_cookie Pulled the current jquery-cookie version from https://github.com/carhartl/jquery-cookie. --- lib/scripts/cookie.js | 73 ++++++++++++--------------------------------------- 1 file changed, 17 insertions(+), 56 deletions(-) (limited to 'lib/scripts/cookie.js') diff --git a/lib/scripts/cookie.js b/lib/scripts/cookie.js index f7d9b5ffb..f97882855 100644 --- a/lib/scripts/cookie.js +++ b/lib/scripts/cookie.js @@ -2,7 +2,7 @@ * 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! +* simple name-value pairs - no complex types! * * You should only use the getValue and setValue methods * @@ -10,7 +10,7 @@ * @author Michal Rezler */ DokuCookie = { - data: Array(), + data: {}, name: 'DOKU_PREFS', /** @@ -19,21 +19,17 @@ DokuCookie = { * @author Andreas Gohr */ setValue: function(key,val){ + var text = ''; this.init(); this.data[key] = val; - // prepare expire date - var now = new Date(); - this.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 this.data){ - if (!this.data.hasOwnProperty(key)) continue; - text += '#'+escape(key)+'#'+this.data[key]; - } - this.setCookie(this.name,text.substr(1),now,DOKU_BASE); + jQuery.each(this.data, function (val, key) { + if (this.data.hasOwnProperty(key)) { + text += '#'+encodeURIComponent(key)+'#'+encodeURIComponent(val); + } + }); + jQuery.cookie(this.name,text.substr(1), {expires: 365, path: DOKU_BASE}); }, /** @@ -52,51 +48,16 @@ DokuCookie = { * @author Andreas Gohr */ init: function(){ - if(this.data.length) return; - var text = this.getCookie(this.name); + var text, parts, i; + if(!jQuery.isEmptyObject(this.data)) { + return; + } + text = jQuery.cookie(this.name); if(text){ - var parts = text.split('#'); - for(var i=0; i 0){ - date.setTime(date.getTime() - skew); - } } }; -- cgit v1.2.3 From 87deddfa454164964c2fb71481cf480b3d2d92df Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 27 Aug 2011 00:59:47 +0300 Subject: issue #54 listview switch/sorting on search --- lib/scripts/cookie.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/scripts/cookie.js') diff --git a/lib/scripts/cookie.js b/lib/scripts/cookie.js index 3f3375fa7..4dd77beea 100644 --- a/lib/scripts/cookie.js +++ b/lib/scripts/cookie.js @@ -24,8 +24,8 @@ DokuCookie = { this.data[key] = val; //save the whole data array - jQuery.each(this.data, function (val, key) { - if (this.data.hasOwnProperty(key)) { + jQuery.each(this.data, function (key, val) { + if (DokuCookie.data.hasOwnProperty(key)) { text += '#'+encodeURIComponent(key)+'#'+encodeURIComponent(val); } }); -- cgit v1.2.3 From 5e7a292691951a0fa0a18f06c8b9bcfb509a032d Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 9 Sep 2011 22:26:16 +0200 Subject: Various JavaScript improvements, JSLint, jQuery --- lib/scripts/cookie.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/scripts/cookie.js') diff --git a/lib/scripts/cookie.js b/lib/scripts/cookie.js index 4dd77beea..c70d0bb56 100644 --- a/lib/scripts/cookie.js +++ b/lib/scripts/cookie.js @@ -9,7 +9,7 @@ * @author Andreas Gohr * @author Michal Rezler */ -DokuCookie = { +var DokuCookie = { data: {}, name: 'DOKU_PREFS', @@ -19,17 +19,18 @@ DokuCookie = { * @author Andreas Gohr */ setValue: function(key,val){ - var text = ''; + var text = [], + _this = this; this.init(); this.data[key] = val; //save the whole data array - jQuery.each(this.data, function (key, val) { - if (DokuCookie.data.hasOwnProperty(key)) { - text += '#'+encodeURIComponent(key)+'#'+encodeURIComponent(val); - } + jQuery.each(_this.data, function (key, val) { + if (_this.data.hasOwnProperty(key)) { + text.push(encodeURIComponent(key)+'#'+encodeURIComponent(val)); + } }); - jQuery.cookie(this.name,text.substr(1), {expires: 365, path: DOKU_BASE}); + jQuery.cookie(this.name, text.join('#'), {expires: 365, path: DOKU_BASE}); }, /** -- cgit v1.2.3 From ba18c46681e5a6b3de65bc71a29aa2d04b54870b Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 24 Sep 2011 16:43:15 +0200 Subject: Small JavaScript improvements --- lib/scripts/cookie.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts/cookie.js') diff --git a/lib/scripts/cookie.js b/lib/scripts/cookie.js index c70d0bb56..3ad67bfa4 100644 --- a/lib/scripts/cookie.js +++ b/lib/scripts/cookie.js @@ -60,5 +60,5 @@ var DokuCookie = { this.data[decodeURIComponent(parts[i])] = decodeURIComponent(parts[i+1]); } } - } + } }; -- cgit v1.2.3