Commit 59d01abf authored by Sven Franck's avatar Sven Franck

jslint pass waitstorage.js

parent 93c5a742
/*global window, define */ /*jslint indent: 2, maxlen: 80, sloppy: true */
/*global setTimeout: true, window: true, define: true, jIO: true */
(function () { (function () {
'use strict'; 'use strict';
var jioWaitStorageLoader = function (jIO) { var jioWaitStorageLoader = function (jIO) {
var newWaitStorage = function (spec, my) { var newWaitStorage = function (spec, my) {
var that = my.basicStorage(spec, my), var that = my.basicStorage(spec, my),
priv = {}, priv = {},
validatestate_sub_storage = spec.storage || false; validatestate_sub_storage = spec.storage || false;
priv.sub_storage_spec = spec.storage || { priv.sub_storage_spec = spec.storage || {
type: 'base' type: 'base'
}; };
priv.delay = spec.delay || 5000; priv.delay = spec.delay || 5000;
priv.save = spec.save || true; priv.save = spec.save || true;
priv.load = spec.load || false; priv.load = spec.load || false;
priv.getlist = spec.getlist || false; priv.getlist = spec.getlist || false;
priv.remove = spec.remove || false; priv.remove = spec.remove || false;
that.validateState = function () { that.validateState = function () {
if (!validatestate_sub_storage) { if (!validatestate_sub_storage) {
return 'Need at least one parameter: "storage" ' + return 'Need at least one parameter: "storage" ' +
'containing storage specifications.'; 'containing storage specifications.';
} }
return ''; return '';
}; };
that.specToStore = function () { that.specToStore = function () {
var o = {}; var o = {};
o.delay = priv.delay; o.delay = priv.delay;
o.storage = priv.sub_storage_spec; o.storage = priv.sub_storage_spec;
o.save = priv.save; o.save = priv.save;
o.load = priv.load; o.load = priv.load;
o.getlist = priv.getlist; o.getlist = priv.getlist;
o.remove = priv.remove; o.remove = priv.remove;
return o; return o;
}; };
priv.doJob = function (command, timeout_or_not_timeout) { priv.doJob = function (command, timeout_or_not_timeout) {
var delay = 0; var delay = 0;
if (timeout_or_not_timeout) { if (timeout_or_not_timeout) {
delay = priv.delay; delay = priv.delay;
} }
window.setTimeout(function () { setTimeout(function () {
that.addJob(that.newStorage(priv.sub_storage_spec), that.addJob(that.newStorage(priv.sub_storage_spec), command);
command); that.end();
that.end(); }, delay);
}, delay); };
};
that.saveDocument = function (command) { that.saveDocument = function (command) {
priv.doJob(command, priv.save); priv.doJob(command, priv.save);
}; };
// end saveDocument // end saveDocument
that.loadDocument = function (command) { that.loadDocument = function (command) {
priv.doJob(command, priv.load); priv.doJob(command, priv.load);
}; };
// end loadDocument // end loadDocument
that.getDocumentList = function (command) { that.getDocumentList = function (command) {
priv.doJob(command, priv.getlist); priv.doJob(command, priv.getlist);
}; };
// end getDocumentList // end getDocumentList
that.removeDocument = function (command) { that.removeDocument = function (command) {
priv.doJob(command, priv.remove); priv.doJob(command, priv.remove);
}; };
// end removeDocument // end removeDocument
return that; return that;
};
jIO.addStorageType('wait', newWaitStorage);
}; };
if (window.requirejs) { jIO.addStorageType('wait', newWaitStorage);
define('JIOWaitStorages', ['jIO'], jioWaitStorageLoader); };
} else {
jioWaitStorageLoader(jIO); if (window.requirejs) {
} define('JIOWaitStorages', ['jIO'], jioWaitStorageLoader);
} else {
jioWaitStorageLoader(jIO);
}
} }
()); ());
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment