Skip to content

Commit ca768c1

Browse files
author
Parashuram N
committed
Commit from Travis Build #13
Build - https://travis-ci.org/axemclion/jquery-indexeddb/builds/3356332 Branch : master@ c9f5c55
2 parents f3bbc2c + c9f5c55 commit ca768c1

File tree

2 files changed

+56
-55
lines changed

2 files changed

+56
-55
lines changed

grunt.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,13 @@ module.exports = function(grunt){
114114
});
115115

116116
var testJobs = ["build", "server"];
117-
if (saucekey !== null) {
118-
testJobs.push("saucelabs-qunit");
119-
}
120117
if (process.env.CI && process.env.TRAVIS) {
118+
if (saucekey !== null) {
119+
testJobs.push("saucelabs-qunit");
120+
}
121121
testJobs.push("publish");
122122
}
123123

124124
grunt.registerTask('test', testJobs.join(" "));
125-
126125
grunt.registerTask('default', 'build');
127126
};

jquery.indexeddb.js

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;
44
var IDBCursor = window.IDBCursor || window.webkitIDBCursor;
55
IDBCursor.PREV = IDBCursor.PREV || "prev";
6-
IDBCursor.NEXT = IDBCursor.PREV || "next";
6+
IDBCursor.NEXT = IDBCursor.NEXT || "next";
77

