From 6ffe06cd65dad3e21a0f2881c8d3ea4a59a2c2cc Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 28 Aug 2014 07:47:42 -0400 Subject: [PATCH] feature(config) add dirStorage --- HELP.md | 1 + html/config.html | 1 + json/config.json | 22 ++++++++++++---------- lib/client.js | 26 ++++++++++++++++++++------ lib/client/config.js | 33 ++++++++++++++------------------- 5 files changed, 48 insertions(+), 35 deletions(-) diff --git a/HELP.md b/HELP.md index 7b220094..5d5efa1e 100644 --- a/HELP.md +++ b/HELP.md @@ -235,6 +235,7 @@ All main configuration could be done via `json/config.json`. "notifications" : false, /* show notifications when tab is not active*/ "localStorage" : true, /* cache directory data */ "buffer" : true, /* buffer for copying files */ + "dirStorage" : true, /* store directory listing to localStorage */ "minify" : true, /* minification of js,css,html and img */ "online" : true, /* load js files from cdn or local path */ "cache" : true, /* add cache-control */ diff --git a/html/config.html b/html/config.html index f8f79b97..a824bb36 100644 --- a/html/config.html +++ b/html/config.html @@ -8,6 +8,7 @@
  • +
  • diff --git a/json/config.json b/json/config.json index bb0a7eec..2ae5dba5 100644 --- a/json/config.json +++ b/json/config.json @@ -1,22 +1,24 @@ { - "auth": false, - "username": "root", - "password": "435b41068e8665513a20070c033b08b9c66e4332", - "analytics": true, - "diff": true, - "zip" : true, + "auth": true, + "username": "coderaiser", + "password": "2df4e196c47f52f553dc7c791cf442033391653a", + "analytics": false, + "diff": false, + "zip": true, "notifications": false, "localStorage": true, - "buffer": true, - "minify": true, + "minify": false, "online": true, "cache": true, "logs": false, "showKeysPanel": true, "server": true, "socket": true, - "port": 8000, + "port": 31337, "sslPort": 4430, "ip": null, - "ssl": false + "ssl": false, + "appCache": false, + "buffer": true, + "dirStorage": true } diff --git a/lib/client.js b/lib/client.js index 9059f50b..56555259 100644 --- a/lib/client.js +++ b/lib/client.js @@ -311,12 +311,7 @@ var Util, DOM, CloudFunc; * { refresh, history } - необходимость обновить данные о каталоге */ function ajaxLoad(path, options, panel) { - if (!options) - options = {}; - - Util.log ('reading dir: "' + path + '";'); - - Storage.get(path, function(error, json) { + var create = function(error, json) { var RESTful = DOM.RESTful, obj = Util.parseJSON(json), isRefresh = options.refresh, @@ -329,6 +324,25 @@ var Util, DOM, CloudFunc; createFileTable(obj, panel, history); Storage.set(path, obj); }); + }; + + if (!options) + options = {}; + + Util.log ('reading dir: "' + path + '";'); + + Files.get('config', function(error, config) { + var dirStorage; + + if (error) + Util.log(error); + else + dirStorage = config.dirStorage; + + if (dirStorage) + Storage.get(path, create); + else + create(); }); } diff --git a/lib/client/config.js b/lib/client/config.js index 8a571186..c6f09817 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -129,9 +129,11 @@ var CloudCmd, Util, DOM; if (el.id === 'localStorage') onLocalStorageChange(data); else if (el.id === 'diff') - onDiffChange(data); + onLSChange(data); else if (el.id === 'buffer') - onBufferChange(data); + onLSChange(data); + else if (el.id === 'dirStorage') + onLSChange(data); break; case 'number': @@ -157,15 +159,18 @@ var CloudCmd, Util, DOM; } function onLocalStorageChange(checked) { - var elDiff = DOM.getById('diff', Element), - elBuffer = DOM.getById('buffer', Element), - msg = 'Diff and Buffer do not work without localStorage'; + var elDiff = DOM.getById('diff', Element), + elBuffer = DOM.getById('buffer', Element), + elDirStorage = DOM.getById('dirStorage', Element), + isChecked = elDiff.checked || elBuffer.checked || elDirStorage.checked, + msg = 'Diff, Buffer and Directory Storage do not work without localStorage'; - if (!checked && (elDiff.checked || elBuffer.checked)) { + if (!checked && isChecked) { alert(msg); - elDiff.checked = - elBuffer.checked = false; + elDiff.checked = + elBuffer.checked = + elDirStorage.checked = false; onChange({ target: elDiff @@ -177,17 +182,7 @@ var CloudCmd, Util, DOM; } } - function onDiffChange(checked) { - var element = DOM.getById('localStorage', Element); - - if (!element.checked && checked) { - onLocalStorageChange(element.checked); - } - - return element.checked; - } - - function onBufferChange(checked) { + function onLSChange(checked) { var element = DOM.getById('localStorage', Element); if (!element.checked && checked) {