欢迎来到福编程网,本站提供各种互联网专业知识!

疯掉了,尽然有js写的操作系统

发布时间:2007-04-23 作者: 来源:转载
http://www.masswerk.at/jsuix///JS/UIXv0.44//(c)mass:werk(N.Landsteiner)2003//allrightsreserved//termguivarconf_term_x=102;varconf_term_y=34;varconf_kbd_offset=34;vartermImgPath='jsuix_support/';vartermDiv='termDiv';vartermBgColor='
http://www.masswerk.at/jsuix/

//JS/UIXv0.44
//(c)mass:werk(N.Landsteiner)2003
//allrightsreserved

//termgui

varconf_term_x=102;
varconf_term_y=34;
varconf_kbd_offset=34;
vartermImgPath='jsuix_support/';
vartermDiv='termDiv';
vartermBgColor='#181818';
vartermFrameColor='#555555';
vartermPageColor='#222222';
varconf_repeat_delay1=320;
varconf_repeat_delay2=170;

vartermKbdDiv='termKbdDiv';
vartermKbdBgColor='#222222';
varkeycapspath='jsuix_support/keycaps/';

vartermSubDivs=false;
vartermLayers=false;
vartermDocNS4=null;
vartermStringStart='';
vartermStringEnd='';

vartermKbdDocNS4=null;
vartermKbdOn=false;
varkeycapsShift=false;
varkeycapsCpslk=false;
varkeycapsShiftRef=newArray();
varkeycapsCpslkRef=newArray();

vartermSpecials=newArray();
termSpecials[0]='';
termSpecials[1]='$';
termSpecials[2]='';
termSpecials[3]='?';
termSpecials[4]='#';
termSpecials[32]='';
termSpecials[34]='"';
termSpecials[38]='&';
termSpecials[60]='<';
termSpecials[62]='>';
termSpecials[127]='◊';

vartermStyles=newArray(1,2,4,8);
vartermStyleOpen=newArray();
vartermStyleClose=newArray();
termStyleOpen[1]='';
termStyleClose[1]='';
termStyleOpen[2]='';
termStyleClose[2]='
';
termStyleOpen[4]='';
termStyleClose[4]='
';
termStyleOpen[8]='';
termStyleClose[8]='
';


//buttonsUI

vartermImgNames=newArray('left_lo','left_hi','right_lo','right_hi','delete_lo','delete_hi','esc_lo','esc_hi','kbd_show_lo','kbd_show_hi','kbd_hide_lo','kbd_hide_hi');
vartermImages=newArray();

functiontermImgPreload(path,imgnames){
for(vari=0;ivarn=imgnames[i];
termImages[n]=newImage();
termImages[n].src=path+n+'.gif'
}
}

if(document.images)termImgPreload(termImgPath,termImgNames);

functiontermSetImg(n,v){
if(document.images){
varimg=(termLayers)?termDocNS4.images['term_'+n]:document.images['term_'+n];
varstat=(v)?'_hi':'_lo';
img.src=termImages[n+stat].src
}
}


//UIkeyboard
//keymaps(200=leftshift,202=rightshift,204=CpsLock)

vartermKeyMap=[
[96,49,50,51,52,53,54,55,56,57,48,45,61,8],
[27,113,119,101,114,116,121,117,105,111,112,91,93,13],
[204,97,115,100,102,103,104,106,107,108,59,39,35],
[200,92,122,120,99,118,98,110,109,44,46,47,30,202],
[32,28,31,29]
];
vartermKeyMapShift=[
[126,33,34,35,36,37,94,38,42,40,41,95,43,8],
[27,81,87,69,82,84,89,85,73,79,80,123,125,13],
[204,65,83,68,70,71,72,74,75,76,58,34,64],
[200,124,90,88,67,86,66,78,77,60,62,63,30,202],
[32,28,31,29]
];
vartermKeyMapCpslk=[
[96,49,50,51,52,53,54,55,56,57,48,45,61,8],
[27,81,87,69,82,84,89,85,73,79,80,91,93,13],
[204,65,83,68,70,71,72,74,75,76,59,39,35],
[200,92,90,88,67,86,66,78,77,44,46,47,30,202],
[32,28,31,29]
];
vartermKeyWdth=[
[35,35,35,35,35,35,35,35,35,35,35,35,35,69],
[55,35,35,35,35,35,35,35,35,35,35,35,35,0],
[65,35,35,35,35,35,35,35,35,35,35,35,35],
[49,35,35,35,35,35,35,35,35,35,35,35,35,54],
[252,35,35,35]
];

