This commit is contained in:
libccy 2017-04-19 10:23:44 +08:00
parent c38f961608
commit bf8474d7ee
1 changed files with 40 additions and 4 deletions

View File

@ -37,6 +37,8 @@
onphase:[], onphase:[],
onwash:[], onwash:[],
onover:[], onover:[],
ondb:[],
ondb2:[],
chatHistory:[], chatHistory:[],
arenaReady:[], arenaReady:[],
onfree:[], onfree:[],
@ -22445,9 +22447,19 @@
}, },
reload2:function(){ reload2:function(){
lib.status.reload--; lib.status.reload--;
if(_status.waitingToReload&&lib.status.reload==0){ if(lib.status.reload==0&&lib.ondb2.length){
window.location.reload(); var command=lib.ondb2.shift();
delete _status.waitingToReload; game[command[0]].apply(game,command[1]);
}
if(lib.status.reload==0&&lib.ondb.length){
var command=lib.ondb.shift();
game[command[0]].apply(game,command[1]);
}
if(lib.status.reload==0){
if(_status.waitingToReload){
window.location.reload();
delete _status.waitingToReload;
}
} }
}, },
exit:function(){ exit:function(){
@ -26142,11 +26154,17 @@
}, },
putDB:function(type,id,item,callback){ putDB:function(type,id,item,callback){
if(!lib.db) return item; if(!lib.db) return item;
if(lib.status.reload){
lib[_status.dburgent?'ondb2':'ondb'].push(['putDB',Array.from(arguments)]);
return;
}
lib.status.reload++; lib.status.reload++;
var put=lib.db.transaction([type],'readwrite').objectStore(type).put(item,id); var put=lib.db.transaction([type],'readwrite').objectStore(type).put(item,id);
put.onsuccess=function(){ put.onsuccess=function(){
if(callback){ if(callback){
_status.dburgent=true;
callback.apply(this,arguments); callback.apply(this,arguments);
delete _status.dburgent;
} }
game.reload2(); game.reload2();
}; };
@ -26157,10 +26175,18 @@
return; return;
} }
if(!callback) return; if(!callback) return;
if(lib.status.reload){
lib[_status.dburgent?'ondb2':'ondb'].push(['getDB',Array.from(arguments)]);
return;
}
lib.status.reload++;
var store=lib.db.transaction([type],'readwrite').objectStore(type); var store=lib.db.transaction([type],'readwrite').objectStore(type);
if(id){ if(id){
store.get(id).onsuccess=function(e){ store.get(id).onsuccess=function(e){
_status.dburgent=true;
callback(e.target.result); callback(e.target.result);
delete _status.dburgent;
game.reload2();
}; };
} }
else{ else{
@ -26172,7 +26198,10 @@
cursor.continue(); cursor.continue();
} }
else{ else{
_status.dburgent=true;
callback(obj); callback(obj);
delete _status.dburgent;
game.reload2();
} }
} }
} }
@ -26182,6 +26211,10 @@
callback(false); callback(false);
return; return;
} }
if(lib.status.reload){
lib[_status.dburgent?'ondb2':'ondb'].push(['deleteDB',Array.from(arguments)]);
return;
}
lib.status.reload++; lib.status.reload++;
if(arguments.length==1){ if(arguments.length==1){
game.getDB(type,null,function(obj){ game.getDB(type,null,function(obj){
@ -26250,7 +26283,10 @@
config[key]=value; config[key]=value;
} }
config.version=lib.version; config.version=lib.version;
game.putDB('data',mode,config); console.log(key,value);
game.putDB('data',mode,config,function(){
console.log(key,value,2);
});
}); });
} }
else{ else{