88
/**
99
* Best to use the constant IDBTransaction since older version support numeric types while the latest spec
@@ -56,18 +56,19 @@
5656
try {
5757
var idbRequest = typeof req === "function" ? req(args) : req;
5858
idbRequest.onsuccess = function(e){
59-
console.log("Success", idbRequest, e, this);
59+
//console.log("Success", idbRequest, e, this);
6060
dfd.resolveWith(idbRequest, [idbRequest.result, e]);
6161
};
6262
idbRequest.onerror = function(e){
63-
console.log("Error", idbRequest, e, this);
63+
//console.log("Error", idbRequest, e, this);
6464
dfd.rejectWith(idbRequest, [idbRequest.error, e]);
6565
};
6666
if (typeof idbRequest.onblocked !== "undefined" && idbRequest.onblocked === null) {
6767
idbRequest.onblocked = function(e){
68-
console.log("Blocked", idbRequest, e, this);
68+
//console.log("Blocked", idbRequest, e, this);
69+
var res;
6970
try {
70-
var res = idbRequest.result;
71+
res = idbRequest.result;
7172
} catch (e) {
7273
res = null; // Required for Older Chrome versions, accessing result causes error
7374
}
@@ -76,7 +77,7 @@
7677
}
7778
if (typeof idbRequest.onupgradeneeded !== "undefined" && idbRequest.onupgradeneeded === null) {
7879
idbRequest.onupgradeneeded = function(e){
79-
console.log("Upgrade", idbRequest, e, this);
80+
//console.log("Upgrade", idbRequest, e, this);
8081
dfd.notifyWith(idbRequest, [idbRequest.result, e]);
8182
};
8283
}
@@ -126,7 +127,7 @@
126127
return wrap.request(function(args){
127128
return idbObjectStore[op].apply(idbObjectStore, args);
128129
}, arguments);
129-
}
130+
};
130131
})(crudOps[i]);
131132
}
132133

@@ -148,7 +149,7 @@
148149

149150
result.createIndex = function(prop, options, indexName){
150151
if (arguments.length === 2 && typeof options === "string") {
151-
indexName = arguments[1]
152+
indexName = arguments[1];
152153
options = null;
153154
}
154155
if (!indexName) {
@@ -161,7 +162,7 @@
161162

162163
result.deleteIndex = function(indexName){
163164
return idbObjectStore.deleteIndex(indexName);
164-
}
165+
};
165166

166167
return result;
167168
},
@@ -183,10 +184,10 @@
183184
"cursor": function(idbCursor, callback){
184185
return $.Deferred(function(dfd){
185186
try {
186-
console.log("Cursor request created", idbCursor);
187+
//console.log("Cursor request created", idbCursor);
187188
var cursorReq = typeof idbCursor === "function" ? idbCursor() : idbCursor;
188189
cursorReq.onsuccess = function(e){
189-
console.log("Cursor successful");
190+
//console.log("Cursor successful");
190191
if (!cursorReq.result) {
191192
dfd.resolveWith(cursorReq, [null, e]);
192193
return;
@@ -209,10 +210,10 @@
209210
"key": cursorReq.result.key,
210211
"value": cursorReq.result.value
211212
};
212-
console.log("Cursor in progress", elem, e);
213+
//console.log("Cursor in progress", elem, e);
213214
dfd.notifyWith(cursorReq, [elem, e]);
214215
var result = callback.apply(cursorReq, [elem]);
215-
console.log("Iteration function returned", result);
216+
//console.log("Iteration function returned", result);
216217
try {
217218
if (result === false) {
218219
dfd.resolveWith(cursorReq, [null, e]);
@@ -223,16 +224,16 @@
223224
else cursorReq.result["continue"]();
224225
}
225226
} catch (e) {
226-
console.log("Exception when trying to advance cursor", cursorReq, e);
227+
//console.log("Exception when trying to advance cursor", cursorReq, e);
227228
dfd.rejectWith(cursorReq, [cursorReq.result, e]);
228229
}
229230
};
230231
cursorReq.onerror = function(e){
231-
console.log("Cursor request errored out", e);
232+
//console.log("Cursor request errored out", e);
232233
dfd.rejectWith(cursorReq, [cursorReq.result, e]);
233234
};
234235
} catch (e) {
235-
console.log("An exception occured inside cursor", cursorReq, e)
236+
//console.log("An exception occured inside cursor", cursorReq, e);
236237
e.type = "exception";
237238
dfd.rejectWith(cursorReq, [null, e]);
238239
}
@@ -245,7 +246,7 @@
245246
} catch (e) {
246247
idbIndex = null;
247248
}
248-
//console.logidbIndex, index);
249+
////console.logidbIndex, index);
249250
return {
250251
"each": function(callback, range, direction){
251252
return wrap.cursor(function(){
@@ -282,7 +283,7 @@
282283
}
283284
};
284285
}
285-
}
286+
};
286287

287288
////////////////////////////////////////////////////////////////////////////////////////////////////
288289

@@ -331,13 +332,13 @@
331332
callback("onupgradeneeded", result, [event]);
332333
// Version transaction is now complete, to open ordinary transaction
333334
versionReq.result.db.close();
334-
console.log("Database closed, and will try to open again, with same version");
335+
//console.log("Database closed, and will try to open again, with same version");
335336
var newDbOpenReq = indexedDB.open(dbName);
336337
delete result.transaction;
337338
delete result.result;
338339

339340
newDbOpenReq.onsuccess = function(e){
340-
console.log("DB Opened without version change", newDbOpenReq.result);
341+
//console.log("DB Opened without version change", newDbOpenReq.result);
341342
copyReq(newDbOpenReq);
342343
callback("onsuccess", result, [e], function(){
343344
newDbOpenReq.result.close();
@@ -347,15 +348,15 @@
347348
newDbOpenReq.onerror = function(e){
348349
copyReq(newDbOpenReq);
349350
callback("onerror", result, [e], function(){
350-
console.log("Closed database in newRequest on error", newDbOpenReq);
351+
//console.log("Closed database in newRequest on error", newDbOpenReq);
351352
newDbOpenReq.result.close();
352353
});
353354
};
354355
newDbOpenReq.onblocked = function(e){
355-
console.log("DB Blocked without version change", newDbOpenReq.result);
356+
//console.log("DB Blocked without version change", newDbOpenReq.result);
356357
copyReq(newDbOpenReq);
357358
callback("onblocked", result, [e], function(){
358-
console.log("Closed database in newRequest on blocked", newDbOpenReq);
359+
//console.log("Closed database in newRequest on blocked", newDbOpenReq);
359360
newDbOpenReq.result.close();
360361
});
361362
};
@@ -366,7 +367,7 @@
366367
};
367368
versionReq.onblocked = function(e){
368369
// This always gets called, resulting the blocking the DB upgrade
369-
console.log("Version transaction blocked, so calling the on blocked method");
370+
//console.log("Version transaction blocked, so calling the on blocked method");
370371
callback("onblocked", result, [e]);
371372
};
372373
} else if (oldVersion === newVersion) {
@@ -382,7 +383,7 @@
382383
};
383384
dbOpenReq.onerror = function(e){
384385
copyReq();
385-
console.log("Error", dbOpenReq);
386+
//console.log("Error", dbOpenReq);
386387
callback("onerror", result, [e]);
387388
};
388389
dbOpenReq.onblocked = function(e){
@@ -397,33 +398,33 @@
397398
};
398399

399400
return result;
400-
}
401+
};
401402

402403

403404
////////////////////////////////////////////////////////////////////////////////////////////////////
404405

405406

406407
// Start with opening the database
407408
var dbPromise = wrap.request(function(){
408-
console.log("Trying to open DB with", version);
409+
//console.log("Trying to open DB with", version);
409410
return version ? openReqShim(dbName, version) : openReqShim(dbName);
410411
});
411412
dbPromise.then(function(db, e){
412-
console.log("DB opened at", db.version);
413+
//console.log("DB opened at", db.version);
413414
db.onversionchange = function(){
414415
// Try to automatically close the database if there is a version change request
415416
if (!(config && config.onversionchange && config.onversionchange() !== false)) {
416417
db.close();
417418
}
418419
};
419420
}, function(error, e){
420-
//console.logerror, e);
421+
////console.logerror, e);
421422
// Nothing much to do if an error occurs
422423
}, function(db, e){
423424
if (e && e.type === "upgradeneeded") {
424425
if (config && config.schema) {
425426
// Assuming that version is always an integer
426-
console.log("Upgrading DB to ", db.version);
427+
//console.log("Upgrading DB to ", db.version);
427428
for (var i = e.oldVersion + 1; i <= e.newVersion; i++) {
428429
typeof config.schema[i] === "function" && config.schema[i].call(this, wrap.transaction(this.transaction));
429430
}
@@ -465,18 +466,19 @@
465466
mode = getDefaultTransaction(mode);
466467
return $.Deferred(function(dfd){
467468
dbPromise.then(function(db, e){
469+
var idbTransaction;
468470
try {
469-
console.log("DB Opened, now trying to create a transaction", storeNames, mode);
470-
var idbTransaction = db.transaction(storeNames, mode);
471-
console.log("Created a transaction", idbTransaction, mode, storeNames);
471+
//console.log("DB Opened, now trying to create a transaction", storeNames, mode);
472+
idbTransaction = db.transaction(storeNames, mode);
473+
//console.log("Created a transaction", idbTransaction, mode, storeNames);
472474
idbTransaction.onabort = idbTransaction.onerror = function(e){
473475
dfd.rejectWith(idbTransaction, [e]);
474476
};
475477
idbTransaction.oncomplete = function(e){
476478
dfd.resolveWith(idbTransaction, [e]);
477479
};
478480
} catch (e) {
479-
console.log("Creating a traction failed", e, storeNames, mode, this);
481+
//console.log("Creating a traction failed", e, storeNames, mode, this);
480482
e.type = "exception";
481483
dfd.rejectWith(this, [e]);
482484
return;
@@ -490,7 +492,7 @@
490492
}, function(err, e){
491493
dfd.rejectWith(this, [e, err]);
492494
}, function(res, e){
493-
console.log("Database open is blocked or upgrade needed", res, e.type);
495+
//console.log("Database open is blocked or upgrade needed", res, e.type);
494496
//dfd.notifyWith(this, ["", e]);
495497
});
496498

@@ -503,74 +505,74 @@
503505
return $.Deferred(function(dfd){
504506
function onTransactionProgress(trans, callback){
505507
try {
506-
console.log("Finally, returning the object store", trans);
508+
//console.log("Finally, returning the object store", trans);
507509
callback(trans.objectStore(storeName)).then(function(result, e){
508510
dfd.resolveWith(this, [result, e]);
509511
}, function(err, e){
510512
dfd.rejectWith(this, [err, e]);
511513
});
512514
} catch (e) {
513-
console.log("Duh, an exception occured", e);
515+
//console.log("Duh, an exception occured", e);
514516
e.name = "exception";
515517
dfd.rejectWith(trans, [e, e]);
516518
}
517519
}
518520
me.transaction(storeName, getDefaultTransaction(mode)).then(function(){
519-
console.log("Transaction completed");
521+
//console.log("Transaction completed");
520522
// Nothing to do when transaction is complete
521523
}, function(err, e){
522524
// If transaction fails, CrudOp fails
523525
if (err.code === err.NOT_FOUND_ERR && (mode === true || typeof mode === "object")) {
524-
console.log("Object Not found, so will try to create one now");
526+
//console.log("Object Not found, so will try to create one now");
525527
var db = this.result;
526528
db.close();
527529
dbPromise = wrap.request(function(){
528-
console.log("Now trying to open the database again", db.version);
530+
//console.log("Now trying to open the database again", db.version);
529531
return openReqShim(dbName, (parseInt(db.version, 10) || 1) + 1);
530532
});
531533
dbPromise.then(function(db, e){
532-
console.log("Database opened, tto open transaction", db.version);
534+
//console.log("Database opened, tto open transaction", db.version);
533535
db.onversionchange = function(){
534536
// Try to automatically close the database if there is a version change request
535537
if (!(config && config.onversionchange && config.onversionchange() !== false)) {
536538
db.close();
537539
}
538540
};
539541
me.transaction(storeName, getDefaultTransaction(mode)).then(function(){
540-
console.log("Transaction completed when trying to create object store");
542+
//console.log("Transaction completed when trying to create object store");
541543
// Nothing much to do
542544
}, function(err, e){
543545
dfd.rejectWith(this, [err, e]);
544546
}, function(trans, e){
545-
console.log("Transaction in progress, when object store was not found", this, trans, e);
547+
//console.log("Transaction in progress, when object store was not found", this, trans, e);
546548
onTransactionProgress(trans, callback);
547549
});
548550
}, function(err, e){
549551
dfd.rejectWith(this, [err, e]);
550552
}, function(db, e){
551553
if (e.type === "upgradeneeded") {
552554
try {
553-
console.log("Now trying to create an object store", e.type);
555+
//console.log("Now trying to create an object store", e.type);
554556
db.createObjectStore(storeName, mode === true ? {
555557
"autoIncrement": true
556558
} : mode);
557-
console.log("Object store created", storeName, db);
559+
//console.log("Object store created", storeName, db);
558560
} catch (ex) {
559-
console.log("Exception when trying ot create a new object store", ex)
561+
//console.log("Exception when trying ot create a new object store", ex);
560562
dfd.rejectWith(this, [ex, e]);
561563
}
562564
}
563565
});
564566
} else {
565-
console.log("Error in transaction inside object store", err);
567+
//console.log("Error in transaction inside object store", err);
566568
dfd.rejectWith(this, [err, e]);
567569
}
568570
}, function(trans){
569-
console.log("Transaction is in progress", trans);
571+
//console.log("Transaction is in progress", trans);
570572
onTransactionProgress(trans, callback);
571573
});
572574
});
573-
};
575+
}
574576

575577
function crudOp(opName, args){
576578
return op(function(wrappedObjectStore){
@@ -590,7 +592,7 @@
590592
result[crud[i]] = (function(op){
591593
return function(){
592594
return crudOp(op, arguments);
593-
}
595+
};
594596
})(crud[i]);
595597
}
596598

@@ -609,7 +611,7 @@
609611
return indexOp("getKey", indexName, [key]);
610612
}
611613
};
612-
}
614+
};
613615

614616
return result;
615617
}

0 commit comments

Comments
 (0)