📄 menugenerator.js
字号:
this.down4="";
this.normal_darkborder4="";
this.normal_lightborder4="";
this.normal_arrow4="";
this.normal_text4="";
this.over_darkborder4="";
this.over_lightborder4="";
this.over_arrow4="";
this.over_text4="";
this.down_darkborder4="";
this.down_lightborder4="";
this.down_arrow4="";
this.down_text4="";
for(i in this){
if(i.indexOf("line_")>=0){
this.wx(i,"line4");
}
else if(i.indexOf("item_")>=0){
this.wx(i,"item4");
}
else if(i.indexOf("menu_")>=0){
str1=i.substr(5);
if(str1.indexOf("darkborder_")>=0)this.wx(i,"menu_darkborder4");
else if(str1.indexOf("lightborder_")>=0)this.wx(i,"menu_lightborder4");
else if(str1.indexOf("4")<0)this.wx(i,"menu4");
}
else if(i.indexOf("normal_")>=0){
str1=i.substr(7);
if(str1.indexOf("darkborder_")>=0)this.wx(i,"normal_darkborder4");
else if(str1.indexOf("lightborder_")>=0)this.wx(i,"normal_lightborder4");
else if(str1.indexOf("arrow_")>=0)this.wx(i,"normal_arrow4");
else if(str1.indexOf("text_")>=0)this.wx(i,"normal_text4");
else if(str1.indexOf("4")<0)this.wx(i,"normal4");
}
else if(i.indexOf("over_")>=0){
str1=i.substr(5);
if(str1.indexOf("darkborder_")>=0)this.wx(i,"over_darkborder4");
else if(str1.indexOf("lightborder_")>=0)this.wx(i,"over_lightborder4");
else if(str1.indexOf("arrow_")>=0)this.wx(i,"over_arrow4");
else if(str1.indexOf("text_")>=0)this.wx(i,"over_text4");
else if(str1.indexOf("4")<0)this.wx(i,"over4");
}
else if(i.indexOf("down_")>=0){
str1=i.substr(5);
if(str1.indexOf("darkborder_")>=0)this.wx(i,"down_darkborder4");
else if(str1.indexOf("lightborder_")>=0)this.wx(i,"down_lightborder4");
else if(str1.indexOf("arrow_")>=0)this.wx(i,"down_arrow4");
else if(str1.indexOf("text_")>=0)this.wx(i,"down_text4");
else if(str1.indexOf("4")<0)this.wx(i,"down4");
}
}
for(i in this){
if(i.lastIndexOf("4")>=0){
if(this[i].length>0){
var tab=(i.indexOf("normal")>=0||i.indexOf("over")>=0||i.indexOf("down")>=0)?"\t":"";
var n=i.indexOf("_");
str1=i.substring(n+1,i.length-1);
if(n>=0)this[i]="\n\t\t\t"+tab+"<"+str1+this[i]+" />";
else this[i]="\n\t\t"+tab+"<"+str1+this[i];
}
}
}
this.menu_darkborder4+=this.menu_lightborder4;
this.normal_text4+=this.normal_arrow4+this.normal_darkborder4+this.normal_lightborder4;
this.over_text4+=this.over_arrow4+this.over_darkborder4+this.over_lightborder4;
this.down_text4+=this.down_arrow4+this.down_darkborder4+this.down_lightborder4;
if(this.menu_darkborder4.length>0){
if(this.menu4.length==0)this.menu4="\n\t\t<menu";
this.menu4+=">"+this.menu_darkborder4+"\n\t\t</menu>";
}
else if(this.menu4.length>0)this.menu4+=" />";
if(this.normal_text4.length>0){
if(this.normal4.length==0)this.normal4="\n\t\t\t<normal";
this.normal4+=">"+this.normal_text4+"\n\t\t\t</normal>";
}
else if(this.normal4.length>0)this.normal4+=" />";
if(this.over_text4.length>0){
if(this.over4.length==0)this.over4="\n\t\t\t<over";
this.over4+=">"+this.over_text4+"\n\t\t\t</over>";
}
else if(this.over4.length>0)this.over4+=" />";
if(this.down_text4.length>0){
if(this.down4.length==0)this.down4="\n\t\t\t<down";
this.down4+=">"+this.down_text4+"\n\t\t\t</down>";
}
else if(this.down4.length>0)this.down4+=" />";
var xml="";
xml+=this.menu4;
var nodxml="";
nodxml+=this.normal4;
nodxml+=this.over4;
nodxml+=this.down4;
if(nodxml.length>0){
if(this.item4.length==0)this.item4="\n\t\t<item";
xml+=this.item4+">"+nodxml+"\n\t\t</item>";
}
else xml+=this.item4+" />";
if(this.line4.length>0)xml+=this.line4+" />";
var pxml=(this.parent.length>0)?" parent=\""+this.parent+"\"":"";
if(xml.length>0)xml="\n\t<style name=\""+this.name+"\""+pxml+">"+xml+"\n\t</style>";
else xml="\n\t<style name=\""+this.name+"\""+pxml+" />";
return xml;
}
}
//------------------------------------------------------------------------------
var spxml=new function(){
this.styles=new Object();
this.styleCount=0;
this.uniqueCount=0;
this.cursty=null;
this.addStyle=function(prop){
var style=new Style(prop);
style.index=this.styleCount;
this.styles[this.styleCount]=style;
this.styleCount++;
this.uniqueCount++;
if(prop==null)style.name="style"+this.uniqueCount;
return style;
}
this.menu=new MenuTag(null,0);
this.menu.add(-1);
this.menu.style=1;
selMenu=1;
}
//------------------------------------------------------------------------------
function lineOnclick(){
spform2.submenu.disabled=this.checked;
var menu=objMenu[selMenu];
if(this.checked==true){
menu.style=0;
menu.label="";
menu.href="";
spform2.label.value="";
if(menu.type==-1){
menu.p.add(-1);
menu.type=3;
}
else if(menu.type==2){
menu.type=3;
}
}
else{
menu.type=2;
spform2.label.focus();
}
spxml.menu.spdisplay();
}
//------------------------------------------------------------------------------
function submenuOnclick(){
var menu=objMenu[selMenu];
var type=menu.type;
spform2.line.disabled=this.checked;
if(this.checked==true){
if(type==-1){
menu.type=1;
menu.p.add(-1);
menu.add(-1);
}
else if(type==2){
menu.type=1;
menu.add(-1);
menu.href="";
}
}
else{
menu.type=2;
menu.style=0;
for(i=0;i<menu.childCount;i++){
menu.childs[i]=null;
menu.childCount--;
}
}
spform2.label.focus();
spxml.menu.spdisplay();
}
//------------------------------------------------------------------------------
function hrefOnkeyup(){
var menu=objMenu[selMenu];
if(menu.type==2){
menu.href=this.value;
}
else{
this.value="";
return false;
}
}
//------------------------------------------------------------------------------
function labelOnkeyup(){
var menu=objMenu[selMenu];
if(menu.type<0){
menu.p.add(-1);
menu.type=2;
}
else if(menu.type==0||menu.type==3){
this.value="";
return false;
}
menu.label=this.value;
spxml.menu.spdisplay();
}
//------------------------------------------------------------------------------
function xtylesOnchange(){
this.sponblur();
var menu=objMenu[selMenu];
if(menu.type<0){
this.options.selectedIndex=0;
}
else if(menu.type==0&&this.options.selectedIndex<1){
this.options.selectedIndex=1;
menu.style=1;
}
else if(menu.type>1){
this.options.selectedIndex=0;
}
else menu.style=this.options.selectedIndex;
this.form["styles"].value=this.value;
spxml.menu.spdisplay();
}
//------------------------------------------------------------------------------
function fntree1(id,metot){
var menu=objMenu[id];
if((id!=selMenu && metot==null) || metot!=null){
selMenu=id;
spform2.label.value=menu.label;
spform2.href.value=menu.href;
spform2.submenu.checked=false;
spform2.line.checked=false;
spform2.submenu.disabled=false;
spform2.line.disabled=false;
if(menu.type<0){
spform2.xtyles.options.selectedIndex=0;
}
else if(menu.type==0){
spform2.xtyles.options.selectedIndex=menu.style;
spform2.submenu.disabled=true;
spform2.line.disabled=true;
}
else if(menu.type==1){
spform2.submenu.checked=true;
spform2.line.disabled=true;
spform2.xtyles.options.selectedIndex=menu.style;
}
else if(menu.type==2){
spform2.xtyles.options.selectedIndex=0;
}
else if(menu.type==3){
spform2.line.checked=true;
spform2.submenu.disabled=true;
spform2.xtyles.options.selectedIndex=0;
}
spform2.styles.value=spform2.xtyles.value;
spxml.menu.spdisplay();
}
if(menu.type!=0)spform2.label.focus();
}
//------------------------------------------------------------------------------
function fnDelete(){
var menu=objMenu[selMenu];
if(menu.type>0){
var ret=menu.del();
if(ret==1){
menu.style=0;
fntree1(objMenu[selMenu].id,1);
}
spxml.menu.spdisplay();
}
}
//------------------------------------------------------------------------------
function menuChange(menu,it1,it2){
if(menu.childs[it1].type<=0||menu.childs[it2].type<=0)return;
var temp=menu.childs[it1].childIndex;
menu.childs[it1].childIndex=menu.childs[it2].childIndex;
menu.childs[it2].childIndex=temp;
temp=menu.childs[it1];
menu.childs[it1]=menu.childs[it2];
menu.childs[it2]=temp;
}
//------------------------------------------------------------------------------
function fnUp(){
var menu=objMenu[selMenu];
if(menu.type>0){
var p=menu.p;
var index=menu.childIndex;
if(index>0){
menuChange(p,index,index-1);
spxml.menu.spdisplay();
}
}
}
//------------------------------------------------------------------------------
function fnDown(){
var menu=objMenu[selMenu];
if(menu.type>0){
var p=menu.p;
var index=menu.childIndex;
if(index<p.childCount-1){
menuChange(p,index,index+1);
spxml.menu.spdisplay();
}
}
}
//------------------------------------------------------------------------------
function MenuTag(p,type){
this.id=countMenu++;
objMenu[this.id]=this;
this.childIndex=0;
this.childCount=0;
this.type=type;
if(p!=null){
this.p=p;
this.index=p.index+1;
this.childIndex=p.childCount;
p.childCount++;
}
else {
this.p=null;
this.childIndex=0;
this.index=0;
}
this.style=0;
this.label="";
this.href="";
this.width="";
this.count=0;
this.childs=new Object();
this.add=function(type){
var obj=new MenuTag(this,type);
this.childs[obj.childIndex]=obj;
return obj;
}
this.del=function(){
var p=this.p;
if(p!=null){
var temp=null;
var index=this.childIndex;
if(index>0) selMenu=p.childs[index-1].id;
else if(p.childs[index+1].type!=-1)selMenu=p.childs[index+1].id;
else selMenu=p.id;
for(i=index;i<p.childCount;i++){
p.childs[i]=p.childs[i+1];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -