JSLint clean JavaScript sources. No fatal errors remain. Options can turn off rest of warnings

This commit is contained in:
paulb777
2011-02-02 08:46:19 -08:00
committed by Fil Maj
parent 5e858f8bc3
commit 6f4673f590
18 changed files with 503 additions and 471 deletions
+37 -33
View File
@@ -45,7 +45,7 @@ DroidDB.prototype.completeQuery = function(id, data) {
r.rows.resultSet = data;
r.rows.length = data.length;
try {
if (typeof query.successCallback == 'function') {
if (typeof query.successCallback === 'function') {
query.successCallback(query.tx, r);
}
} catch (ex) {
@@ -83,7 +83,7 @@ DroidDB.prototype.fail = function(reason, id) {
tx.queryList = {};
try {
if (typeof query.errorCallback == 'function') {
if (typeof query.errorCallback === 'function') {
query.errorCallback(query.tx, reason);
}
} catch (ex) {
@@ -99,6 +99,24 @@ DroidDB.prototype.fail = function(reason, id) {
}
};
/**
* Transaction object
* PRIVATE METHOD
*/
var DroidDB_Tx = function() {
// Set the id of the transaction
this.id = PhoneGap.createUUID();
// Callbacks
this.successCallback = null;
this.errorCallback = null;
// Query list
this.queryList = {};
};
var DatabaseShell = function() {
};
@@ -128,22 +146,6 @@ DatabaseShell.prototype.transaction = function(process, errorCallback, successCa
}
};
/**
* Transaction object
* PRIVATE METHOD
*/
var DroidDB_Tx = function() {
// Set the id of the transaction
this.id = PhoneGap.createUUID();
// Callbacks
this.successCallback = null;
this.errorCallback = null;
// Query list
this.queryList = {};
};
/**
* Mark query in transaction as complete.
@@ -157,10 +159,13 @@ DroidDB_Tx.prototype.queryComplete = function(id) {
// If no more outstanding queries, then fire transaction success
if (this.successCallback) {
var count = 0;
for (var i in this.queryList) {
count++;
var i;
for (i in this.queryList) {
if (this.queryList.hasOwnProperty(i)) {
count++;
}
}
if (count == 0) {
if (count === 0) {
try {
this.successCallback();
} catch(e) {
@@ -220,7 +225,7 @@ var DroidDB_Query = function(tx) {
this.successCallback = null;
this.errorCallback = null;
}
};
/**
* Execute SQL statement
@@ -233,7 +238,7 @@ var DroidDB_Query = function(tx) {
DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCallback) {
// Init params array
if (typeof params == 'undefined') {
if (typeof params === 'undefined') {
params = [];
}
@@ -304,10 +309,11 @@ var CupcakeLocalStorage = function() {
var storage = {};
this.db.transaction(
function (transaction) {
var i;
transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
transaction.executeSql('SELECT * FROM storage', [], function(tx, result) {
for(var i = 0; i < result.rows.length; i++) {
storage[result.rows.item(i)['id']] = result.rows.item(i)['body'];
for(i = 0; i < result.rows.length; i++) {
storage[result.rows.item(i).id] = result.rows.item(i).body;
}
PhoneGap.initializationComplete("cupcakeStorage");
});
@@ -328,10 +334,10 @@ var CupcakeLocalStorage = function() {
transaction.executeSql('REPLACE INTO storage (id, body) values(?,?)', [key,val]);
}
);
}
};
this.getItem = function(key) {
return storage[key];
}
};
this.removeItem = function(key) {
delete storage[key];
this.db.transaction(
@@ -341,8 +347,7 @@ var CupcakeLocalStorage = function() {
transaction.executeSql('DELETE FROM storage where id=?', [key]);
}
);
}
};
this.clear = function() {
storage = {};
this.db.transaction(
@@ -352,20 +357,19 @@ var CupcakeLocalStorage = function() {
transaction.executeSql('DELETE FROM storage', []);
}
);
}
};
} catch(e) {
alert("Database error "+e+".");
return;
}
};
PhoneGap.addConstructor(function() {
if (typeof window.openDatabase == "undefined") {
if (typeof window.openDatabase === "undefined") {
navigator.openDatabase = window.openDatabase = DroidDB_openDatabase;
window.droiddb = new DroidDB();
}
if (typeof window.localStorage == "undefined") {
if (typeof window.localStorage === "undefined") {
navigator.localStorage = window.localStorage = new CupcakeLocalStorage();
PhoneGap.waitForInitialization("cupcakeStorage");
}