懒加载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=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();
@ -39271,6 +39275,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){
@ -39283,6 +39288,7 @@
node.classList.add('active');
}
}
//“更多”下的内容
var map={};
var infoconfig=connectMenu?info.connect:info.config;
if(infoconfig){
@ -39463,6 +39469,7 @@
}
})
}
};
return node;
};
var modeorder=lib.config.modeorder||[];
@ -39488,6 +39495,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){
@ -39517,8 +39525,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){
@ -39596,6 +39608,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={};
@ -39983,6 +39996,7 @@
info.config.update(config,map);
}
}
};
return node;
};
@ -39993,6 +40007,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);
@ -40536,6 +40551,7 @@
createDash('音','音频文件',dash2);
createDash('字','字体文件',dash3);
createDash('全','全部文件',dash4);
};
}());
createModeConfig('others',start.firstChild);
@ -40544,6 +40560,7 @@
active=start.firstChild.firstChild;
active.classList.add('active');
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
}());
@ -40562,7 +40579,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){
@ -40571,6 +40592,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();
@ -40630,7 +40654,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){
@ -40639,6 +40662,8 @@
if(position2){
position.insertBefore(node,position2);
}
node._initLink=function(){
var info=lib.characterPack[mode];
node.link=page;
node.mode=mode;
page.node=node;
@ -40785,17 +40810,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{
@ -40932,6 +40957,7 @@
});
}
}
};
return node;
};
if(lib.config.show_favourite_menu&&!connectMenu&&Array.isArray(lib.config.favouriteCharacter)){
@ -40942,7 +40968,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';
}
@ -40989,6 +41017,7 @@
active.classList.add('active');
updateActive(active);
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
if(!connectMenu){
@ -41031,7 +41060,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){
@ -41040,6 +41073,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();
@ -41120,6 +41154,7 @@
if(node.innerHTML.length>=5){
node.classList.add('smallfont');
}
node._initLink=function(){
node.link=page;
node.mode=mode;
var list=[];
@ -41390,6 +41425,7 @@
}
ui.create.div('.menuplaceholder',page);
}
};
return node;
};
if(!connectMenu&&lib.config.show_ban_menu){
@ -41428,6 +41464,7 @@
active.classList.add('active');
updateActiveCard(active);
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
(function(){
@ -41587,7 +41624,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('扩展');
@ -41666,6 +41707,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]){
@ -41701,6 +41743,7 @@
}
page.appendChild(cfgnode);
}
};
return node;
};
for(var i in lib.extensionMenu){
@ -41713,6 +41756,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);
@ -43825,10 +43869,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(){
@ -44128,12 +44174,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();
}());
@ -44174,7 +44222,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='';
}
@ -44205,6 +44257,7 @@
ui.click.menuTab('其它');
clickMode.call(ui.commandnode);
};
//更新菜单有本体函数赋值,就不要懒加载了
(function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','更新',start.firstChild,clickMode);
@ -44900,6 +44953,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;
@ -45007,9 +45063,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');
@ -45153,12 +45206,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(){
@ -45329,11 +45384,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(){
@ -45362,16 +45419,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){
@ -45548,6 +45606,7 @@
}
}
};
};
}());
@ -45618,6 +45677,7 @@
active=start.firstChild.firstChild;
active.classList.add('active');
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
}());