keyboard-multihexa.js
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:9k
源码类别:

OA系统

开发平台:

C#

  1. var caps=0, lock=0, hexchars="0123456789ABCDEF", accent="0000", clavdeb=0
  2. var clav=new Array();j=0;for (i in Maj){clav[j]=i;j++}
  3. var ns6=((!document.all)&&(document.getElementById))
  4. var ie=document.all
  5. var langue=getCk();if (langue==""){langue=clav[clavdeb]}
  6. CarMaj=Maj[langue].split("|");CarMin=Min[langue].split("|")
  7. /*clavier*/
  8. var posClavierLeft=0, posClavierTop=0
  9. if (ns6){posClavierLeft=0;posClavierTop=80}
  10. else if (ie){posClavierLeft=0;posClavierTop=80}
  11. tracer("fond",posClavierLeft,posClavierTop,'<img src="Load.ashx?type=image&file=multiclavier.gif" width=404 height=152 border="0"><br />',"sign")
  12. /*touches*/
  13. var posX=new Array(0,28,56,84,112,140,168,196,224,252,280,308,336,42,70,98,126,154,182,210,238,266,294,322,350,50,78,106,134,162,190,218,246,274,302,330,64,92,120,148,176,204,232,260,288,316,28,56,84,294,322,350)
  14. var posY=new Array(14,14,14,14,14,14,14,14,14,14,14,14,14,42,42,42,42,42,42,42,42,42,42,42,42,70,70,70,70,70,70,70,70,70,70,70,98,98,98,98,98,98,98,98,98,98,126,126,126,126,126,126)
  15. var nbTouches=52
  16. for (i=0;i<nbTouches;i++){
  17. CarMaj[i]=((CarMaj[i]!="0000")?(fromhexby4tocar(CarMaj[i])):"")
  18. CarMin[i]=((CarMin[i]!="0000")?(fromhexby4tocar(CarMin[i])):"")
  19. if (CarMaj[i]==CarMin[i].toUpperCase()){
  20. cecar=((lock==0)&&(caps==0)?CarMin[i]:CarMaj[i]) 
  21. tracer("car"+i,posClavierLeft+6+posX[i],posClavierTop+3+posY[i],cecar,((dia[hexa(cecar)]!=null)?"simpledia":"simple"))
  22. tracer("majus"+i,posClavierLeft+15+posX[i],posClavierTop+1+posY[i],"&nbsp;","double")
  23. tracer("minus"+i,posClavierLeft+3+posX[i],posClavierTop+9+posY[i],"&nbsp;","double")
  24. }
  25. else{
  26. tracer("car"+i,posClavierLeft+6+posX[i],posClavierTop+3+posY[i],"&nbsp;","simple")
  27. cecar=CarMin[i]
  28. tracer("minus"+i,posClavierLeft+3+posX[i],posClavierTop+9+posY[i],cecar,((dia[hexa(cecar)]!=null)?"doubledia":"double"))
  29. cecar=CarMaj[i]
  30. tracer("majus"+i,posClavierLeft+15+posX[i],posClavierTop+1+posY[i],cecar,((dia[hexa(cecar)]!=null)?"doubledia":"double"))
  31. }
  32. }
  33. /*touches de fonctions*/
  34. var actC1=new Array(0,371,364,0,378,0,358,0,344,0,112,378)
  35. var actC2=new Array(0,0,14,42,42,70,70,98,98,126,126,126)
  36. var actC3=new Array(32,403,403,39,403,47,403,61,403,25,291,403)
  37. var actC4=new Array(11,11,39,67,67,95,95,123,123,151,151,151)
  38. var act  =new Array("kb-","kb+","Delete","Clear","Back","CapsLock","Enter","Shift","Shift","<|<","Space",">|>")
  39. var effet=new Array("clavscroll(-3)","clavscroll(3)","faire("del")","RAZ()","faire("bck")","bloq()","faire("\n")","haut()","haut()","faire("ar")","faire(" ")","faire("av")")
  40. var nbActions=12
  41. for (i=0;i<nbActions;i++){tracer("act"+i,posClavierLeft+1+actC1[i],posClavierTop-1+actC2[i],act[i],"action")}
  42. /*navigation*/
  43. var clavC1=new Array(35,119,203,287)
  44. var clavC2=new Array(0,0,0,0)
  45. var clavC3=new Array(116,200,284,368)
  46. var clavC4=new Array(11,11,11,11)
  47. for (i=0;i<4;i++){tracer("clav"+i,posClavierLeft+5+clavC1[i],posClavierTop-1+clavC2[i],clav[i],"clavier")}
  48. /*zones reactives*/
  49. tracer("masque",posClavierLeft,posClavierTop,'<img src="Load.ashx?type=image&file=1x1.gif" width=404 height=152 border="0" usemap="#clavier">')
  50. document.write('<map name="clavier">')
  51. for (i=0;i<nbTouches;i++){document.write('<area coords="'+posX[i]+','+posY[i]+','+(posX[i]+25)+','+(posY[i]+25)+'" href=# onClick='javascript:ecrire('+i+')'>')}
  52. for (i=0;i<nbActions;i++){document.write('<area coords="'+actC1[i]+','+actC2[i]+','+actC3[i]+','+actC4[i]+'" href=# onClick='javascript:'+effet[i]+''>')}
  53. for (i=0;i<4;i++){document.write('<area coords="'+clavC1[i]+','+clavC2[i]+','+clavC3[i]+','+clavC4[i]+'" href='javascript:charger('+i+')'>')}
  54. document.write('</map>')
  55. /*fonctions*/
  56. function ecrire(i){
  57. txt=rechercher()+"|";subtxt=txt.split("|")
  58. ceci=(lock==1)?CarMaj[i]:((caps==1)?CarMaj[i]:CarMin[i])
  59. if (test(ceci)){subtxt[0]+=cardia(ceci);distinguer(false)}
  60. else if(dia[accent]!=null&&dia[hexa(ceci)]!=null){distinguer(false);accent=hexa(ceci);distinguer(true)}
  61. else if(dia[accent]!=null){subtxt[0]+=fromhexby4tocar(accent)+ceci;distinguer(false)}
  62. else if(dia[hexa(ceci)]!=null){accent=hexa(ceci);distinguer(true)}
  63. else {subtxt[0]+=ceci}
  64. txt=subtxt[0]+"|"+subtxt[1]
  65. afficher(txt)
  66. if (caps==1){caps=0;MinusMajus()}
  67. }
  68. function faire(ceci){
  69. txt=rechercher()+"|";subtxt=txt.split("|")
  70. l0=subtxt[0].length
  71. l1=subtxt[1].length
  72. c1=subtxt[0].substring(0,(l0-2))
  73. c2=subtxt[0].substring(0,(l0-1))
  74. c3=subtxt[1].substring(0,1)
  75. c4=subtxt[1].substring(0,2)
  76. c5=subtxt[0].substring((l0-2),l0)
  77. c6=subtxt[0].substring((l0-1),l0)
  78. c7=subtxt[1].substring(1,l1)
  79. c8=subtxt[1].substring(2,l1)
  80. if(dia[accent]!=null){if(ceci==" "){ceci=fromhexby4tocar(accent)}distinguer(false)}
  81. switch (ceci){
  82. case("av") :if(escape(c4)!="%0D%0A"){txt=subtxt[0]+c3+"|"+c7}else{txt=subtxt[0]+c4+"|"+c8}break
  83. case("ar") :if(escape(c5)!="%0D%0A"){txt=c2+"|"+c6+subtxt[1]}else{txt=c1+"|"+c5+subtxt[1]}break
  84. case("bck"):if(escape(c5)!="%0D%0A"){txt=c2+"|"+subtxt[1]}else{txt=c1+"|"+subtxt[1]}break
  85. case("del"):if(escape(c4)!="%0D%0A"){txt=subtxt[0]+"|"+c7}else{txt=subtxt[0]+"|"+c8}break
  86. default:txt=subtxt[0]+ceci+"|"+subtxt[1];break
  87. }
  88. afficher(txt)
  89. }
  90. function RAZ(){txt="";if(dia[accent]!=null){distinguer(false)}afficher(txt)}
  91. function haut(){caps=1;MinusMajus()}
  92. function bloq(){lock=(lock==1)?0:1;MinusMajus()}
  93. /*fonctions de traitement du clavier*/
  94. function tracer(nom,gauche,haut,ceci,classe){ceci="<span class="+classe+">"+ceci+"</span>";document.write('<div id="'+nom+'" >'+ceci+'</div>');if (ns6){document.getElementById(nom).style.left=gauche+"px";document.getElementById(nom).style.top=haut+"px";}else if (ie){document.all(nom).style.left=gauche;document.all(nom).style.top=haut}}
  95. function retracer(nom,ceci,classe){ceci="<span class="+classe+">"+ceci+"</span>";if (ns6){document.getElementById(nom).innerHTML=ceci}else if (ie){doc=document.all(nom);doc.innerHTML=ceci}}
  96. function clavscroll(n){
  97. clavdeb+=n
  98. if (clavdeb<0){clavdeb=0}
  99. if (clavdeb>clav.length-4){clavdeb=clav.length-4}
  100. for (i=clavdeb;i<clavdeb+4;i++){retracer("clav"+(i-clavdeb),clav[i],"clavier")}
  101. if (clavdeb==0){retracer("act0","&nbsp;","action")}else {retracer("act0",act[0],"action")}
  102. if (clavdeb==clav.length-4){retracer("act1","&nbsp;","action")}else {retracer("act1",act[1],"action")}
  103. }
  104. function charger(i){
  105. langue=clav[i+clavdeb];setCk(langue);accent="0000"
  106. CarMaj=Maj[langue].split("|");CarMin=Min[langue].split("|")
  107. for (i=0;i<nbTouches;i++){
  108. CarMaj[i]=((CarMaj[i]!="0000")?(fromhexby4tocar(CarMaj[i])):"")
  109. CarMin[i]=((CarMin[i]!="0000")?(fromhexby4tocar(CarMin[i])):"")
  110. if (CarMaj[i]==CarMin[i].toUpperCase()){
  111. cecar=((lock==0)&&(caps==0)?CarMin[i]:CarMaj[i]) 
  112. retracer("car"+i,cecar,((dia[hexa(cecar)]!=null)?"simpledia":"simple"))
  113. retracer("minus"+i,"&nbsp;")
  114. retracer("majus"+i,"&nbsp;")
  115. }
  116. else{
  117. retracer("car"+i,"&nbsp;")
  118. cecar=CarMin[i]
  119. retracer("minus"+i,cecar,((dia[hexa(cecar)]!=null)?"doubledia":"double"))
  120. cecar=CarMaj[i]
  121. retracer("majus"+i,cecar,((dia[hexa(cecar)]!=null)?"doubledia":"double"))
  122. }
  123. }
  124. }
  125. function distinguer(oui){
  126. for (i=0;i<nbTouches;i++){
  127. if (CarMaj[i]==CarMin[i].toUpperCase()){
  128. cecar=((lock==0)&&(caps==0)?CarMin[i]:CarMaj[i]) 
  129. if(test(cecar)){retracer("car"+i,oui?(cardia(cecar)):cecar,oui?"simpledia":"simple")}
  130. }
  131. else{
  132. cecar=CarMin[i]
  133. if(test(cecar)){retracer("minus"+i,oui?(cardia(cecar)):cecar,oui?"doubledia":"double")}
  134. cecar=CarMaj[i]
  135. if(test(cecar)){retracer("majus"+i,oui?(cardia(cecar)):cecar,oui?"doubledia":"double")}
  136. }
  137. }
  138. if (!oui){accent="0000"}
  139. }
  140. function MinusMajus(){
  141. for (i=0;i<nbTouches;i++){
  142. if (CarMaj[i]==CarMin[i].toUpperCase()){
  143. cecar=((lock==0)&&(caps==0)?CarMin[i]:CarMaj[i]) 
  144. retracer("car"+i,(test(cecar)?cardia(cecar):cecar),((dia[hexa(cecar)]!=null||test(cecar))?"simpledia":"simple"))
  145. }
  146. }
  147. }
  148. function test(cecar){return(dia[accent]!=null&&dia[accent][hexa(cecar)]!=null)}
  149. function cardia(cecar){return(fromhexby4tocar(dia[accent][hexa(cecar)]))}
  150. function fromhex(inval){out=0;for (a=inval.length-1;a>=0;a--){out+=Math.pow(16,inval.length-a-1)*hexchars.indexOf(inval.charAt(a))}return out}
  151. function fromhexby4tocar(ceci){out4=new String();for (l=0;l<ceci.length;l+=4){out4+=String.fromCharCode(fromhex(ceci.substring(l,l+4)))}return out4}
  152. function tohex(inval){return hexchars.charAt(inval/16)+hexchars.charAt(inval%16)}
  153. function tohex2(inval){return tohex(inval/256)+tohex(inval%256)}
  154. function hexa(ceci){out="";for (k=0;k<ceci.length;k++){out+=(tohex2(ceci.charCodeAt(k)))}return out}
  155. function getCk(){fromN=document.cookie.indexOf("langue=")+0;if((fromN)!=-1){fromN+=7;toN=document.cookie.indexOf(";",fromN)+0;if(toN==-1){toN=document.cookie.length}return unescape(document.cookie.substring(fromN,toN))}return ""}
  156. function setCk(inval){if(inval!=null){exp=new Date();time=365*60*60*24*1000;exp.setTime(exp.getTime()+time);document.cookie=escape("langue")+"="+escape(inval)+"; "+"expires="+exp.toGMTString()}}