From 807ff074540575e6ef8f99ad32b098a816091171 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 17:18:59 +0300 Subject: split main objects to dojo modules --- js/ArticleCache.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 js/ArticleCache.js (limited to 'js/ArticleCache.js') diff --git a/js/ArticleCache.js b/js/ArticleCache.js new file mode 100644 index 000000000..fbba1f679 --- /dev/null +++ b/js/ArticleCache.js @@ -0,0 +1,25 @@ +define(["dojo/_base/declare"], function (declare) { + return declare("fox.ArticleCache", null, { + has_storage: 'sessionStorage' in window && window['sessionStorage'] !== null, + set: function(id, obj) { + if (this.has_storage) + try { + sessionStorage["article:" + id] = obj; + } catch (e) { + sessionStorage.clear(); + } + }, + get: function(id) { + if (this.has_storage) + return sessionStorage["article:" + id]; + }, + clear: function() { + if (this.has_storage) + sessionStorage.clear(); + }, + del: function(id) { + if (this.has_storage) + sessionStorage.removeItem("article:" + id); + }, + }); +}); -- cgit v1.2.3 From f89924f7a19871e26d5805a6c1863903c6e474bf Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 18:38:27 +0300 Subject: set use strict on JS modules; remove some mostly useless stuff like get_minified_js() --- js/ArticleCache.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/ArticleCache.js') diff --git a/js/ArticleCache.js b/js/ArticleCache.js index fbba1f679..a4e8e091f 100644 --- a/js/ArticleCache.js +++ b/js/ArticleCache.js @@ -1,3 +1,5 @@ +'use strict' +/* global __, ngettext */ define(["dojo/_base/declare"], function (declare) { return declare("fox.ArticleCache", null, { has_storage: 'sessionStorage' in window && window['sessionStorage'] !== null, -- cgit v1.2.3 From 84affc7b1d71769038dfd25d74e40d6bf744e5fb Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 3 Dec 2018 09:33:44 +0300 Subject: rework dojo singleton modules to better work with phpstorm completion (ugh) - declare() is not needed there anyway remove event.observe from login form (not needed) load pluginhost via amd --- js/ArticleCache.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'js/ArticleCache.js') diff --git a/js/ArticleCache.js b/js/ArticleCache.js index a4e8e091f..ce34d00d9 100644 --- a/js/ArticleCache.js +++ b/js/ArticleCache.js @@ -1,9 +1,9 @@ 'use strict' /* global __, ngettext */ define(["dojo/_base/declare"], function (declare) { - return declare("fox.ArticleCache", null, { + ArticleCache = { has_storage: 'sessionStorage' in window && window['sessionStorage'] !== null, - set: function(id, obj) { + set: function (id, obj) { if (this.has_storage) try { sessionStorage["article:" + id] = obj; @@ -11,17 +11,19 @@ define(["dojo/_base/declare"], function (declare) { sessionStorage.clear(); } }, - get: function(id) { + get: function (id) { if (this.has_storage) return sessionStorage["article:" + id]; }, - clear: function() { + clear: function () { if (this.has_storage) sessionStorage.clear(); }, - del: function(id) { + del: function (id) { if (this.has_storage) sessionStorage.removeItem("article:" + id); }, - }); + } + + return ArticleCache; }); -- cgit v1.2.3