feature(config) add dirStorage

This commit is contained in:
coderaiser 2014-08-28 07:47:42 -04:00
parent 61d2cc6555
commit 6ffe06cd65
5 changed files with 48 additions and 35 deletions

View file

@ -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 */

View file

@ -8,6 +8,7 @@
<li><span><input type="checkbox" id="notifications" {{ notifications }} ></input></span><label for="notifications"> Notifications</label></li>
<li><span><input type="checkbox" id="localStorage" {{ localStorage }} ></input></span><label for="localStorage"> Local Storage</label></li>
<li><span><input type="checkbox" id="buffer" {{ buffer }} ></input></span> <label for="buffer">Buffer</label></li>
<li><span><input type="checkbox" id="dirStorage" {{ dirStorage }} ></input></span> <label for="dirStorage">Directory Storage</label></li>
<li><span><input type="checkbox" id="minify" {{ minify }} ></input></span><label for="minify"> Minify</label></li>
<li><span><input type="checkbox" id="online" {{ online }} ></input></span><label for="online"> Online</label></li>
<li><span><input type="checkbox" id="cache" {{ cache }} ></input></span><label for="cache"> Cache</label></li>

View file

@ -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
}

View file

@ -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();
});
}

View file

@ -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) {