2
0
Fork 0

clearup some old if statements

This commit is contained in:
Willem 2016-01-18 22:41:52 +01:00
parent 6d9869fb85
commit 25e2e4bcd0
2 changed files with 23 additions and 18 deletions

View file

@ -84,7 +84,7 @@ A javascript library providing server defined loading of assets for a single pag
* boot.angular.modules = The angular modules to boot. (default: empty)
* server.url = The server url like 'https://myhost', when null the user will get promted to input it. (default: null)
* server.assets = The server path to the assets resources definition file, is required (default: null)
* server.timeout = The timeout to download the server resources.
* server.timeout = The timeout to download the server resources. (default: 4096)
* server.flag = The window flag which is set when the server.url is know. (default: 'FFServerUrl')
* server.question.transport = The transport to prefix the server.url with. (default: 'http://')
* server.question.title = The question ui title. (default: 'Server')

View file

@ -97,7 +97,7 @@
localStorage: function() {
try {
var testData = 'localStorageDetect';
rootWindow.localStorage.setItem(testData, testData);
rootWindow.localStorage.setItem(testData, testData); // throws err in private browsing mode
rootWindow.localStorage.removeItem(testData);
return true;
} catch(e) {
@ -180,10 +180,13 @@
return {
cacheOpen: function(cb) {
if (cacheDB !== null) {
cb(null); // open once.
return;
return cb(null); // open once.
}
try {
cacheDB = rootWindow.openDatabase(opt.name, opt.version, opt.name, opt.size);
} catch(e) {
return cb(e);
}
cacheDB = rootWindow.openDatabase(opt.name, opt.version, opt.name, opt.size);
cacheDB.transaction(function(tx) {
var query = 'SELECT value FROM cache_store WHERE key = \"test-for-table\"';
utilDebug('websql.cacheOpen query '+query);
@ -455,7 +458,7 @@
utilDebug('injectResources');
resources.forEach(function (resource) {
cacheGetValue(resource.type,resource.hash,function(err,item) {
// TODO injectResourceData
// TODO reuse injectResourceData
var tag = null;
if (resource.type === 'css' || resource.type === 'cssData') {
@ -549,10 +552,11 @@
}
options.server.url = '';
if (options.server.question.transport !== undefined) {
if (inputTag.value.indexOf('http') === -1) {
options.server.url += options.server.question.transport;
}
options.server.url += inputTag.value;
// TODO: auto rm ending /
var resourcesUrl = options.server.url + options.server.assets;
utilDebug('askUrlStart check assets '+resourcesUrl);
@ -608,12 +612,11 @@
var formTag = document.createElement('div');
rootTag.appendChild(formTag);
if (options.server.question.transport !== undefined) {
var transportTag = document.createElement('label');
rootTag.setAttribute('for','serverInput');
transportTag.appendChild(document.createTextNode(options.server.question.transport));
formTag.appendChild(transportTag);
}
var transportTag = document.createElement('label');
rootTag.setAttribute('for','serverInput');
transportTag.appendChild(document.createTextNode(options.server.question.transport));
formTag.appendChild(transportTag);
var inputTag = document.createElement('input');
inputTag.type = 'text';
inputTag.id = 'serverInput';
@ -781,11 +784,13 @@
utilDebug('bootCordova done in '+(new Date().getTime()-startTime)+' ms.');
callback();
};
utilDebug('bootCordova timeout '+options.boot.cordova.timeout);
setTimeout ( function () {
utilDebug('bootCordova timeout');
bootOnce();
}, options.boot.cordova.timeout);
if (options.boot.cordova.timeout > 0) {
utilDebug('bootCordova timeout '+options.boot.cordova.timeout);
setTimeout ( function () {
utilDebug('bootCordova timeout');
bootOnce();
}, options.boot.cordova.timeout);
}
document.addEventListener("deviceready", function () {
rootWindow[options.boot.cordova.flag] = true;
utilDebug('bootCordova '+options.boot.cordova.flag);