部分代码写法优化

This commit is contained in:
shijian 2023-11-23 23:16:14 +08:00
parent 7e56e00ae2
commit a0bf1cfdee
1 changed files with 43 additions and 42 deletions

View File

@ -51390,44 +51390,48 @@ new Promise(resolve=>{
node._initLink=function(){ node._initLink=function(){
node.link=page; node.link=page;
page.classList.add('menu-sym'); page.classList.add('menu-sym');
const text=document.createElement('div'); const text=document.createElement('div');
text.style.width='194px'; text.css({
text.style.height='124px'; 'width':'194px',
text.style.padding='3px'; 'height':'124px',
text.style.borderRadius='2px'; 'padding':'3px',
text.style.boxShadow='rgba(0, 0, 0, 0.2) 0 0 0 1px'; 'borderRadius':'2px',
text.style.textAlign='left'; 'boxShadow':'rgba(0, 0, 0, 0.2) 0 0 0 1px',
text.style.webkitUserSelect='initial'; 'textAlign':'left',
text.style.overflow='scroll'; 'webkitUserSelect':'initial',
text.style.position='absolute'; 'overflow':'scroll',
text.style.left='30px'; 'position':'absolute',
text.style.top='50px'; 'left':'30px',
text.style.wordBreak='break-all'; 'top':'50px',
'wordBreak':'break-all'
});
const pre=ui.create.node('pre.fullsize',text); const pre=ui.create.node('pre.fullsize',text);
pre.style.margin=0; text.css.call(pre,{
pre.style.padding=0; 'margin':'0',
pre.style.position='relative'; 'padding':'0',
pre.style.webkitUserSelect = pre.style.userSelect = 'text'; 'position':'relative',
'webkitUserSelect': 'text',
'userSelect':'text'
});
lib.setScroll(pre); lib.setScroll(pre);
page.appendChild(text); page.appendChild(text);
// var caption=ui.create.div('','输入命令',page);
// caption.style.margin='6px';
// caption.style.position='absolute';
// caption.style.width='120px';
// caption.style.top='129px';
// caption.style.left='64px';
const text2=document.createElement('input'); const text2=document.createElement('input');
text2.style.width='200px'; text.css.call(text2,{
text2.style.height='20px'; 'width':'200px',
text2.style.padding='0'; 'height':'20px',
text2.style.position='absolute'; 'padding':'0',
text2.style.top='15px'; 'position': 'absolute',
text2.style.left='30px'; 'top':'15px',
text2.style.resize='none'; 'left':'30px',
text2.style.border='none'; 'resize':'none',
text2.style.borderRadius='2px'; 'border':'none',
text2.style.boxShadow='rgba(0, 0, 0, 0.2) 0 0 0 1px'; 'borderRadius':'2px',
'boxShadow':'rgba(0, 0, 0, 0.2) 0 0 0 1px'
});
const g={}; const g={};
const logs=[]; const logs=[];
let logindex=-1; let logindex=-1;
@ -51506,7 +51510,7 @@ new Promise(resolve=>{
return eval(reg.test(value)?('('+value+')'):value); return eval(reg.test(value)?('('+value+')'):value);
} }
`))(proxyWindow); `))(proxyWindow);
const runCommand=function(e){ const runCommand=()=>{
if(text2.value&&!['up','down'].contains(text2.value)){ if(text2.value&&!['up','down'].contains(text2.value)){
logindex=-1; logindex=-1;
logs.unshift(text2.value); logs.unshift(text2.value);
@ -51545,10 +51549,9 @@ new Promise(resolve=>{
else{ else{
if(!game.observe&&!game.online){ if(!game.observe&&!game.online){
try{ try{
var value=text2.value.trim(); let value=text2.value.trim();
if(value.endsWith(";")) value=value.slice(0,-1).trim(); if(value.endsWith(";")) value=value.slice(0,-1).trim();
var result=fun(value); game.print(fun(value));
game.print(result);
} }
catch(e){ catch(e){
game.print(e); game.print(e);
@ -51557,7 +51560,7 @@ new Promise(resolve=>{
text2.value=''; text2.value='';
} }
} }
text2.addEventListener('keydown',function(e){ text2.addEventListener('keydown',e=>{
if(e.keyCode==13){ if(e.keyCode==13){
runCommand(); runCommand();
} }
@ -51632,13 +51635,11 @@ new Promise(resolve=>{
text.scrollTop=text.scrollHeight; text.scrollTop=text.scrollHeight;
} }
if(_status.toprint){ if(_status.toprint){
for(var i=0;i<_status.toprint.length;i++){ game.print(...status.toprint);
game.print.apply(this,_status.toprint[i]);
}
delete _status.toprint; delete _status.toprint;
} }
runButton.listen(runCommand); runButton.listen(runCommand);
clearButton.listen(function(){ clearButton.listen(()=>{
pre.innerHTML=''; pre.innerHTML='';
}); });
}; };