This commit is contained in:
parent
5d0507f7ab
commit
bd24fc43e5
59
game/game.js
59
game/game.js
|
@ -6058,6 +6058,9 @@
|
||||||
var stream=response.pipe(file);
|
var stream=response.pipe(file);
|
||||||
stream.on('finish',onsuccess);
|
stream.on('finish',onsuccess);
|
||||||
stream.on('error',onerror);
|
stream.on('error',onerror);
|
||||||
|
stream.on('progress',function(arg1,arg2){
|
||||||
|
console.log(arg1,arg2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},true);
|
},true);
|
||||||
}
|
}
|
||||||
|
@ -6191,6 +6194,26 @@
|
||||||
folder=lib.assetURL+folder;
|
folder=lib.assetURL+folder;
|
||||||
fileTransfer.download(encodeURI(url),encodeURI(folder),onsuccess,onerror);
|
fileTransfer.download(encodeURI(url),encodeURI(folder),onsuccess,onerror);
|
||||||
};
|
};
|
||||||
|
game.readFile=function(filename,callback){
|
||||||
|
window.resolveLocalFileSystemURL(lib.assetURL,function(entry){
|
||||||
|
entry.getFile(filename,{},function(fileEntry){
|
||||||
|
fileEntry.file(function(fileToLoad){
|
||||||
|
var fileReader = new FileReader();
|
||||||
|
fileReader.onload = function(e){
|
||||||
|
callback(e.target.result);
|
||||||
|
};
|
||||||
|
fileReader.readAsArrayBuffer(fileToLoad, "UTF-8");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
game.removeFile=function(dir){
|
||||||
|
window.resolveLocalFileSystemURL(lib.assetURL,function(entry){
|
||||||
|
entry.getFile(dir,{},function(fileEntry){
|
||||||
|
fileEntry.remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
game.ensureDirectory=function(list,callback,file){
|
game.ensureDirectory=function(list,callback,file){
|
||||||
var directorylist;
|
var directorylist;
|
||||||
var num=0;
|
var num=0;
|
||||||
|
@ -20215,6 +20238,15 @@
|
||||||
}
|
}
|
||||||
download();
|
download();
|
||||||
},
|
},
|
||||||
|
fetch:function(url,onload,onerror){
|
||||||
|
var tmpName=get.id();
|
||||||
|
game.download(encodeURI(url),tmpName,function(){
|
||||||
|
game.readFile(tmpName,function(data){
|
||||||
|
onload(data);
|
||||||
|
game.removeFile(tmpName);
|
||||||
|
},onerror);
|
||||||
|
},onerror);
|
||||||
|
},
|
||||||
playVideo:function(time,mode){
|
playVideo:function(time,mode){
|
||||||
if(!_status.replayvideo){
|
if(!_status.replayvideo){
|
||||||
localStorage.setItem(lib.configprefix+'playbackmode',lib.config.mode);
|
localStorage.setItem(lib.configprefix+'playbackmode',lib.config.mode);
|
||||||
|
@ -30485,7 +30517,7 @@
|
||||||
this.innerHTML='正在下载';
|
this.innerHTML='正在下载';
|
||||||
this.classList.add('nopointer');
|
this.classList.add('nopointer');
|
||||||
var url=lib.extensionURL+this.info[0]+'.zip';
|
var url=lib.extensionURL+this.info[0]+'.zip';
|
||||||
var importExtensionf=function(data,fileEntry){
|
var importExtensionf=function(data){
|
||||||
if(game.importExtension(data,function(){
|
if(game.importExtension(data,function(){
|
||||||
reloadnode.style.display='';
|
reloadnode.style.display='';
|
||||||
})!==false){
|
})!==false){
|
||||||
|
@ -30497,33 +30529,14 @@
|
||||||
}
|
}
|
||||||
that.classList.remove('active');
|
that.classList.remove('active');
|
||||||
that.classList.remove('highlight');
|
that.classList.remove('highlight');
|
||||||
if(fileEntry&&fileEntry.remove){
|
|
||||||
fileEntry.remove();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if(typeof window.fetch!='function'){
|
if(typeof window.fetch!='function'){
|
||||||
game.download(encodeURI(url),this.info[0]+'.zip',function(){
|
game.fetch(url,function(data){
|
||||||
if(window.resolveLocalFileSystemURL){
|
importExtensionf(data);
|
||||||
window.resolveLocalFileSystemURL(lib.assetURL,function(entry){
|
|
||||||
entry.getFile(that.info[0]+'.zip',{},function(fileEntry){
|
|
||||||
fileEntry.file(function(fileToLoad){
|
|
||||||
var fileReader = new FileReader();
|
|
||||||
fileReader.onload = function(e){
|
|
||||||
importExtensionf(e.target.result,fileEntry);
|
|
||||||
};
|
|
||||||
fileReader.readAsArrayBuffer(fileToLoad, "UTF-8");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
that.innerHTML='下载完成';
|
|
||||||
that.parentNode.parentNode.lastChild.innerHTML='已将扩展下载至游戏目录,请在“导入扩展”一栏中选择并安装';
|
|
||||||
}
|
|
||||||
},function(){
|
},function(){
|
||||||
that.innerHTML='下载失败';
|
that.innerHTML='下载失败';
|
||||||
that.classList.add('nopointer');
|
that.classList.add('nopointer');
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
window.fetch(url).then(function(response){
|
window.fetch(url).then(function(response){
|
||||||
|
|
Loading…
Reference in New Issue