clearup some old if statements
This commit is contained in:
parent
6d9869fb85
commit
25e2e4bcd0
|
@ -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)
|
* 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.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.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.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.transport = The transport to prefix the server.url with. (default: 'http://')
|
||||||
* server.question.title = The question ui title. (default: 'Server')
|
* server.question.title = The question ui title. (default: 'Server')
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
localStorage: function() {
|
localStorage: function() {
|
||||||
try {
|
try {
|
||||||
var testData = 'localStorageDetect';
|
var testData = 'localStorageDetect';
|
||||||
rootWindow.localStorage.setItem(testData, testData);
|
rootWindow.localStorage.setItem(testData, testData); // throws err in private browsing mode
|
||||||
rootWindow.localStorage.removeItem(testData);
|
rootWindow.localStorage.removeItem(testData);
|
||||||
return true;
|
return true;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
@ -180,10 +180,13 @@
|
||||||
return {
|
return {
|
||||||
cacheOpen: function(cb) {
|
cacheOpen: function(cb) {
|
||||||
if (cacheDB !== null) {
|
if (cacheDB !== null) {
|
||||||
cb(null); // open once.
|
return cb(null); // open once.
|
||||||
return;
|
}
|
||||||
|
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) {
|
cacheDB.transaction(function(tx) {
|
||||||
var query = 'SELECT value FROM cache_store WHERE key = \"test-for-table\"';
|
var query = 'SELECT value FROM cache_store WHERE key = \"test-for-table\"';
|
||||||
utilDebug('websql.cacheOpen query '+query);
|
utilDebug('websql.cacheOpen query '+query);
|
||||||
|
@ -455,7 +458,7 @@
|
||||||
utilDebug('injectResources');
|
utilDebug('injectResources');
|
||||||
resources.forEach(function (resource) {
|
resources.forEach(function (resource) {
|
||||||
cacheGetValue(resource.type,resource.hash,function(err,item) {
|
cacheGetValue(resource.type,resource.hash,function(err,item) {
|
||||||
// TODO injectResourceData
|
// TODO reuse injectResourceData
|
||||||
|
|
||||||
var tag = null;
|
var tag = null;
|
||||||
if (resource.type === 'css' || resource.type === 'cssData') {
|
if (resource.type === 'css' || resource.type === 'cssData') {
|
||||||
|
@ -549,10 +552,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
options.server.url = '';
|
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 += options.server.question.transport;
|
||||||
}
|
}
|
||||||
options.server.url += inputTag.value;
|
options.server.url += inputTag.value;
|
||||||
|
// TODO: auto rm ending /
|
||||||
|
|
||||||
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);
|
||||||
|
@ -608,12 +612,11 @@
|
||||||
var formTag = document.createElement('div');
|
var formTag = document.createElement('div');
|
||||||
rootTag.appendChild(formTag);
|
rootTag.appendChild(formTag);
|
||||||
|
|
||||||
if (options.server.question.transport !== undefined) {
|
var transportTag = document.createElement('label');
|
||||||
var transportTag = document.createElement('label');
|
rootTag.setAttribute('for','serverInput');
|
||||||
rootTag.setAttribute('for','serverInput');
|
transportTag.appendChild(document.createTextNode(options.server.question.transport));
|
||||||
transportTag.appendChild(document.createTextNode(options.server.question.transport));
|
formTag.appendChild(transportTag);
|
||||||
formTag.appendChild(transportTag);
|
|
||||||
}
|
|
||||||
var inputTag = document.createElement('input');
|
var inputTag = document.createElement('input');
|
||||||
inputTag.type = 'text';
|
inputTag.type = 'text';
|
||||||
inputTag.id = 'serverInput';
|
inputTag.id = 'serverInput';
|
||||||
|
@ -781,11 +784,13 @@
|
||||||
utilDebug('bootCordova done in '+(new Date().getTime()-startTime)+' ms.');
|
utilDebug('bootCordova done in '+(new Date().getTime()-startTime)+' ms.');
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
utilDebug('bootCordova timeout '+options.boot.cordova.timeout);
|
if (options.boot.cordova.timeout > 0) {
|
||||||
setTimeout ( function () {
|
utilDebug('bootCordova timeout '+options.boot.cordova.timeout);
|
||||||
utilDebug('bootCordova timeout');
|
setTimeout ( function () {
|
||||||
bootOnce();
|
utilDebug('bootCordova timeout');
|
||||||
}, options.boot.cordova.timeout);
|
bootOnce();
|
||||||
|
}, options.boot.cordova.timeout);
|
||||||
|
}
|
||||||
document.addEventListener("deviceready", function () {
|
document.addEventListener("deviceready", function () {
|
||||||
rootWindow[options.boot.cordova.flag] = true;
|
rootWindow[options.boot.cordova.flag] = true;
|
||||||
utilDebug('bootCordova '+options.boot.cordova.flag);
|
utilDebug('bootCordova '+options.boot.cordova.flag);
|
||||||
|
|
Loading…
Reference in a new issue