1 | /*
|
---|
2 | * FCKeditor - The text editor for internet
|
---|
3 | * Copyright (C) 2003-2006 Frederico Caldeira Knabben
|
---|
4 | *
|
---|
5 | * Licensed under the terms of the GNU Lesser General Public License:
|
---|
6 | * http://www.opensource.org/licenses/lgpl-license.php
|
---|
7 | *
|
---|
8 | * For further information visit:
|
---|
9 | * http://www.fckeditor.net/
|
---|
10 | *
|
---|
11 | * "Support Open Source software. What about a donation today?"
|
---|
12 | *
|
---|
13 | * File Name: multihexa.js
|
---|
14 | * Scripts for the fck_universalkey.html page.
|
---|
15 | * Definition des 104 caracteres en hexa unicode.
|
---|
16 | *
|
---|
17 | * File Authors:
|
---|
18 | * Michel Staelens (michel.staelens@wanadoo.fr)
|
---|
19 | * Bernadette Cierzniak
|
---|
20 | * Abdul-Aziz Al-Oraij (top7up@hotmail.com)
|
---|
21 | */
|
---|
22 |
|
---|
23 | var caps=0, lock=0, hexchars="0123456789ABCDEF", accent="0000", keydeb=0
|
---|
24 | var key=new Array();j=0;for (i in Maj){key[j]=i;j++}
|
---|
25 | var ns6=((!document.all)&&(document.getElementById))
|
---|
26 | var ie=document.all
|
---|
27 |
|
---|
28 | var langue=getCk();
|
---|
29 | if (langue==""){
|
---|
30 | langue=key[keydeb]
|
---|
31 | }
|
---|
32 | CarMaj=Maj[langue].split("|");CarMin=Min[langue].split("|")
|
---|
33 |
|
---|
34 | /*unikey*/
|
---|
35 | var posUniKeyLeft=0, posUniKeyTop=0
|
---|
36 | if (ns6){posUniKeyLeft=0;posUniKeyTop=60}
|
---|
37 | else if (ie){posUniKeyLeft=0;posUniKeyTop=60}
|
---|
38 | tracer("fond",posUniKeyLeft,posUniKeyTop,'<img src="fck_universalkey/keyboard_layout.gif" width=404 height=152 border="0"><br />',"sign")
|
---|
39 | /*touches*/
|
---|
40 | 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)
|
---|
41 | 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)
|
---|
42 | var nbTouches=52
|
---|
43 | for (i=0;i<nbTouches;i++){
|
---|
44 | CarMaj[i]=((CarMaj[i]!="0000")?(fromhexby4tocar(CarMaj[i])):"")
|
---|
45 | CarMin[i]=((CarMin[i]!="0000")?(fromhexby4tocar(CarMin[i])):"")
|
---|
46 | if (CarMaj[i]==CarMin[i].toUpperCase()){
|
---|
47 | cecar=((lock==0)&&(caps==0)?CarMin[i]:CarMaj[i])
|
---|
48 | tracer("car"+i,posUniKeyLeft+6+posX[i],posUniKeyTop+3+posY[i],cecar,((dia[hexa(cecar)]!=null)?"simpledia":"simple"))
|
---|
49 | tracer("majus"+i,posUniKeyLeft+15+posX[i],posUniKeyTop+1+posY[i]," ","double")
|
---|
50 | tracer("minus"+i,posUniKeyLeft+3+posX[i],posUniKeyTop+9+posY[i]," ","double")
|
---|
51 | }
|
---|
52 | else{
|
---|
53 | tracer("car"+i,posUniKeyLeft+6+posX[i],posUniKeyTop+3+posY[i]," ","simple")
|
---|
54 | cecar=CarMin[i]
|
---|
55 | tracer("minus"+i,posUniKeyLeft+3+posX[i],posUniKeyTop+9+posY[i],cecar,((dia[hexa(cecar)]!=null)?"doubledia":"double"))
|
---|
56 | cecar=CarMaj[i]
|
---|
57 | tracer("majus"+i,posUniKeyLeft+15+posX[i],posUniKeyTop+1+posY[i],cecar,((dia[hexa(cecar)]!=null)?"doubledia":"double"))
|
---|
58 | }
|
---|
59 | }
|
---|
60 | /*touches de fonctions*/
|
---|
61 | var actC1=new Array(0,371,364,0,378,0,358,0,344,0,112,378)
|
---|
62 | var actC2=new Array(0,0,14,42,42,70,70,98,98,126,126,126)
|
---|
63 | var actC3=new Array(32,403,403,39,403,47,403,61,403,25,291,403)
|
---|
64 | var actC4=new Array(11,11,39,67,67,95,95,123,123,151,151,151)
|
---|
65 | var act =new Array(" « KB"," KB » ","Delete","Clear","Back","Caps<br> Lock","Enter","Shift","Shift","<|<","Space",">|>")
|
---|
66 | var effet=new Array("keyscroll(-3)","keyscroll(3)","faire(\"del\")","RAZ()","faire(\"bck\")","bloq()","faire(\"\\n\")","haut()","haut()","faire(\"ar\")","faire(\" \")","faire(\"av\")")
|
---|
67 | var nbActions=12
|
---|
68 | for (i=0;i<nbActions;i++){
|
---|
69 | tracer("act"+i,posUniKeyLeft+1+actC1[i],posUniKeyTop-1+actC2[i],act[i],"action")
|
---|
70 | }
|
---|
71 | /*navigation*/
|
---|
72 | var keyC1=new Array(35,119,203,287)
|
---|
73 | var keyC2=new Array(0,0,0,0)
|
---|
74 | var keyC3=new Array(116,200,284,368)
|
---|
75 | var keyC4=new Array(11,11,11,11)
|
---|
76 | for (i=0;i<4;i++){
|
---|
77 | tracer("key"+i,posUniKeyLeft+5+keyC1[i],posUniKeyTop-1+keyC2[i],key[i],"unikey")
|
---|
78 | }
|
---|
79 | /*zones reactives*/
|
---|
80 | tracer("masque",posUniKeyLeft,posUniKeyTop,'<img src="fck_universalkey/00.gif" width=404 height=152 border="0" usemap="#unikey">')
|
---|
81 | document.write('<map name="unikey">')
|
---|
82 | for (i=0;i<nbTouches;i++){
|
---|
83 | document.write('<area coords="'+posX[i]+','+posY[i]+','+(posX[i]+25)+','+(posY[i]+25)+'" href=# onClick=\'javascript:ecrire('+i+')\'>')
|
---|
84 | }
|
---|
85 | for (i=0;i<nbActions;i++){
|
---|
86 | document.write('<area coords="'+actC1[i]+','+actC2[i]+','+actC3[i]+','+actC4[i]+'" href=# onClick=\'javascript:'+effet[i]+'\'>')
|
---|
87 | }
|
---|
88 | for (i=0;i<4;i++){
|
---|
89 | document.write('<area coords="'+keyC1[i]+','+keyC2[i]+','+keyC3[i]+','+keyC4[i]+'" onclick=\'javascript:charger('+i+')\'>')
|
---|
90 | }
|
---|
91 | document.write('</map>')
|
---|
92 |
|
---|
93 | /*fonctions*/
|
---|
94 | function ecrire(i){
|
---|
95 | txt=rechercher()+"|";subtxt=txt.split("|")
|
---|
96 | ceci=(lock==1)?CarMaj[i]:((caps==1)?CarMaj[i]:CarMin[i])
|
---|
97 | if (test(ceci)){subtxt[0]+=cardia(ceci);distinguer(false)}
|
---|
98 | else if(dia[accent]!=null&&dia[hexa(ceci)]!=null){distinguer(false);accent=hexa(ceci);distinguer(true)}
|
---|
99 | else if(dia[accent]!=null){subtxt[0]+=fromhexby4tocar(accent)+ceci;distinguer(false)}
|
---|
100 | else if(dia[hexa(ceci)]!=null){accent=hexa(ceci);distinguer(true)}
|
---|
101 | else {subtxt[0]+=ceci}
|
---|
102 | txt=subtxt[0]+"|"+subtxt[1]
|
---|
103 | afficher(txt)
|
---|
104 | if (caps==1){caps=0;MinusMajus()}
|
---|
105 | }
|
---|
106 | function faire(ceci){
|
---|
107 | txt=rechercher()+"|";subtxt=txt.split("|")
|
---|
108 | l0=subtxt[0].length
|
---|
109 | l1=subtxt[1].length
|
---|
110 | c1=subtxt[0].substring(0,(l0-2))
|
---|
111 | c2=subtxt[0].substring(0,(l0-1))
|
---|
112 | c3=subtxt[1].substring(0,1)
|
---|
113 | c4=subtxt[1].substring(0,2)
|
---|
114 | c5=subtxt[0].substring((l0-2),l0)
|
---|
115 | c6=subtxt[0].substring((l0-1),l0)
|
---|
116 | c7=subtxt[1].substring(1,l1)
|
---|
117 | c8=subtxt[1].substring(2,l1)
|
---|
118 | if(dia[accent]!=null){if(ceci==" "){ceci=fromhexby4tocar(accent)}distinguer(false)}
|
---|
119 | switch (ceci){
|
---|
120 | case("av") :if(escape(c4)!="%0D%0A"){txt=subtxt[0]+c3+"|"+c7}else{txt=subtxt[0]+c4+"|"+c8}break
|
---|
121 | case("ar") :if(escape(c5)!="%0D%0A"){txt=c2+"|"+c6+subtxt[1]}else{txt=c1+"|"+c5+subtxt[1]}break
|
---|
122 | case("bck"):if(escape(c5)!="%0D%0A"){txt=c2+"|"+subtxt[1]}else{txt=c1+"|"+subtxt[1]}break
|
---|
123 | case("del"):if(escape(c4)!="%0D%0A"){txt=subtxt[0]+"|"+c7}else{txt=subtxt[0]+"|"+c8}break
|
---|
124 | default:txt=subtxt[0]+ceci+"|"+subtxt[1];break
|
---|
125 | }
|
---|
126 | afficher(txt)
|
---|
127 | }
|
---|
128 | function RAZ(){txt="";if(dia[accent]!=null){distinguer(false)}afficher(txt)}
|
---|
129 | function haut(){caps=1;MinusMajus()}
|
---|
130 | function bloq(){lock=(lock==1)?0:1;MinusMajus()}
|
---|
131 |
|
---|
132 | /*fonctions de traitement du unikey*/
|
---|
133 | 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}}
|
---|
134 | 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}}
|
---|
135 | function keyscroll(n){
|
---|
136 | keydeb+=n
|
---|
137 | if (keydeb<0){
|
---|
138 | keydeb=0
|
---|
139 | }
|
---|
140 | if (keydeb>key.length-4){
|
---|
141 | keydeb=key.length-4
|
---|
142 | }
|
---|
143 | for (i=keydeb;i<keydeb+4;i++){
|
---|
144 | retracer("key"+(i-keydeb),key[i],"unikey")
|
---|
145 | }
|
---|
146 | if (keydeb==0){
|
---|
147 | retracer("act0"," ","action")
|
---|
148 | }else {
|
---|
149 | retracer("act0",act[0],"action")
|
---|
150 | }
|
---|
151 | if (keydeb==key.length-4){
|
---|
152 | retracer("act1"," ","action")
|
---|
153 | }else {
|
---|
154 | retracer("act1",act[1],"action")
|
---|
155 | }
|
---|
156 | }
|
---|
157 | function charger(i){
|
---|
158 | langue=key[i+keydeb];setCk(langue);accent="0000"
|
---|
159 | CarMaj=Maj[langue].split("|");CarMin=Min[langue].split("|")
|
---|
160 | for (i=0;i<nbTouches;i++){
|
---|
161 | CarMaj[i]=((CarMaj[i]!="0000")?(fromhexby4tocar(CarMaj[i])):"")
|
---|
162 | CarMin[i]=((CarMin[i]!="0000")?(fromhexby4tocar(CarMin[i])):"")
|
---|
163 | if (CarMaj[i]==CarMin[i].toUpperCase()){
|
---|
164 | cecar=((lock==0)&&(caps==0)?CarMin[i]:CarMaj[i])
|
---|
165 | retracer("car"+i,cecar,((dia[hexa(cecar)]!=null)?"simpledia":"simple"))
|
---|
166 | retracer("minus"+i," ")
|
---|
167 | retracer("majus"+i," ")
|
---|
168 | }
|
---|
169 | else{
|
---|
170 | retracer("car"+i," ")
|
---|
171 | cecar=CarMin[i]
|
---|
172 | retracer("minus"+i,cecar,((dia[hexa(cecar)]!=null)?"doubledia":"double"))
|
---|
173 | cecar=CarMaj[i]
|
---|
174 | retracer("majus"+i,cecar,((dia[hexa(cecar)]!=null)?"doubledia":"double"))
|
---|
175 | }
|
---|
176 | }
|
---|
177 | }
|
---|
178 | function distinguer(oui){
|
---|
179 | for (i=0;i<nbTouches;i++){
|
---|
180 | if (CarMaj[i]==CarMin[i].toUpperCase()){
|
---|
181 | cecar=((lock==0)&&(caps==0)?CarMin[i]:CarMaj[i])
|
---|
182 | if(test(cecar)){retracer("car"+i,oui?(cardia(cecar)):cecar,oui?"simpledia":"simple")}
|
---|
183 | }
|
---|
184 | else{
|
---|
185 | cecar=CarMin[i]
|
---|
186 | if(test(cecar)){retracer("minus"+i,oui?(cardia(cecar)):cecar,oui?"doubledia":"double")}
|
---|
187 | cecar=CarMaj[i]
|
---|
188 | if(test(cecar)){retracer("majus"+i,oui?(cardia(cecar)):cecar,oui?"doubledia":"double")}
|
---|
189 | }
|
---|
190 | }
|
---|
191 | if (!oui){accent="0000"}
|
---|
192 | }
|
---|
193 | function MinusMajus(){
|
---|
194 | for (i=0;i<nbTouches;i++){
|
---|
195 | if (CarMaj[i]==CarMin[i].toUpperCase()){
|
---|
196 | cecar=((lock==0)&&(caps==0)?CarMin[i]:CarMaj[i])
|
---|
197 | retracer("car"+i,(test(cecar)?cardia(cecar):cecar),((dia[hexa(cecar)]!=null||test(cecar))?"simpledia":"simple"))
|
---|
198 | }
|
---|
199 | }
|
---|
200 | }
|
---|
201 | function test(cecar){return(dia[accent]!=null&&dia[accent][hexa(cecar)]!=null)}
|
---|
202 | function cardia(cecar){return(fromhexby4tocar(dia[accent][hexa(cecar)]))}
|
---|
203 | 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}
|
---|
204 | 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}
|
---|
205 | function tohex(inval){return hexchars.charAt(inval/16)+hexchars.charAt(inval%16)}
|
---|
206 | function tohex2(inval){return tohex(inval/256)+tohex(inval%256)}
|
---|
207 | function hexa(ceci){out="";for (k=0;k<ceci.length;k++){out+=(tohex2(ceci.charCodeAt(k)))}return out}
|
---|
208 | function getCk(){
|
---|
209 | fromN=document.cookie.indexOf("langue=")+0;
|
---|
210 | if((fromN)!=-1){
|
---|
211 | fromN+=7;
|
---|
212 | toN=document.cookie.indexOf(";",fromN)+0;
|
---|
213 | if(toN==-1){
|
---|
214 | toN=document.cookie.length
|
---|
215 | }
|
---|
216 | return unescape(document.cookie.substring(fromN,toN))
|
---|
217 | }
|
---|
218 | return ""
|
---|
219 | }
|
---|
220 | function setCk(inval){
|
---|
221 | if(inval!=null){
|
---|
222 | exp=new Date();
|
---|
223 | time=365*60*60*24*1000;
|
---|
224 | exp.setTime(exp.getTime()+time);
|
---|
225 | document.cookie=escape("langue")+"="+escape(inval)+"; "+"expires="+exp.toGMTString()
|
---|
226 | }
|
---|
227 | }
|
---|
228 |
|
---|
229 | // Arabic Keystroke Translator
|
---|
230 | function arkey(e) {
|
---|
231 | if ((document.layers)|(navigator.userAgent.indexOf("MSIE 4")>-1)|(langue!="Arabic")) return true;
|
---|
232 |
|
---|
233 | if (!e) var e = window.event;
|
---|
234 | if (e.keyCode) keyCode = e.keyCode;
|
---|
235 | else if (e.which) keyCode = e.which;
|
---|
236 | var character = String.fromCharCode(keyCode);
|
---|
237 |
|
---|
238 | entry = true;
|
---|
239 | cont=e.srcElement || e.currentTarget || e.target;
|
---|
240 | if (keyCode>64 && keyCode<91) {
|
---|
241 | entry=false;
|
---|
242 | source='ش لاؤ ي ث ب ل ا ه ت ن م ة ى خ ح ض ق س ف ع ر ص ء غ ئ ';
|
---|
243 | shsource='ِ لآ} ] ُ [ لأأ ÷ ـ ، / آ × ؛ َ ٌ ٍ لإ { ً ْ إ ~';
|
---|
244 |
|
---|
245 | if (e.shiftKey) cont.value += shsource.substr((keyCode-64)*2-2,2);
|
---|
246 | else
|
---|
247 | cont.value += source.substr((keyCode-64)*2-2,2);
|
---|
248 | if (cont.value.substr(cont.value.length-1,1)==' ') cont.value=cont.value.substr(0,cont.value.length-1);
|
---|
249 | }
|
---|
250 | if (e.shiftKey) {
|
---|
251 | if (keyCode==186) {cont.value += ':';entry=false;}
|
---|
252 | if (keyCode==188) {cont.value += ',';entry=false;}
|
---|
253 | if (keyCode==190) {cont.value += '.';entry=false;}
|
---|
254 | if (keyCode==191) {cont.value += '؟';entry=false;}
|
---|
255 | if (keyCode==192) {cont.value += 'ّ';entry=false;}
|
---|
256 | if (keyCode==219) {cont.value += '<';entry=false;}
|
---|
257 | if (keyCode==221) {cont.value += '>';entry=false;}
|
---|
258 | } else {
|
---|
259 | if (keyCode==186||keyCode==59) {cont.value += 'ك';entry=false;}
|
---|
260 | if (keyCode==188) {cont.value += 'و';entry=false;}
|
---|
261 | if (keyCode==190) {cont.value += 'ز';entry=false;}
|
---|
262 | if (keyCode==191) {cont.value += 'ظ';entry=false;}
|
---|
263 | if (keyCode==192) {cont.value += 'ذ';entry=false;}
|
---|
264 | if (keyCode==219) {cont.value += 'ج';entry=false;}
|
---|
265 | if (keyCode==221) {cont.value += 'د';entry=false;}
|
---|
266 | if (keyCode==222) {cont.value += 'ط';entry=false;}
|
---|
267 | }
|
---|
268 | return entry;
|
---|
269 | }
|
---|
270 | function hold_it(e){
|
---|
271 | if ((document.layers)|(navigator.userAgent.indexOf("MSIE 4")>-1)|(langue!="Arabic")) return true;
|
---|
272 |
|
---|
273 | var keyCode;
|
---|
274 | if (!e) var e = window.event;
|
---|
275 | if (e.keyCode) keyCode = e.keyCode;
|
---|
276 | else if (e.which) keyCode = e.which;
|
---|
277 | var character = String.fromCharCode(keyCode);
|
---|
278 | switch(keyCode){
|
---|
279 | case 186:
|
---|
280 | case 188:
|
---|
281 | case 190:
|
---|
282 | case 191:
|
---|
283 | case 192:
|
---|
284 | case 219:
|
---|
285 | case 221:
|
---|
286 | case 222:
|
---|
287 | case 116:
|
---|
288 | case 59:
|
---|
289 | case 47:
|
---|
290 | case 46:
|
---|
291 | case 44:
|
---|
292 | case 39:
|
---|
293 | return false;
|
---|
294 | case 92:
|
---|
295 | return true;
|
---|
296 | }
|
---|
297 | if (keyCode<63) return true;
|
---|
298 | return false;
|
---|
299 | }
|
---|
300 |
|
---|
301 | var obj = document.getElementById( 'uni_area' );
|
---|
302 | if ( obj && langue=="Arabic"){
|
---|
303 | with (navigator) {
|
---|
304 | if (appName=="Netscape")
|
---|
305 | obj.onkeypress = hold_it;
|
---|
306 | }
|
---|
307 | obj.onkeydown = arkey;
|
---|
308 | }
|
---|
309 | // Arabic Keystroke Translator End |
---|