This commit is contained in:
libccy 2017-03-24 13:24:03 +08:00
parent ed49016376
commit 005758dd7e
2 changed files with 118 additions and 99 deletions

View File

@ -6011,7 +6011,8 @@
}; };
if(ui.updatep1){ if(ui.updatep1){
ui.updatep1.style.display=''; ui.updatep1.style.display='';
ui.updatep2.style.display=''; ui.updatep2.style.display='';
ui.updatep3.style.display='';
} }
game.download=function(url,folder,onsuccess,onerror,dev){ game.download=function(url,folder,onsuccess,onerror,dev){
if(url.indexOf('web/')==0){ if(url.indexOf('web/')==0){
@ -6157,7 +6158,8 @@
} }
if(ui.updatep1){ if(ui.updatep1){
ui.updatep1.style.display=''; ui.updatep1.style.display='';
ui.updatep2.style.display=''; ui.updatep2.style.display='';
ui.updatep3.style.display='';
} }
game.download=function(url,folder,onsuccess,onerror,dev){ game.download=function(url,folder,onsuccess,onerror,dev){
if(url.indexOf('web/')==0){ if(url.indexOf('web/')==0){
@ -7045,6 +7047,26 @@
oReq.open("GET", sScriptURL); oReq.open("GET", sScriptURL);
oReq.send(); oReq.send();
}, },
json:function(url,onload,onerror){
var oReq=new XMLHttpRequest();
if(onload) oReq.addEventListener("load",function(){
var result;
try{
result=JSON.parse(this.responseText);
if(!result){
throw('err');
}
}
catch(e){
onerror();
return;
}
onload(result);
});
if(onerror) oReq.addEventListener("error",onerror);
oReq.open("GET", url);
oReq.send();
},
layout:function(layout,nosave){ layout:function(layout,nosave){
if(!nosave) game.saveConfig('layout',layout); if(!nosave) game.saveConfig('layout',layout);
game.layout=layout; game.layout=layout;
@ -19799,7 +19821,7 @@
name:'删除此扩展', name:'删除此扩展',
clear:true, clear:true,
onclick:function(){ onclick:function(){
if(this.innerHTML=='确认删除'){ if(this.innerHTML=='<span>确认删除</span>'){
var prefix='extension_'+obj.name; var prefix='extension_'+obj.name;
var page=this.parentNode; var page=this.parentNode;
var start=page.parentNode.previousSibling; var start=page.parentNode.previousSibling;
@ -19826,10 +19848,10 @@
} }
} }
else{ else{
this.innerHTML='确认删除'; this.innerHTML='<span>确认删除</span>';
var that=this; var that=this;
setTimeout(function(){ setTimeout(function(){
that.innerHTML='删除'+obj.name; that.innerHTML='<span>删除此扩展</span>';
},1000); },1000);
} }
} }
@ -30254,13 +30276,13 @@
ui.create.div('','<input type="file" accept="application/zip" style="width:153px"><button>确定</button>',importExtension); ui.create.div('','<input type="file" accept="application/zip" style="width:153px"><button>确定</button>',importExtension);
if(!game.download||true){ if(!game.download||typeof window.fetch!='function'){
extensionnode.classList.add('on'); extensionnode.classList.add('on');
importExtension.style.display=''; importExtension.style.display='';
importextensionexpanded=true; importextensionexpanded=true;
} }
var reloadnode=ui.create.div('.config.toggle','重新启动',page,game.reload); var reloadnode=ui.create.div('.config.toggle.pointerdiv','重新启动',page,game.reload);
reloadnode.style.display='none'; reloadnode.style.display='none';
var placeholder=ui.create.div('.config.toggle',page); var placeholder=ui.create.div('.config.toggle',page);
placeholder.style.height=0; placeholder.style.height=0;
@ -30292,12 +30314,12 @@
} }
var clickExtension=function(){ var clickExtension=function(){
var active=this.parentNode.querySelector('.videonode.active'); var active=this.parentNode.querySelector('.videonode.current');
if(active){ if(active){
active.classList.remove('active'); active.classList.remove('current');
} }
if(active!=this){ if(active!=this){
this.classList.add('active'); this.classList.add('current');
} }
}; };
var importExtensionf=function(extname,extversion,noasset,onsuccess,onerror){ var importExtensionf=function(extname,extversion,noasset,onsuccess,onerror){
@ -30343,65 +30365,77 @@
} }
}; };
var downloadExtension=function(e){ var downloadExtension=function(e){
if((this.innerHTML!='下载扩展'&&this.innerHTML!='更新扩展'&&this.innerHTML!='更新素材')||!window.JSZip) return; if((this.innerHTML!='下载扩展'&&this.innerHTML!='更新扩展')||!window.JSZip) return;
if(e){ if(e){
e.stopPropagation(); e.stopPropagation();
} }
node.updated=true; node.updated=true;
var that=this; var that=this;
var list=[]; var list=[];
var noasset=false;
if(this.files.length){ this.innerHTML='正在下载';
if(!lib.config.no_extension_asset||this.innerHTML=='更新素材'){ window.fetch(lib.extensionURL+this.info[0]+'.zip').then(function(response){
for(var i=0;i<this.files.length;i++){ if(response.status === 200 || response.status === 0){
list.push('web/'+this.link+'/'+this.files[i]); return Promise.resolve(response.arrayBuffer())
} }else{
} that.innerHTML='下载失败';
else{ that.classList.add('nopointer');
noasset=true; return Promise.reject(new Error(response.statusText));
} }
} }).then(function(data){
this.classList.add('button-downloading'); if(game.importExtension(data,function(){
this.innerHTML='<span>正在下载</span><div>正在下载</div>'; reloadnode.style.display='';
var progress=ui.create.div('.button-progress',this); })!==false){
list.push('web/'+this.link+'/extension.js'); game.saveConfig('extension_'+that.info[0]+'_version',that.info[3]);
game.checkFileList(list,function(){ that.innerHTML='安装成功';
game.multiDownload(list,function(num){ }
var length=100*(list.length-num)/list.length; else{
progress.style.width=length+'%'; that.innerHTML='安装失败';
if(length<10){ }
var width=8-progress.offsetWidth; that.classList.add('nopointer');
progress.style.transition='all 0s'; });
progress.style.height='calc(100% - '+width/2+'px)'; // console.log();
progress.style.top=width/4+'px'; // this.classList.add('button-downloading');
} // this.innerHTML='<span>正在下载</span><div>正在下载</div>';
else{ // var progress=ui.create.div('.button-progress',this);
progress.style.transition=''; // list.push('web/'+this.link+'/extension.js');
progress.style.height=''; // game.checkFileList(list,function(){
progress.style.top=''; // game.multiDownload(list,function(num){
} // var length=100*(list.length-num)/list.length;
},function(){ // progress.style.width=length+'%';
that.innerHTML='下载失败'; // if(length<10){
},function(){ // var width=8-progress.offsetWidth;
if(that.innerHTML=='下载失败') return; // progress.style.transition='all 0s';
progress.style.width='100%'; // progress.style.height='calc(100% - '+width/2+'px)';
importExtensionf(that.name,that.version,noasset,function(){ // progress.style.top=width/4+'px';
that.childNodes[0].innerHTML='安装成功'; // }
that.childNodes[1].innerHTML='安装成功'; // else{
// that.classList.remove('active'); // progress.style.transition='';
// that.classList.add('highlight'); // progress.style.height='';
reloadnode.style.display=''; // progress.style.top='';
},function(){ // }
that.innerHTML='安装失败'; // },function(){
}); // that.innerHTML='下载失败';
},function(str){ // },function(){
return 'extension/'+that.name+'/'+str.slice(str.lastIndexOf('/')+1); // if(that.innerHTML=='下载失败') return;
}); // progress.style.width='100%';
}); // importExtensionf(that.name,that.version,noasset,function(){
// that.childNodes[0].innerHTML='安装成功';
// that.childNodes[1].innerHTML='安装成功';
// // that.classList.remove('active');
// // that.classList.add('highlight');
// reloadnode.style.display='';
// },function(){
// that.innerHTML='安装失败';
// });
// },function(str){
// return 'extension/'+that.name+'/'+str.slice(str.lastIndexOf('/')+1);
// });
// });
}; };
node.update=function(){ node.update=function(){
if(!game.download||this.updated||true) return; if(this.updated||!game.download||typeof window.fetch!='function') return;
if(!window.JSZip){ if(!window.JSZip){
lib.init.js(lib.assetURL+'game','jszip'); lib.init.js(lib.assetURL+'game','jszip');
} }
@ -30414,54 +30448,34 @@
for(var i=0;i<toremove.length;i++){ for(var i=0;i<toremove.length;i++){
toremove[i].remove(); toremove[i].remove();
} }
var loading=ui.create.div('.loading.config.toggle','载入中...',page); var loading=ui.create.div('.loading.config.toggle','载入中...',page);
var script=lib.init.js('http://'+lib.hallURL,'web/list',function(){ lib.init.json(lib.extensionURL2,function(list){
loading.remove(); loading.style.display='none';
script.remove(); for(var i=0;i<list.length;i++){
var list=window.noname_extension_list; var info=list[i];
delete window.noname_extension_list; var node=ui.create.div('.videonode.menubutton.extension.large',page,clickExtension);
var cfgnode=createConfig({ ui.create.div('.caption',list[i][0],node);
name:'不下载素材', ui.create.div('.text.author','作者:'+list[i][1]);
init:lib.config.no_extension_asset, ui.create.div('.text',list[i][2],node);
onclick:function(bool){
game.saveConfig('no_extension_asset',bool);
}
});
cfgnode.classList.add('loading');
cfgnode.style.marginBottom='10px';
page.appendChild(cfgnode);
for(var i in list){
var node=ui.create.div('.videonode.menubutton.extension.large',page,clickExtension);
ui.create.div('.caption',list[i].name,node);
ui.create.div('.text.author','作者:'+list[i].author,node);
ui.create.div('.text',list[i].description,node);
var download=ui.create.div('.menubutton.text.active','下载扩展',node.firstChild,downloadExtension); var download=ui.create.div('.menubutton.text.active','下载扩展',node.firstChild,downloadExtension);
if(lib.config.extensions.contains(list[i].name)){ if(lib.config.extensions.contains(list[i][0])){
download.classList.remove('active'); download.classList.remove('active');
if(lib.config['extension_'+list[i].name+'_version']!=list[i].version){ if(lib.config['extension_'+list[i][0]+'_version']!=list[i][3]){
download.innerHTML='更新扩展'; download.innerHTML='更新扩展';
download.classList.add('highlight'); download.classList.add('highlight');
} }
else if(lib.config['extension_'+list[i].name+'_noasset']){
download.innerHTML='更新素材';
download.classList.add('highlight');
}
else{ else{
download.classList.add('transparent2'); download.classList.add('transparent2');
download.classList.remove('active'); download.classList.remove('active');
download.innerHTML='已安装'; download.innerHTML='已安装';
} }
} }
download.link=i; download.info=list[i];
download.name=list[i].name; }
download.files=list[i].files||[]; },function(){
if(list[i].version){ loading.innerHTML='连接失败';
download.version=list[i].version; });
}
}
},function(){
loading.innerHTML='连接失败';
});
}; };
}()); }());
var active=start.firstChild.querySelector('.active'); var active=start.firstChild.querySelector('.active');
@ -30589,10 +30603,12 @@
li3.innerHTML='更新地址:<span>'+trimurl(lib.config.updateURL||lib.updateURL)+'</span><p style="margin-top:8px"></p>'; li3.innerHTML='更新地址:<span>'+trimurl(lib.config.updateURL||lib.updateURL)+'</span><p style="margin-top:8px"></p>';
li3.style.whiteSpace='nowrap'; li3.style.whiteSpace='nowrap';
ui.updatep1=li1.querySelector('p'); ui.updatep1=li1.querySelector('p');
ui.updatep2=li2; ui.updatep2=li2;
ui.updatep3=li3;
if(!game.download){ if(!game.download){
ui.updatep1.style.display='none'; ui.updatep1.style.display='none';
ui.updatep2.style.display='none'; ui.updatep2.style.display='none';
ui.updatep3.style.display='none';
} }
var button1,button2,button3,button4,button5; var button1,button2,button3,button4,button5;

View File

@ -1101,7 +1101,7 @@ input.fileinput::-webkit-file-upload-button {
height: auto; height: auto;
max-height: 90px; max-height: 90px;
} }
.videonode.menubutton.extension.active{ .videonode.menubutton.extension.current{
max-height: 200px; max-height: 200px;
} }
.videonode.menubutton>div{ .videonode.menubutton>div{
@ -1111,6 +1111,9 @@ input.fileinput::-webkit-file-upload-button {
position: relative; position: relative;
display: block; display: block;
} }
#window:not(.nopointer) .videonode.menubutton.extension>.caption>.menubutton:not(.transparent2):not(.nopointer){
cursor: pointer;
}
.videonode.menubutton.extension>.caption>.menubutton{ .videonode.menubutton.extension>.caption>.menubutton{
position: relative; position: relative;
float: right; float: right;