From 19a363bdc233d7d91f0b7f93f46c13032d60d102 Mon Sep 17 00:00:00 2001 From: libccy Date: Fri, 24 Mar 2017 17:15:44 +0800 Subject: [PATCH] v1.9.14 --- game/game.js | 268 ++++++++++++++++++++++++++++++------------------- game/update.js | 2 +- 2 files changed, 163 insertions(+), 107 deletions(-) diff --git a/game/game.js b/game/game.js index c0cd28e50..188313cb7 100644 --- a/game/game.js +++ b/game/game.js @@ -23,7 +23,6 @@ updateURL:'https://raw.githubusercontent.com/libccy/noname', updateURL2:'https://coding.net/u/libccy/p/noname/git/raw', extensionURL:'https://coding.net/u/libccy/p/noname-extension/git/raw/master/', - extensionURL2:'https://coding.net/u/libccy/p/noname-extension-list/git/raw/master/list.js', hallURL:'websha.cn', assetURL:'', changeLog:[], @@ -6990,7 +6989,13 @@ } }, req:function(str,onload,onerror,master){ - var sScriptURL=get.url(master)+str; + var sScriptURL; + if(str.indexOf('http')==0){ + sScriptURL=str; + } + else{ + sScriptURL=get.url(master)+str; + } var oReq=new XMLHttpRequest(); if(onload) oReq.addEventListener("load",onload); if(onerror) oReq.addEventListener("error",onerror); @@ -25368,6 +25373,38 @@ if(listen) node.onclick=listen; return node; }, + iframe:function(src){ + var layer=document.createElement('div'); + layer.classList.add('poplayer'); + layer.style.zIndex='100'; + layer.listen(function(){ + this.remove(); + }); + layer.style.background='white'; + + var webview=document.createElement('iframe'); + webview.src=src; + webview.width='100%'; + webview.height='100%'; + webview.style.left='0px'; + webview.style.top='0px'; + webview.style.position='absolute'; + webview.style.border='none'; + layer.appendChild(webview); + + var backbutton=ui.create.div('.menubutton.round','返',layer,function(){ + layer.remove(); + }); + backbutton.style.bottom='10px'; + backbutton.style.right='10px'; + backbutton.style.background='rgba(0,0,0,0.4)'; + backbutton.style.color='white'; + backbutton.style.textShadow='rgba(0,0,0,0.5) 0px 0px 2px'; + backbutton.style.boxShadow='rgba(0, 0, 0, 0.3) 0 0 0 1px, rgba(0, 0, 0, 0.3) 0 3px 10px'; + backbutton.style.position='fixed'; + + ui.window.appendChild(layer); + }, chat:function(){ var chat=ui.create.system('聊天',null,true); ui.chatButton=chat; @@ -28270,7 +28307,8 @@ buttonReset.style.display='none'; buttonExport.style.display='none'; } - exportExtLine.style.display='none'; + exportExtLine.style.display='none'; + shareExtLine.style.display='none'; dash1.reset(name); dash2.reset(name); dash3.reset(name); @@ -28426,6 +28464,7 @@ buttonExport.style.display='none'; buttonExport.onclick=function(){ processExtension(true); + shareExtLine.style.display=''; }; inputExtLine.appendChild(buttonExport); var exportExtLine=ui.create.div(pageboard); @@ -28438,6 +28477,21 @@ exportExtLine.querySelectorAll('span')[1].onclick=function(){ exportExtLine.style.display='none'; }; + + + var shareExtLine=ui.create.div(pageboard); + shareExtLine.style.display='none'; + shareExtLine.style.width='calc(100% - 40px)'; + shareExtLine.style.textAlign='left'; + shareExtLine.style.marginBottom='5px'; + shareExtLine.innerHTML='已导出扩展。分享扩展×'; + shareExtLine.querySelectorAll('span')[0].onclick=function(){ + ui.create.iframe('https://tieba.baidu.com/p/5037850317'); + }; + shareExtLine.querySelectorAll('span')[1].onclick=function(){ + shareExtLine.style.display='none'; + }; + var dashboard=ui.create.div(pageboard); var clickDash=function(){ ui.create.templayer(); @@ -30284,10 +30338,45 @@ this.innerHTML='正在下载'; this.classList.add('nopointer'); var url=lib.extensionURL+this.info[0]+'.zip'; + var importExtensionf=function(data,fileEntry){ + if(game.importExtension(data,function(){ + reloadnode.style.display=''; + })!==false){ + game.saveConfig('extension_'+that.info[0]+'_version',that.info[3]); + that.innerHTML='安装成功'; + } + else{ + that.innerHTML='安装失败'; + } + that.classList.remove('active'); + that.classList.remove('highlight'); + if(fileEntry&&fileEntry.remove){ + fileEntry.remove(); + } + }; if(typeof window.fetch!='function'){ game.download(encodeURI(url),this.info[0]+'.zip',function(){ - that.innerHTML='下载完成'; - that.parentNode.parentNode.lastChild.innerHTML='已将扩展下载至游戏目录,请在“导入扩展”一栏中选择并安装'; + if(window.resolveLocalFileSystemURL){ + window.resolveLocalFileSystemURL(lib.assetURL,function(entry){ + game.print(entry); + entry.getFile(that.info[0]+'.zip',{},function(fileEntry){ + game.print(fileEntry); + fileEntry.file(function(fileToLoad){ + game.print(123); + var fileReader = new FileReader(); + fileReader.onload = function(e){ + game.print(456); + importExtensionf(e.target.result,fileEntry); + }; + fileReader.readAsArrayBuffer(fileToLoad, "UTF-8"); + }); + }); + }); + } + else{ + that.innerHTML='下载完成'; + that.parentNode.parentNode.lastChild.innerHTML='已将扩展下载至游戏目录,请在“导入扩展”一栏中选择并安装'; + } },function(){ that.innerHTML='下载失败'; that.classList.add('nopointer'); @@ -30297,24 +30386,13 @@ window.fetch(url).then(function(response){ if(response.status === 200 || response.status === 0){ return Promise.resolve(response.arrayBuffer()) - }else{ + } + else{ that.innerHTML='下载失败'; that.classList.add('nopointer'); return Promise.reject(new Error(response.statusText)); } - }).then(function(data){ - if(game.importExtension(data,function(){ - reloadnode.style.display=''; - })!==false){ - game.saveConfig('extension_'+that.info[0]+'_version',that.info[3]); - that.innerHTML='安装成功'; - } - else{ - that.innerHTML='安装失败'; - } - that.classList.remove('active'); - that.classList.remove('highlight'); - }); + }).then(importExtensionf); } }; @@ -30334,7 +30412,7 @@ } var loading=ui.create.div('.loading.config.toggle','载入中...',page); - lib.init.js(lib.extensionURL2,null,function(){ + lib.init.js(lib.extensionURL+'list.js',null,function(){ var list=window.noname_extension_list; delete window.noname_extension_list; loading.style.display='none'; @@ -30528,100 +30606,78 @@ button1.disabled=true; var goupdate=function(files,update){ - if(game.download){ - lib.version=update.version; - lib.init.req('game/source.js',function(){ - try{ - eval(this.responseText); - if(!window.noname_source_list){ - throw('err'); - } - } - catch(e){ - alert('更新地址有误'); - console.log(e); - return; + lib.version=update.version; + lib.init.req('game/source.js',function(){ + try{ + eval(this.responseText); + if(!window.noname_source_list){ + throw('err'); } + } + catch(e){ + alert('更新地址有误'); + console.log(e); + return; + } - var updates=window.noname_source_list; - delete window.noname_source_list; - if(Array.isArray(files)){ - files.add('game/update.js'); - var files2=[]; - for(var i=0;i