懒加载ui.create.menu

This commit is contained in:
shijian 2023-08-25 22:19:48 +08:00
parent 7273418d0b
commit 24f5f56cca
1 changed files with 4468 additions and 4408 deletions

View File

@ -39260,7 +39260,11 @@
active.link.remove(); active.link.remove();
active=this; active=this;
this.classList.add('active'); this.classList.add('active');
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link); rightPane.appendChild(this.link);
}
if(connectMenu){ if(connectMenu){
if(updateActive) updateActive(); if(updateActive) updateActive();
if(updateActiveCard) updateActiveCard(); if(updateActiveCard) updateActiveCard();
@ -39271,6 +39275,7 @@
var info=lib.mode[mode]; var info=lib.mode[mode];
var page=ui.create.div(''); var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',info.name,position,clickMode); var node=ui.create.div('.menubutton.large',info.name,position,clickMode);
node._initLink=function(){
node.link=page; node.link=page;
node.mode=mode; node.mode=mode;
if(connectMenu){ if(connectMenu){
@ -39283,6 +39288,7 @@
node.classList.add('active'); node.classList.add('active');
} }
} }
//“更多”下的内容
var map={}; var map={};
var infoconfig=connectMenu?info.connect:info.config; var infoconfig=connectMenu?info.connect:info.config;
if(infoconfig){ if(infoconfig){
@ -39463,6 +39469,7 @@
} }
}) })
} }
};
return node; return node;
}; };
var modeorder=lib.config.modeorder||[]; var modeorder=lib.config.modeorder||[];
@ -39488,6 +39495,7 @@
active=start.firstChild.firstChild; active=start.firstChild.firstChild;
active.classList.add('active'); active.classList.add('active');
} }
if(!active.link) active._initLink();
rightPane.appendChild(active.link); rightPane.appendChild(active.link);
if(lib.config.fold_mode){ if(lib.config.fold_mode){
rightPane.addEventListener('mousewheel',function(e){ rightPane.addEventListener('mousewheel',function(e){
@ -39517,8 +39525,12 @@
active.classList.remove('active'); active.classList.remove('active');
active.link.remove(); active.link.remove();
active=this; active=this;
this.classList.add('active'); active.classList.add('active');
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link); rightPane.appendChild(this.link);
}
}; };
var clickAutoSkill=function(bool){ var clickAutoSkill=function(bool){
@ -39596,6 +39608,7 @@
var info=lib.configMenu[mode]; var info=lib.configMenu[mode];
var page=ui.create.div(''); var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',info.name,position,clickMode); var node=ui.create.div('.menubutton.large',info.name,position,clickMode);
node._initLink=function(){
node.link=page; node.link=page;
node.mode=mode; node.mode=mode;
var map={}; var map={};
@ -39983,6 +39996,7 @@
info.config.update(config,map); info.config.update(config,map);
} }
} }
};
return node; return node;
}; };
@ -39993,6 +40007,7 @@
if(!game.download&&!lib.device) return; if(!game.download&&!lib.device) return;
var page=ui.create.div('#create-extension'); var page=ui.create.div('#create-extension');
var node=ui.create.div('.menubutton.large','文件',start.firstChild,clickMode); var node=ui.create.div('.menubutton.large','文件',start.firstChild,clickMode);
node._initLink=function(){
node.link=page; node.link=page;
node.mode='create'; node.mode='create';
var pageboard=ui.create.div(page); var pageboard=ui.create.div(page);
@ -40536,6 +40551,7 @@
createDash('音','音频文件',dash2); createDash('音','音频文件',dash2);
createDash('字','字体文件',dash3); createDash('字','字体文件',dash3);
createDash('全','全部文件',dash4); createDash('全','全部文件',dash4);
};
}()); }());
createModeConfig('others',start.firstChild); createModeConfig('others',start.firstChild);
@ -40544,6 +40560,7 @@
active=start.firstChild.firstChild; active=start.firstChild.firstChild;
active.classList.add('active'); active.classList.add('active');
} }
if(!active.link) active._initLink();
rightPane.appendChild(active.link); rightPane.appendChild(active.link);
}()); }());
@ -40562,7 +40579,11 @@
} }
this.classList.add('active'); this.classList.add('active');
updateActive(this); updateActive(this);
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link); rightPane.appendChild(this.link);
}
}; };
updateActive=function(node){ updateActive=function(node){
if(!node){ if(!node){
@ -40571,6 +40592,9 @@
return; return;
} }
} }
if (!node.link) {
node._initLink();
}
for(var i=0;i<node.link.childElementCount;i++){ for(var i=0;i<node.link.childElementCount;i++){
if(node.link.childNodes[i].updateBanned){ if(node.link.childNodes[i].updateBanned){
node.link.childNodes[i].updateBanned(); node.link.childNodes[i].updateBanned();
@ -40630,7 +40654,6 @@
}; };
var createModeConfig=function(mode,position,position2){ var createModeConfig=function(mode,position,position2){
var info=lib.characterPack[mode];
var page=ui.create.div(''); var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',lib.translate[mode+'_character_config'],position,clickMode); var node=ui.create.div('.menubutton.large',lib.translate[mode+'_character_config'],position,clickMode);
if(node.innerHTML.length>=5){ if(node.innerHTML.length>=5){
@ -40639,6 +40662,8 @@
if(position2){ if(position2){
position.insertBefore(node,position2); position.insertBefore(node,position2);
} }
node._initLink=function(){
var info=lib.characterPack[mode];
node.link=page; node.link=page;
node.mode=mode; node.mode=mode;
page.node=node; page.node=node;
@ -40785,17 +40810,17 @@
delete this._banning; delete this._banning;
}; };
var updateBanned=function(){ var updateBanned=function(){
var list; var _list;
if(connectMenu){ if(connectMenu){
var mode=menux.pages[0].firstChild.querySelector('.active'); var mode=menux.pages[0].firstChild.querySelector('.active');
if(mode&&mode.mode){ if(mode&&mode.mode){
list=lib.config['connect_'+mode.mode+'_banned']; _list=lib.config['connect_'+mode.mode+'_banned'];
} }
} }
else{ 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'); this.classList.add('banned');
} }
else{ else{
@ -40932,6 +40957,7 @@
}); });
} }
} }
};
return node; return node;
}; };
if(lib.config.show_favourite_menu&&!connectMenu&&Array.isArray(lib.config.favouriteCharacter)){ if(lib.config.show_favourite_menu&&!connectMenu&&Array.isArray(lib.config.favouriteCharacter)){
@ -40942,7 +40968,9 @@
lib.characterPack.mode_favourite[favname]=lib.character[favname]; 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)){ if(get.is.empty(lib.characterPack.mode_favourite)){
ui.favouriteCharacter.node.style.display='none'; ui.favouriteCharacter.node.style.display='none';
} }
@ -40989,6 +41017,7 @@
active.classList.add('active'); active.classList.add('active');
updateActive(active); updateActive(active);
} }
if(!active.link) active._initLink();
rightPane.appendChild(active.link); rightPane.appendChild(active.link);
if(!connectMenu){ if(!connectMenu){
@ -41031,7 +41060,11 @@
if(this.mode=='cardpile'){ if(this.mode=='cardpile'){
this.create(); this.create();
} }
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link); rightPane.appendChild(this.link);
}
}; };
updateActiveCard=function(node){ updateActiveCard=function(node){
if(!node){ if(!node){
@ -41040,6 +41073,7 @@
return; return;
} }
} }
if(!node.link) node._initLink();
for(var i=0;i<node.link.childElementCount;i++){ for(var i=0;i<node.link.childElementCount;i++){
if(node.link.childNodes[i].updateBanned){ if(node.link.childNodes[i].updateBanned){
node.link.childNodes[i].updateBanned(); node.link.childNodes[i].updateBanned();
@ -41120,6 +41154,7 @@
if(node.innerHTML.length>=5){ if(node.innerHTML.length>=5){
node.classList.add('smallfont'); node.classList.add('smallfont');
} }
node._initLink=function(){
node.link=page; node.link=page;
node.mode=mode; node.mode=mode;
var list=[]; var list=[];
@ -41390,6 +41425,7 @@
} }
ui.create.div('.menuplaceholder',page); ui.create.div('.menuplaceholder',page);
} }
};
return node; return node;
}; };
if(!connectMenu&&lib.config.show_ban_menu){ if(!connectMenu&&lib.config.show_ban_menu){
@ -41428,6 +41464,7 @@
active.classList.add('active'); active.classList.add('active');
updateActiveCard(active); updateActiveCard(active);
} }
if(!active.link) active._initLink();
rightPane.appendChild(active.link); rightPane.appendChild(active.link);
(function(){ (function(){
@ -41587,7 +41624,11 @@
active.link.remove(); active.link.remove();
active=this; active=this;
this.classList.add('active'); this.classList.add('active');
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link); rightPane.appendChild(this.link);
}
}; };
ui.click.extensionTab=function(name){ ui.click.extensionTab=function(name){
ui.click.menuTab('扩展'); ui.click.menuTab('扩展');
@ -41666,6 +41707,7 @@
if(node.innerHTML.length>=5){ if(node.innerHTML.length>=5){
node.classList.add('smallfont'); node.classList.add('smallfont');
} }
node._initLink=function(){
node.link=page; node.link=page;
node.mode=mode; node.mode=mode;
for(var i in lib.extensionMenu[mode]){ for(var i in lib.extensionMenu[mode]){
@ -41701,6 +41743,7 @@
} }
page.appendChild(cfgnode); page.appendChild(cfgnode);
} }
};
return node; return node;
}; };
for(var i in lib.extensionMenu){ for(var i in lib.extensionMenu){
@ -41713,6 +41756,7 @@
if(lib.config.show_extensionmaker==false) return; if(lib.config.show_extensionmaker==false) return;
var page=ui.create.div('#create-extension'); var page=ui.create.div('#create-extension');
var node=ui.create.div('.menubutton.large','制作扩展',start.firstChild,clickMode); var node=ui.create.div('.menubutton.large','制作扩展',start.firstChild,clickMode);
node._initLink=function(){
node.link=page; node.link=page;
node.mode='create'; node.mode='create';
var pageboard=ui.create.div(page); var pageboard=ui.create.div(page);
@ -43825,10 +43869,12 @@
createDash('卡','编辑卡牌',dash2); createDash('卡','编辑卡牌',dash2);
createDash('技','编辑技能',dash3); createDash('技','编辑技能',dash3);
createDash('码','编辑代码',dash4); createDash('码','编辑代码',dash4);
};
}()); }());
(function(){ (function(){
var page=ui.create.div(''); var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','获取扩展',start.firstChild,clickMode); var node=ui.create.div('.menubutton.large','获取扩展',start.firstChild,clickMode);
node._initLink=function(){
node.link=page; node.link=page;
node.mode='get'; node.mode='get';
page.listen(function(){ page.listen(function(){
@ -44128,12 +44174,14 @@
}); });
} }
}; };
};
}()); }());
var active=start.firstChild.querySelector('.active'); var active=start.firstChild.querySelector('.active');
if(!active){ if(!active){
active=start.firstChild.firstChild; active=start.firstChild.firstChild;
active.classList.add('active'); active.classList.add('active');
} }
if(!active.link) active._initLink();
rightPane.appendChild(active.link); rightPane.appendChild(active.link);
updateNodes(); updateNodes();
}()); }());
@ -44174,7 +44222,11 @@
} }
active=this; active=this;
this.classList.add('active'); this.classList.add('active');
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link); rightPane.appendChild(this.link);
}
if(this.type=='cheat'){ if(this.type=='cheat'){
cheatButton.style.display=''; cheatButton.style.display='';
} }
@ -44205,6 +44257,7 @@
ui.click.menuTab('其它'); ui.click.menuTab('其它');
clickMode.call(ui.commandnode); clickMode.call(ui.commandnode);
}; };
//更新菜单有本体函数赋值,就不要懒加载了
(function(){ (function(){
var page=ui.create.div(''); var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','更新',start.firstChild,clickMode); var node=ui.create.div('.menubutton.large','更新',start.firstChild,clickMode);
@ -44900,6 +44953,9 @@
} }
}()); }());
(function(){ (function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','控制',start.firstChild,clickMode);
node._initLink=function(){
var norow2=function(){ var norow2=function(){
var node=currentrow1; var node=currentrow1;
if(!node) return false; if(!node) return false;
@ -45007,9 +45063,6 @@
clickContainer.call(menuContainer); clickContainer.call(menuContainer);
} }
}); });
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','控制',start.firstChild,clickMode);
node.link=page; node.link=page;
node.type='cheat'; node.type='cheat';
page.classList.add('menu-sym'); page.classList.add('menu-sym');
@ -45153,12 +45206,14 @@
} }
checkCheat(); checkCheat();
}); });
};
}()); }());
(function(){ (function(){
var page=ui.create.div(''); var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','命令',start.firstChild,clickMode); var node=ui.create.div('.menubutton.large','命令',start.firstChild,clickMode);
ui.commandnode=node; ui.commandnode=node;
node.type='cmd'; node.type='cmd';
node._initLink=function(){
node.link=page; node.link=page;
page.classList.add('menu-sym'); page.classList.add('menu-sym');
menuUpdates.push(function(){ menuUpdates.push(function(){
@ -45329,11 +45384,13 @@
clearButton.listen(function(){ clearButton.listen(function(){
pre.innerHTML=''; pre.innerHTML='';
}); });
};
}()); }());
(function(){ (function(){
var page=ui.create.div(''); var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','战绩',start.firstChild,clickMode); var node=ui.create.div('.menubutton.large','战绩',start.firstChild,clickMode);
node.type='rec'; node.type='rec';
node._initLink=function(){
node.link=page; node.link=page;
page.style.paddingBottom='10px'; page.style.paddingBottom='10px';
var reset=function(){ var reset=function(){
@ -45362,16 +45419,17 @@
item.link=lib.config.all.mode[i]; item.link=lib.config.all.mode[i];
} }
} }
};
}()); }());
(function(){ (function(){
if(!window.indexedDB||window.nodb) return; if(!window.indexedDB||window.nodb) return;
var page=ui.create.div(''); var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','录像',start.firstChild,clickMode); var node=ui.create.div('.menubutton.large','录像',start.firstChild,clickMode);
node.type='video'; node.type='video';
node.link=page;
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
lib.videos=[]; lib.videos=[];
node._initLink=function(){
node.link=page;
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
store.openCursor().onsuccess=function(e){ store.openCursor().onsuccess=function(e){
var cursor=e.target.result; var cursor=e.target.result;
if(cursor){ if(cursor){
@ -45548,6 +45606,7 @@
} }
} }
}; };
};
}()); }());
@ -45618,6 +45677,7 @@
active=start.firstChild.firstChild; active=start.firstChild.firstChild;
active.classList.add('active'); active.classList.add('active');
} }
if(!active.link) active._initLink();
rightPane.appendChild(active.link); rightPane.appendChild(active.link);
}()); }());