2
Fork 0

some white space and comma fixes

This commit is contained in:
Willem 2016-11-20 16:11:05 +01:00
parent 8586667828
commit d4f681e28c

View file

@ -26,7 +26,7 @@
/** /**
* FFSpaLoader is an assets loader for single page applications. * FFSpaLoader is an assets loader for single page applications.
* Its build around the concept the there is only a single static index.html which * Its build around the concept the there is only a single static index.html which
* synces all its assets to local cache for offline use and or fast page loads. * synces all its assets to local cache for offline use and or fast page loads.
* *
* @module FFSpaLoader * @module FFSpaLoader
*/ */
@ -115,14 +115,14 @@
progres: { progres: {
items: { items: {
enable: true, enable: true,
size: 50, size: 50
}, },
bar: { bar: {
enable: true, enable: true,
percentage: true, percentage: true
} }
}, },
delayDss: false, // TODO: move to cache type options delayDss: false // TODO: move to cache type options
}, },
cache: { cache: {
meta: null, meta: null,
@ -196,7 +196,7 @@
cacheGetValue: function(key, cb) { cacheGetValue: function(key, cb) {
try { try {
var dataRaw = rootWindow.localStorage.getItem(key); var dataRaw = rootWindow.localStorage.getItem(key);
var data = JSON.parse(dataRaw); var data = JSON.parse(dataRaw);
cb(null, data); cb(null, data);
} catch(e) { } catch(e) {
cb(e); cb(e);
@ -287,7 +287,7 @@
executeSql(tx, 'SELECT value FROM '+opt.table+' WHERE key = ?',[key], function(tx, res) { executeSql(tx, 'SELECT value FROM '+opt.table+' WHERE key = ?',[key], function(tx, res) {
if (res.rows.length === 0) { if (res.rows.length === 0) {
var queryInsert = 'INSERT INTO '+opt.table+' (key,value) VALUES (?,?)'; var queryInsert = 'INSERT INTO '+opt.table+' (key,value) VALUES (?,?)';
executeSql(tx, queryInsert, [key,JSON.stringify(value)], nullDataHandler(cb), cb); executeSql(tx, queryInsert, [key,JSON.stringify(value)], nullDataHandler(cb), cb);
} else { } else {
var queryUpdate = 'UPDATE '+opt.table+' SET value = ? WHERE key = ?'; var queryUpdate = 'UPDATE '+opt.table+' SET value = ? WHERE key = ?';
executeSql(tx, queryUpdate, [JSON.stringify(value),key], nullDataHandler(cb), cb); executeSql(tx, queryUpdate, [JSON.stringify(value),key], nullDataHandler(cb), cb);
@ -301,7 +301,7 @@
}); });
} }
}; };
}, }
} }
}; };
@ -324,7 +324,7 @@
titleTag.setAttribute('class','ffTitle'); titleTag.setAttribute('class','ffTitle');
titleTag.appendChild(document.createTextNode(options.boot.error.title+err.name)); titleTag.appendChild(document.createTextNode(options.boot.error.title+err.name));
rootTag.appendChild(titleTag); rootTag.appendChild(titleTag);
var dialogTag = document.createElement('div'); var dialogTag = document.createElement('div');
dialogTag.setAttribute('class','ffError'); dialogTag.setAttribute('class','ffError');
rootTag.appendChild(dialogTag); rootTag.appendChild(dialogTag);
@ -332,7 +332,7 @@
var questionTag = document.createElement('p'); var questionTag = document.createElement('p');
questionTag.appendChild(document.createTextNode(err.message)); questionTag.appendChild(document.createTextNode(err.message));
dialogTag.appendChild(questionTag); dialogTag.appendChild(questionTag);
try { try {
var stack = err.stack || ''; var stack = err.stack || '';
stack = stack.split('\n').map(function (line) { return line.trim()+'\n'; }); stack = stack.split('\n').map(function (line) { return line.trim()+'\n'; });
@ -440,12 +440,12 @@
options.server.url = options.server.url.substring(0,options.server.url.indexOf(options.server.depath) - 1); options.server.url = options.server.url.substring(0,options.server.url.indexOf(options.server.depath) - 1);
} }
if (options.server.url.indexOf('file://') === 0) { if (options.server.url.indexOf('file://') === 0) {
utilDebug('start server.url cleared because is file uri'); utilDebug('start server.url cleared because is file uri');
options.server.url = null; options.server.url = null;
} }
utilDebug('start cleaned server.url \"'+options.server.url+'\" from \"'+serverUrlOrg+'\"'); utilDebug('start cleaned server.url \"'+options.server.url+'\" from \"'+serverUrlOrg+'\"');
}; };
var cacheGetService = function (type) { var cacheGetService = function (type) {
if (options.cache[type]) { if (options.cache[type]) {
return options.cache[type]; return options.cache[type];
@ -456,7 +456,7 @@
var cacheHasService = function (type) { var cacheHasService = function (type) {
return cacheGetService(type) !== null; return cacheGetService(type) !== null;
}; };
var cacheCheckType = function (type, cb, action) { var cacheCheckType = function (type, cb, action) {
if (cacheHasService(type)) { if (cacheHasService(type)) {
action(); action();
@ -476,7 +476,7 @@
cacheCheckType(type, cb, function() { cacheCheckType(type, cb, function() {
var cacheKey = type+'_'+key; var cacheKey = type+'_'+key;
utilDebug('cacheGetValue key '+cacheKey); utilDebug('cacheGetValue key '+cacheKey);
cacheGetService(type).cacheGetValue(cacheKey,cb); cacheGetService(type).cacheGetValue(cacheKey,cb);
}); });
}; };
@ -492,7 +492,7 @@
cacheCheckType(type, cb, function() { cacheCheckType(type, cb, function() {
var cacheKey = type+'_'+key; var cacheKey = type+'_'+key;
utilDebug('cacheSetValue key '+cacheKey); utilDebug('cacheSetValue key '+cacheKey);
cacheGetService(type).cacheSetValue(cacheKey,value,cb); cacheGetService(type).cacheSetValue(cacheKey,value,cb);
}); });
}; };
@ -507,7 +507,7 @@
cacheCheckType(type, cb, function() { cacheCheckType(type, cb, function() {
var cacheKey = type+'_'+key; var cacheKey = type+'_'+key;
utilDebug('cacheDeleteValue key '+cacheKey); utilDebug('cacheDeleteValue key '+cacheKey);
cacheGetService(type).cacheDeleteValue(cacheKey,cb); cacheGetService(type).cacheDeleteValue(cacheKey,cb);
}); });
}; };
@ -550,9 +550,7 @@
if (keyIdx !== -1) { if (keyIdx !== -1) {
valueNew.splice(keyIdx,1); valueNew.splice(keyIdx,1);
} }
} }
//utilDebug('cleanupCache value1: '+JSON.stringify(value));
//utilDebug('cleanupCache value2: '+JSON.stringify(valueNew));
utilRunStack('cleanupCacheItems',diff, function(key, cb) { utilRunStack('cleanupCacheItems',diff, function(key, cb) {
cacheDeleteValue(typeKey.type,key,cb); cacheDeleteValue(typeKey.type,key,cb);
@ -566,7 +564,7 @@
cacheSetValue(typeKey.type,'keys',valueNew ,cb); cacheSetValue(typeKey.type,'keys',valueNew ,cb);
} }
}); });
}); });
}, cb); }, cb);
}; };
@ -588,7 +586,7 @@
document.getElementsByTagName('head')[0].appendChild(tag); document.getElementsByTagName('head')[0].appendChild(tag);
//var ref = document.getElementsByTagName('script')[0]; //var ref = document.getElementsByTagName('script')[0];
//ref.parentNode.insertBefore(tag, ref); // note in reverse order //ref.parentNode.insertBefore(tag, ref); // note in reverse order
cb(null); cb(null);
}; };
@ -791,7 +789,7 @@
cb(new Error('No assets')); cb(new Error('No assets'));
return; return;
} }
rootWindow[options.server.flag] = options.server.url; rootWindow[options.server.flag] = options.server.url;
var resourcesUrl = options.server.url + options.server.assets; var resourcesUrl = options.server.url + options.server.assets;
utilDebug('startLoader assets \"'+resourcesUrl+'\"'); utilDebug('startLoader assets \"'+resourcesUrl+'\"');
@ -849,7 +847,7 @@
if (err === null) { if (err === null) {
cleanupCache(resources,false,cb); // only clean when fetched + cached cleanupCache(resources,false,cb); // only clean when fetched + cached
} else { } else {
cb(err); cb(err);
} }
}); });
}); });
@ -887,9 +885,9 @@
var inputValueHost = null; var inputValueHost = null;
if (inputValueRaw.indexOf("://") >= 0) { if (inputValueRaw.indexOf("://") >= 0) {
inputValueHost = inputValueRaw.split('/')[2]; inputValueHost = inputValueRaw.split('/')[2];
} else { } else {
inputValueHost = inputValueRaw.split('/')[0]; inputValueHost = inputValueRaw.split('/')[0];
} }
var inputValuePath = inputValueRaw.split(inputValueHost)[1]; var inputValuePath = inputValueRaw.split(inputValueHost)[1];
if (options.question.validate.min.value !== false && inputValueHost.length < options.question.validate.min.value) { if (options.question.validate.min.value !== false && inputValueHost.length < options.question.validate.min.value) {
@ -920,7 +918,7 @@
utilCleanServerUrl(); utilCleanServerUrl();
var resourcesUrl = options.server.url + options.server.assets; var resourcesUrl = options.server.url + options.server.assets;
utilDebug('askUrlStart check assets '+resourcesUrl); utilDebug('askUrlStart check assets '+resourcesUrl);
utilHttpFetch(resourcesUrl,function(err, httpRequest) { utilHttpFetch(resourcesUrl,function(err, httpRequest) {
@ -975,7 +973,7 @@
var questionTag = document.createElement('div'); var questionTag = document.createElement('div');
questionTag.setAttribute('class','ffQuestionText'); questionTag.setAttribute('class','ffQuestionText');
questionTag.appendChild(document.createTextNode(options.question.text)); questionTag.appendChild(document.createTextNode(options.question.text));
formTag.appendChild(questionTag); formTag.appendChild(questionTag);
var inputTag = document.createElement('input'); var inputTag = document.createElement('input');
inputTag.setAttribute('type','text'); inputTag.setAttribute('type','text');