varkeycapsImgNames=newArray(200,201,202,203,204,205);

functiontermKeyCaps(k){
if((k<28)&&(k>=32)&&(repeatTimer))clearTimeout(repeatTimer);
if(k==204){
keycapsCpslk=(!keycapsCpslk);
varcnr=(keycapsCpslk)?205:204;
termKbdSetImg(204,cnr)
}
elseif((k==200)||(k==202)){
keycapsShift=(!keycapsShift);
varm=(keycapsShift)?1:0;
termKbdSetImg(200,200+m);
termKbdSetImg(202,202+m)
}
else{
varch=0;
if(keycapsShift){
ch=keycapsShiftRef[k]
keycapsShift=false;
termKbdSetImg(200,200);
termKbdSetImg(202,202)
}
elseif(keycapsCpslk)ch=keycapsCpslkRef[k]
elsech=k;
keyHandler({which:ch,jsuix_remapped:true})
}
}

functiontermKbdSetImg(n,v){
if(document.images){
varimg=(termLayers)?termKbdDocNS4.images['key'+n]:document.images['key'+n];
img.src=termImages[v].src
}
}


functiontermSetKbdButton(v){
if(document.images){
varimg=(termLayers)?termDocNS4.images.term_kbd_show:document.images.term_kbd_show;
varn=(termKbdOn)?'kbd_hide':'kbd_show';
varstat=(v)?'_hi':'_lo';
img.src=termImages[n+stat].src
}
}

functiontermKbdShow(){
if(termKbdOn){
setDivVisibility(termKbdDiv,0);
termKbdOn=false;
termSetKbdButton(0)
}
else{
termImgPreload(keycapspath,keycapsImgNames);
keycapsShift=false;
keycapsCpslk=false;
vars='n';
s+='n';
s+=''+termMakeKbd()+'n';
s+'n';
s+='n';
s+='';
writeElement(termKbdDiv,s);
setDivXY(termKbdDiv,conf_term_x,conf_term_y+conf_kbd_offset+conf_rows*conf_rowheigt);
if(termLayers)termKbdDocNS4=document.layers[termKbdDiv].document;
termKbdOn=true;
setDivVisibility(termKbdDiv,1);
termSetKbdButton(0)
}
}

functiontermMakeKbd(){
vars='n';
for(vari=0;is+='';
for(vark=0;kvarkc=termKeyMap[i][k];
keycapsShiftRef[kc]=termKeyMapShift[i][k];
keycapsCpslkRef[kc]=termKeyMapCpslk[i][k];
if(kc==13){
s+='';
continue
};
if(kc==32)s+=''
elseif(kc==28){
s+='';
s+='';
continue
}
elseif(kc==29){
s+='';
continue
}
elseif(kc==8){
s+='';
continue
}
s+='';
if(kc==35)s+='';
};
s+='n';
};
s+='';
returns
}


//termUI

functiontermHide(){
if(repeatTimer)clearTimeout(repeatTimer);
if(termKbdOn)termKbdShow();
setDivVisibility(termDiv,0)
}

