Merge pull request #234 from nonameShijian/PR-Branch

懒加载ui.create.menu
This commit is contained in:
Spmario233 2023-08-25 22:38:31 +08:00 committed by GitHub
commit c80f137f70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4468 additions and 4408 deletions

View File

@ -39323,7 +39323,11 @@
active.link.remove();
active=this;
this.classList.add('active');
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link);
}
if(connectMenu){
if(updateActive) updateActive();
if(updateActiveCard) updateActiveCard();
@ -39334,6 +39338,7 @@
var info=lib.mode[mode];
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',info.name,position,clickMode);
node._initLink=function(){
node.link=page;
node.mode=mode;
if(connectMenu){
@ -39346,6 +39351,7 @@
node.classList.add('active');
}
}
//“更多”下的内容
var map={};
var infoconfig=connectMenu?info.connect:info.config;
if(infoconfig){
@ -39526,6 +39532,7 @@
}
})
}
};
return node;
};
var modeorder=lib.config.modeorder||[];
@ -39551,6 +39558,7 @@
active=start.firstChild.firstChild;
active.classList.add('active');
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
if(lib.config.fold_mode){
rightPane.addEventListener('mousewheel',function(e){
@ -39580,8 +39588,12 @@
active.classList.remove('active');
active.link.remove();
active=this;
this.classList.add('active');
active.classList.add('active');
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link);
}
};
var clickAutoSkill=function(bool){
@ -39659,6 +39671,7 @@
var info=lib.configMenu[mode];
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',info.name,position,clickMode);
node._initLink=function(){
node.link=page;
node.mode=mode;
var map={};
@ -40046,6 +40059,7 @@
info.config.update(config,map);
}
}
};
return node;
};
@ -40056,6 +40070,7 @@
if(!game.download&&!lib.device) return;
var page=ui.create.div('#create-extension');
var node=ui.create.div('.menubutton.large','文件',start.firstChild,clickMode);
node._initLink=function(){
node.link=page;
node.mode='create';
var pageboard=ui.create.div(page);
@ -40599,6 +40614,7 @@
createDash('音','音频文件',dash2);
createDash('字','字体文件',dash3);
createDash('全','全部文件',dash4);
};
}());
createModeConfig('others',start.firstChild);
@ -40607,6 +40623,7 @@
active=start.firstChild.firstChild;
active.classList.add('active');
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
}());
@ -40625,7 +40642,11 @@
}
this.classList.add('active');
updateActive(this);
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link);
}
};
updateActive=function(node){
if(!node){
@ -40634,6 +40655,9 @@
return;
}
}
if (!node.link) {
node._initLink();
}
for(var i=0;i<node.link.childElementCount;i++){
if(node.link.childNodes[i].updateBanned){
node.link.childNodes[i].updateBanned();
@ -40693,7 +40717,6 @@
};
var createModeConfig=function(mode,position,position2){
var info=lib.characterPack[mode];
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',lib.translate[mode+'_character_config'],position,clickMode);
if(node.innerHTML.length>=5){
@ -40702,6 +40725,8 @@
if(position2){
position.insertBefore(node,position2);
}
node._initLink=function(){
var info=lib.characterPack[mode];
node.link=page;
node.mode=mode;
page.node=node;
@ -40848,17 +40873,17 @@
delete this._banning;
};
var updateBanned=function(){
var list;
var _list;
if(connectMenu){
var mode=menux.pages[0].firstChild.querySelector('.active');
if(mode&&mode.mode){
list=lib.config['connect_'+mode.mode+'_banned'];
_list=lib.config['connect_'+mode.mode+'_banned'];
}
}
else{
list=lib.config[get.mode()+'_banned'];
_list=lib.config[get.mode()+'_banned'];
}
if(list&&list.contains(this.link)){
if(_list&&_list.contains(this.link)){
this.classList.add('banned');
}
else{
@ -40995,6 +41020,7 @@
});
}
}
};
return node;
};
if(lib.config.show_favourite_menu&&!connectMenu&&Array.isArray(lib.config.favouriteCharacter)){
@ -41005,7 +41031,9 @@
lib.characterPack.mode_favourite[favname]=lib.character[favname];
}
}
ui.favouriteCharacter=createModeConfig('mode_favourite',start.firstChild).link;
var favouriteCharacterNode=createModeConfig('mode_favourite',start.firstChild);
if(!favouriteCharacterNode.link) favouriteCharacterNode._initLink();
ui.favouriteCharacter=favouriteCharacterNode.link;
if(get.is.empty(lib.characterPack.mode_favourite)){
ui.favouriteCharacter.node.style.display='none';
}
@ -41052,6 +41080,7 @@
active.classList.add('active');
updateActive(active);
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
if(!connectMenu){
@ -41094,7 +41123,11 @@
if(this.mode=='cardpile'){
this.create();
}
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link);
}
};
updateActiveCard=function(node){
if(!node){
@ -41103,6 +41136,7 @@
return;
}
}
if(!node.link) node._initLink();
for(var i=0;i<node.link.childElementCount;i++){
if(node.link.childNodes[i].updateBanned){
node.link.childNodes[i].updateBanned();
@ -41183,6 +41217,7 @@
if(node.innerHTML.length>=5){
node.classList.add('smallfont');
}
node._initLink=function(){
node.link=page;
node.mode=mode;
var list=[];
@ -41453,6 +41488,7 @@
}
ui.create.div('.menuplaceholder',page);
}
};
return node;
};
if(!connectMenu&&lib.config.show_ban_menu){
@ -41491,6 +41527,7 @@
active.classList.add('active');
updateActiveCard(active);
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
(function(){
@ -41650,7 +41687,11 @@
active.link.remove();
active=this;
this.classList.add('active');
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link);
}
};
ui.click.extensionTab=function(name){
ui.click.menuTab('扩展');
@ -41729,6 +41770,7 @@
if(node.innerHTML.length>=5){
node.classList.add('smallfont');
}
node._initLink=function(){
node.link=page;
node.mode=mode;
for(var i in lib.extensionMenu[mode]){
@ -41764,6 +41806,7 @@
}
page.appendChild(cfgnode);
}
};
return node;
};
for(var i in lib.extensionMenu){
@ -41776,6 +41819,7 @@
if(lib.config.show_extensionmaker==false) return;
var page=ui.create.div('#create-extension');
var node=ui.create.div('.menubutton.large','制作扩展',start.firstChild,clickMode);
node._initLink=function(){
node.link=page;
node.mode='create';
var pageboard=ui.create.div(page);
@ -43888,10 +43932,12 @@
createDash('卡','编辑卡牌',dash2);
createDash('技','编辑技能',dash3);
createDash('码','编辑代码',dash4);
};
}());
(function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','获取扩展',start.firstChild,clickMode);
node._initLink=function(){
node.link=page;
node.mode='get';
page.listen(function(){
@ -44191,12 +44237,14 @@
});
}
};
};
}());
var active=start.firstChild.querySelector('.active');
if(!active){
active=start.firstChild.firstChild;
active.classList.add('active');
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
updateNodes();
}());
@ -44237,7 +44285,11 @@
}
active=this;
this.classList.add('active');
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link);
}
if(this.type=='cheat'){
cheatButton.style.display='';
}
@ -44268,6 +44320,7 @@
ui.click.menuTab('其它');
clickMode.call(ui.commandnode);
};
//更新菜单有本体函数赋值,就不要懒加载了
(function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','更新',start.firstChild,clickMode);
@ -44963,6 +45016,9 @@
}
}());
(function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','控制',start.firstChild,clickMode);
node._initLink=function(){
var norow2=function(){
var node=currentrow1;
if(!node) return false;
@ -45070,9 +45126,6 @@
clickContainer.call(menuContainer);
}
});
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','控制',start.firstChild,clickMode);
node.link=page;
node.type='cheat';
page.classList.add('menu-sym');
@ -45216,12 +45269,14 @@
}
checkCheat();
});
};
}());
(function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','命令',start.firstChild,clickMode);
ui.commandnode=node;
node.type='cmd';
node._initLink=function(){
node.link=page;
page.classList.add('menu-sym');
menuUpdates.push(function(){
@ -45392,11 +45447,13 @@
clearButton.listen(function(){
pre.innerHTML='';
});
};
}());
(function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','战绩',start.firstChild,clickMode);
node.type='rec';
node._initLink=function(){
node.link=page;
page.style.paddingBottom='10px';
var reset=function(){
@ -45425,16 +45482,17 @@
item.link=lib.config.all.mode[i];
}
}
};
}());
(function(){
if(!window.indexedDB||window.nodb) return;
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','录像',start.firstChild,clickMode);
node.type='video';
node.link=page;
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
lib.videos=[];
node._initLink=function(){
node.link=page;
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
store.openCursor().onsuccess=function(e){
var cursor=e.target.result;
if(cursor){
@ -45611,6 +45669,7 @@
}
}
};
};
}());
@ -45681,6 +45740,7 @@
active=start.firstChild.firstChild;
active.classList.add('active');
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
}());