Skip to content

Commit

Permalink
trying to push github from travis
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristof degrave committed Oct 21, 2015
1 parent 6883bf9 commit 0f9f589
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ deploy:
api_key:
secure: LifWcMvVdfecAE8MwECByqgoJZzjzlbO+0TedFZZ/zP+llfE024QAWluSpL6VrZTvqiAgPUj1M7H2YhxIGfoecnBZSHR+65BMDABFkQ/5Q+yH12iRDLK9bvjr+ToXSe7ia/MAtr08Ma9Z4yCNIOrnb003Liupq/NgNWJL+KQeQk=
file:
- dist\indexeddbmock.js
- dist\indexeddbmock.min.js
- dist\indexedDBmock.js
- dist\indexedDBmock.min.js
on:
tag: false
all_branches: true
Expand Down
113 changes: 83 additions & 30 deletions dist/indexedDBmock.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,40 @@
else {
if (version && connection.version < version) {
setTimeout(function () {
returnObj.target = returnObj;
returnObj.target.readyState = "done";
returnObj.target.type = "upgradeneeded";
returnObj.target.newVersion = version;
returnObj.target.oldVersion = connection.version;
returnObj.target.transaction = new Transaction(null, TransactionTypes.VERSIONCHANGE, new Snapshot(db, connection));

// Upgrade version
returnObj.target.transaction.db.version = version;
connection.version = version;
db.version = version;

if (typeof returnObj.onupgradeneeded === 'function') {
returnObj.onupgradeneeded(returnObj);
returnObj.target.transaction.__commit();
for (var i = 0; i < db.connections.length; i++) {
if (db.connections[i]._connectionId !== connection._connectionId) {
if (typeof db.connections[i].onversionchange === 'function') {
db.connections[i].onversionchange(new IVersionChangeEvent("versionchange", {target: db.connections[i], newVersion: version, oldVersion: db.connections[i].version}));
}
}
}
function upgrade(returnObj, connection, db, version) {
if(db.connections.length > 0 && db.connections[0]._connectionId !== connection._connectionId){
if (typeof returnObj.onblocked === 'function') {
returnObj.onblocked(new IVersionChangeEvent("blocked", {target: db.connections[i], newVersion: null, oldVersion: connection.version}));
}
setTimeout(upgrade, 10, returnObj, connection, db, version);
}

returnObj.target = returnObj;
returnObj.target.readyState = "done";
returnObj.target.type = "upgradeneeded";
returnObj.target.newVersion = version;
returnObj.target.oldVersion = connection.version;
returnObj.target.transaction = new Transaction(null, TransactionTypes.VERSIONCHANGE, new Snapshot(db, connection));

// Upgrade version
returnObj.target.transaction.db.version = version;
connection.version = version;
db.version = version;

if (typeof returnObj.onupgradeneeded === 'function') {
returnObj.onupgradeneeded(returnObj);
returnObj.target.transaction.__commit();
}
}

upgrade(returnObj, connection, db, version);

setTimeout(function () {
if(returnObj.target.transaction._aborted) {
Expand All @@ -85,19 +103,6 @@

returnObj.onsuccess(returnObj);
}

for (var i = 0; i < db.connections.length; i++) {
if (db.connections[i]._connectionId !== connection._connectionId) {
if (typeof db.connections[i].onversionchange === 'function') {
db.connections[i].target = db.connections[i];
db.connections[i].target.readyState = "done";
db.connections[i].target.type = TransactionTypes.VERSIONCHANGE;
db.connections[i].target.version = version;

db.connections[i].onversionchange(db.connections[i]);
}
}
}
}, timeout);
}, timeout);
}
Expand Down Expand Up @@ -244,17 +249,60 @@

this.objectStore = objectStore;
this.__data = {};
}, KeyRange = function(lower, upper, lowerOpen, upperOpen){
},
KeyRange = function(lower, upper, lowerOpen, upperOpen){
this.lower = lower;
this.upper = upper;
this.lowerOpen = lowerOpen ? lowerOpen : false;
this.upperOpen = upperOpen ? upperOpen : false;
},
IEvent = function(type, config){
this.CAPTURING_PHASE = 1;
this.AT_TARGET = 2;
this.BUBBLING_PHASE = 3;

this.bubbles = config.bubbles || false;
this.cancelBubble = (config.bubbles && config.cancelable) || false;
this.cancelable = config.cancelable || false;
this.currentTarget = config.target;
this.defaultPrevented = false;
this.detail = undefined;
this.eventPhase = this.AT_TARGET;
this.path = undefined;
this.returnValue = undefined;
this.srcElement = config.target;
this.target = config.target;
this.timestamp = global.Date.now();
this.type = type;
},
IVersionChangeEvent = function(type, versionChangeInit){
IEvent.call(this, type, {target: versionChangeInit.target});

this.newVersion = versionChangeInit.newVersion;
this.oldVersion = versionChangeInit.oldVersion;
};

IEvent.prototype = (function(){
function preventDefault(){
this.defaultPrevented = true;
}
function stopImmediatePropagation(){
this.cancelBubble = true;
}

return {
preventDefault: preventDefault,
stopImmediatePropagation: stopImmediatePropagation
};
})();

IVersionChangeEvent.prototype = IEvent.prototype;


Connection.prototype = function () {
function close() {
for (var i = 0; i < this._db.connections.length; i++) {
if (this._db.connections[i].connectionId === this._connectionId) {
if (this._db.connections[i]._connectionId === this._connectionId) {
this._db.connections.splice(i, 1);
}
}
Expand Down Expand Up @@ -288,6 +336,9 @@
};
}


// TODO: Check valid key path?

if(parameters && parameters.keyPath instanceof Array)
{
for (var i = 0; i < parameters.keyPath.length; i++){
Expand Down Expand Up @@ -762,6 +813,8 @@

// TODO: Import existing data in the object store

// TODO: Check valid key path?

var index = new Index(name, keyPath, parameters, this);
this._indexes.push(index);
this.indexNames.push(name);
Expand Down
Loading

0 comments on commit 0f9f589

Please sign in to comment.