functionmakeTerm(){
window.status='Buildingterminal...';
termLayers=(document.layers)?true:false;
termSubDivs=(navigator.userAgent.indexOf('Gecko')<0);
vars='';
s+='n';
s+='n';
varrstr='';
for(varc=0;cfor(varr=0;rvarid=((termLayers)||(termSubDivs))?'':'ID="term_'+r+'"';
s+=''+rstr+'n';
};
s+='n';
s+='n';

s+='nn';
s+='n';

s+='n';
s+='n';
s+='n';
s+='n';
s+='n';
s+='n';
s+='n';
if(termLayers){
for(varr=0;rs+='n'
};
termDocNS4=document.layers[termDiv].document;
termStringStart='';
termStringEnd='';
}
elseif(termSubDivs){
for(varr=0;rs+='

n'
};
termStringStart='';
termStringEnd='';
};
writeElement(termDiv,s);
setDivXY(termDiv,conf_term_x,conf_term_y);
setDivVisibility(termDiv,1);
window.status=''
}

functiontermDisplay(r){
vars=termStringStart;
varcurStyle=0;
for(vari=0;ivarc=term[r][i];
varcs=termStyle[r][i];
if(cs!=curStyle){
if(curStyle){
for(vark=termStyles.length-1;k>=0;k--){
varst=termStyles[k];
if(curStyle&st)s+=termStyleClose[st];
}
};
curStyle=cs;
for(vark=0;kvarst=termStyles[k];
if(curStyle&st)s+=termStyleOpen[st];
}
};
s+=(termSpecials[c])?termSpecials[c]:String.fromCharCode(c);
};
if(curStyle>0){
for(vark=termStyles.length-1;k>=0;k--){
varst=termStyles[k];
if(curStyle&st)s+=termStyleClose[st];
}
};
s+=termStringEnd;
writeElement('term_'+r,s,termDocNS4)
}

functiontermGuiReady(){
ready=true;
if(termGuiElementReady(termDiv,self.document)){
for(varr=0;rif(termGuiElementReady('term_'+r,termDocNS4)==false){
ready=false;
break
}
}
}
elseready=false;
returnready
}


functioncursorKbdLeft(){
keyHandler({which:28})
}

functioncursorKbdRight(){
keyHandler({which:29})
}

functiontermKbdBackspace(){
keyHandler({which:8})
}

functiontermKbdEsc(){
keyHandler({which:27})
}

functiontermKbdClear(){
if((!cnslLock)&&(!cnslRawMode))cnslReset();
}

//UI-buttonrepeat

functionrepeatSet(cmd,on){
if(repeatTimer)clearTimeout(repeatTimer);
repeatTimer=setTimeout('repeatDo("'+cmd+'")',conf_repeat_delay1);
}

functionrepeatClear(){
if(repeatTimer)clearTimeout(repeatTimer);
}

functionrepeatDo(cmd){
if(repeatTimer)clearTimeout(repeatTimer);
if(cmd=='left')cursorKbdLeft()
elseif(cmd=='right')cursorKbdRight()
elseif(cmd=='backspace')termKbdBackspace();
repeatTimer=setTimeout('repeatDo("'+cmd+'")',conf_repeat_delay2);
}


//basicdynamics

functionwriteElement(e,t,d){
if(document.layers){
vardoc=(d)?d:self.document;
doc.layers[e].document.open();
doc.layers[e].document.write(t);
doc.layers[e].document.close()
}
elseif(document.getElementById){
varobj=document.getElementById(e);
obj.innerHTML=t
}
elseif(document.all){
document.all[e].innerHTML=t
}
}

functionsetDivXY(d,x,y){
if(document.layers){
document.layers[d].moveTo(x,y)
}
elseif(document.getElementById){
varobj=document.getElementById(d);
obj.style.left=x+'px';
obj.style.top=y+'px'
}
elseif(document.all){
document.all[d].style.left=x+'px';
document.all[d].style.top=y+'px'
}
}

functionsetDivVisibility(d,v){
if(document.layers){
document.layers[d].visibility=(v)?'show':'hide';
}
elseif(document.getElementById){
varobj=document.getElementById(d);
obj.style.visibility=(v)?'visible':'hidden';
}
elseif(document.all){
document.all[d].style.visibility=(v)?'visible':'hidden';
}
}

functiontermGuiElementReady(e,d){
if(document.layers){
vardoc=(d)?d:self.document;
return((doc)&&(doc.layers[e]))?true:false
}
elseif(document.getElementById){
return(document.getElementById(e))?true:false
}
elseif(document.all){
return(document.all[e])?true:false
}
elsereturnfalse
}

//eof

相关推荐