tinymcevim-svn Mailing List for TinyMCE Vietnamese Input Method
Brought to you by:
mohanjith
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: <moh...@us...> - 2008-04-14 10:37:03
|
Revision: 4 http://tinymcevim.svn.sourceforge.net/tinymcevim/?rev=4&view=rev Author: mohanjith Date: 2008-04-14 03:36:31 -0700 (Mon, 14 Apr 2008) Log Message: ----------- Updated readme Modified Paths: -------------- trunk/vietunicode/readme.txt Modified: trunk/vietunicode/readme.txt =================================================================== --- trunk/vietunicode/readme.txt 2008-04-14 10:31:08 UTC (rev 3) +++ trunk/vietunicode/readme.txt 2008-04-14 10:36:31 UTC (rev 4) @@ -1,9 +1,15 @@ AVIM JavaScript Vietnamese Input Method TinyMCE plugin ====================================================== +Project is hosted at Sourceforge, http://sourceforge.net/projects/tinymcevim + +Requirements +------------ + 1. TinyMCE - http://tinymce.moxiecode.com/ + Installation ------------- - 1. Place the vietunicode directory in jscripts/tiny_mce/plugins directory. Directory + 1. Place the vietunicode directory in jscripts/tiny_mce/plugins directory of you TinyMCE installation. Directory structure should look like bellow. - jscripts/ @@ -51,4 +57,4 @@ auto_desc:"Tự Động" }}}); --- Mohanjith (moha at mohanjith.net) +-- Mohanjith (http://sourceforge.net/projects/tinymcevim | moha at users.sourceforge.net) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <moh...@us...> - 2008-04-14 10:31:19
|
Revision: 3 http://tinymcevim.svn.sourceforge.net/tinymcevim/?rev=3&view=rev Author: mohanjith Date: 2008-04-14 03:31:08 -0700 (Mon, 14 Apr 2008) Log Message: ----------- Eclipse file Added Paths: ----------- trunk/vietunicode/.project Added: trunk/vietunicode/.project =================================================================== --- trunk/vietunicode/.project (rev 0) +++ trunk/vietunicode/.project 2008-04-14 10:31:08 UTC (rev 3) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>TinyMCE VIM</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + </buildSpec> + <natures> + </natures> +</projectDescription> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <moh...@us...> - 2008-04-14 10:16:34
|
Revision: 1 http://tinymcevim.svn.sourceforge.net/tinymcevim/?rev=1&view=rev Author: mohanjith Date: 2008-04-14 03:00:09 -0700 (Mon, 14 Apr 2008) Log Message: ----------- Creating inital repository structure Added Paths: ----------- branches/ tags/ trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <moh...@us...> - 2008-04-14 10:06:12
|
Revision: 2 http://tinymcevim.svn.sourceforge.net/tinymcevim/?rev=2&view=rev Author: mohanjith Date: 2008-04-14 03:01:40 -0700 (Mon, 14 Apr 2008) Log Message: ----------- Initial import Added Paths: ----------- trunk/vietunicode/ trunk/vietunicode/css/ trunk/vietunicode/css/content.css trunk/vietunicode/editor_plugin.js trunk/vietunicode/editor_plugin_src.js trunk/vietunicode/langs/ trunk/vietunicode/langs/en.js trunk/vietunicode/readme.txt Added: trunk/vietunicode/css/content.css =================================================================== --- trunk/vietunicode/css/content.css (rev 0) +++ trunk/vietunicode/css/content.css 2008-04-14 10:01:40 UTC (rev 2) @@ -0,0 +1,3 @@ +a#elm1_vietunicode_method_listbox_text { + width: 100px; +} \ No newline at end of file Added: trunk/vietunicode/editor_plugin.js =================================================================== --- trunk/vietunicode/editor_plugin.js (rev 0) +++ trunk/vietunicode/editor_plugin.js 2008-04-14 10:01:40 UTC (rev 2) @@ -0,0 +1 @@ +va="email".split(",");method=0;on_off=1;dockspell=1;dauCu=1;useCookie=1;radioID="him_auto,him_telex,him_vni,him_viqr,him_viqr2,him_off,him_ckspell,him_daucu".split(",");var agt=navigator.userAgent.toLowerCase(),alphabet="QWERTYUIOPASDFGHJKLZXCVBNM ",them,spellerr,setCookie,getCookie,attached=new Array();var is_ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1)),S,F,J,R,X,D,oc,sk,saveStr,wi,frame,is_opera=false,D2,isKHTML=false;var ver=0,support=true,changed=false,specialChange=false,uni,uni2,g,h,SFJRX,DAWEO,Z,AEO,moc,trang,kl=0,tw5,range=null,fID=document.getElementsByTagName("iframe");skey=new Array(97,226,259,101,234,105,111,244,417,117,432,121,65,194,258,69,202,73,79,212,416,85,431,89);var skey2="a,a,a,e,e,i,o,o,o,u,u,y,A,A,A,E,E,I,O,O,O,U,U,Y".split(","),A,E,O,whit=false,english="ĐÂĂƠƯÊÔ",lowen="đâăơưêô",ds1="d,D".split(","),db1=new Array(273,272);os1="o,O,ơ,Ơ,ó,Ó,ò,Ò,ọ,Ọ,ỏ,Ỏ,õ,Õ,ớ,Ớ,ờ,Ờ,ợ,Ợ,ở,Ở,ỡ,Ỡ".split(","),ob1="ô,Ô,ô,Ô,ố,Ố,ồ,Ồ,ộ,Ộ,ổ,Ổ,ỗ,Ỗ,ố,Ố,ồ,Ồ,ộ,Ộ,ổ,Ổ,ỗ,Ỗ".split(",");mocs1="o,O,ô,Ô,u,U,ó,Ó,ò,Ò,ọ,Ọ,ỏ,Ỏ,õ,Õ,ú,Ú,ù,Ù,ụ,Ụ,ủ,Ủ,ũ,Ũ,ố,Ố,ồ,Ồ,ộ,Ộ,ổ,Ổ,ỗ,Ỗ".split(",");mocb1="ơ,Ơ,ơ,Ơ,ư,Ư,ớ,Ớ,ờ,Ờ,ợ,Ợ,ở,Ở,ỡ,Ỡ,ứ,Ứ,ừ,Ừ,ự,Ự,ử,Ử,ữ,Ữ,ớ,Ớ,ờ,Ờ,ợ,Ợ,ở,Ở,ỡ,Ỡ".split(",");trangs1="a,A,â,Â,á,Á,à,À,ạ,Ạ,ả,Ả,ã,Ã,ấ,Ấ,ầ,Ầ,ậ,Ậ,ẩ,Ẩ,ẫ,Ẫ".split(",");trangb1="ă,Ă,ă,Ă,ắ,Ắ,ằ,Ằ,ặ,Ặ,ẳ,Ẳ,ẵ,Ẵ,ắ,Ắ,ằ,Ằ,ặ,Ặ,ẳ,Ẳ,ẵ,Ẵ".split(",");as1="a,A,ă,Ă,á,Á,à,À,ạ,Ạ,ả,Ả,ã,Ã,ắ,Ắ,ằ,Ằ,ặ,Ặ,ẳ,Ẳ,ẵ,Ẵ,ế,Ế,ề,Ề,ệ,Ệ,ể,Ể,ễ,Ễ".split(",");ab1="â,Â,â,Â,ấ,Ấ,ầ,Ầ,ậ,Ậ,ẩ,Ẩ,ẫ,Ẫ,ấ,Ấ,ầ,Ầ,ậ,Ậ,ẩ,Ẩ,ẫ,Ẫ,é,É,è,È,ẹ,Ẹ,ẻ,Ẻ,ẽ,Ẽ".split(",");es1="e,E,é,É,è,È,ẹ,Ẹ,ẻ,Ẻ,ẽ,Ẽ".split(",");eb1="ê,Ê,ế,Ế,ề,Ề,ệ,Ệ,ể,Ể,ễ,Ễ".split(",");arA="á,à,ả,ã,ạ,a,Á,À,Ả,Ã,Ạ,A".split(",");mocrA="ó,ò,ỏ,õ,ọ,o,ú,ù,ủ,ũ,ụ,u,Ó,Ò,Ỏ,Õ,Ọ,O,Ú,Ù,Ủ,Ũ,Ụ,U".split(",");erA="é,è,ẻ,ẽ,ẹ,e,É,È,Ẻ,Ẽ,Ẹ,E".split(",");orA="ó,ò,ỏ,õ,ọ,o,Ó,Ò,Ỏ,Õ,Ọ,O".split(",");aA="ấ,ầ,ẩ,ẫ,ậ,â,Ấ,Ầ,Ẩ,Ẫ,Ậ,Â".split(",");mocA="ớ,ờ,ở,ỡ,ợ,ơ,ứ,ừ,ử,ữ,ự,ư,Ớ,Ờ,Ở,Ỡ,Ợ,Ơ,Ứ,Ừ,Ử,Ữ,Ự,Ư".split(",");trangA="ắ,ằ,ẳ,ẵ,ặ,ă,Ắ,Ằ,Ẳ,Ẵ,Ặ,Ă".split(",");eA="ế,ề,ể,ễ,ệ,ê,Ế,Ề,Ể,Ễ,Ệ,Ê".split(",");oA="ố,ồ,ổ,ỗ,ộ,ô,Ố,Ồ,Ổ,Ỗ,Ộ,Ô".split(",");function notWord(B){var C=" \r\n#,\\;.:-_()<>+-*/=?!\"$%{}[]'~|^@&\t"+fcc(160);return(C.indexOf(B)>=0)}function nan(B){if((isNaN(B))||(B=="e")){return true}else{return false}}function mozGetText(G){var C,H,B="";g=1;C=(G.data)?G.data:G.value;if(C.length<=0){return false}if(!G.data){if(!G.setSelectionRange){return false}H=G.selectionStart}else{H=G.pos}if(G.selectionStart!=G.selectionEnd){return new Array("",H)}while(1){if(H-g<0){break}else{if(notWord(C.substr(H-g,1))){if(C.substr(H-g,1)=="\\"){B=C.substr(H-g,1)+B}break}else{B=C.substr(H-g,1)+B}}g++}return new Array(B,H)}function start(H,G){var B="",I;oc=H;uni2=false;if(method==0){uni="D,A,E,O,W,W".split(",");uni2="9,6,6,6,7,8".split(",");D2="DAWEO6789"}else{if(method==1){uni="D,A,E,O,W,W".split(",");D2="DAWEO"}else{if(method==2){uni="9,6,6,6,7,8".split(",");D2="6789"}else{if(method==3){uni="D,^,^,^,+,(".split(",");D2="D^+("}else{if(method==4){uni="D,^,^,^,*,(".split(",");D2="D^*("}}}}}if(!is_ie){G=fcc(G.which);B=mozGetText(H);if(D2.indexOf(up(G))>=0){I=true}else{I=false}if((!B)||(H.sel)){return }main(B[0],G,B[1],uni,I);if(!dockspell){B=mozGetText(H)}if((B)&&(uni2)&&(!changed)){main(B[0],G,B[1],uni2,I)}}else{H=ieGetText(H);if(H){var C=H.cW.text;B=main(H.cW.text,G,0,uni,false);if((uni2)&&((B==C)||(typeof (B)=="undefined"))){B=main(H.cW.text,G,0,uni2,false)}if(B){H.cW.text=B}}}if(D2.indexOf(up(G))>=0){if(!is_ie){B=mozGetText(H);if(!B){return }normC(B[0],G,B[1])}else{if(typeof (H)=="object"){H=ieGetText(H);if(H){B=H.cW.text;if(!changed){B+=G;changed=true}H.cW.text=B;B=normC(B,G,0);if(B){H=ieGetText(H);H.cW.text=B}}}}}}function ieGetText(C){var G=C.document.selection.createRange(),B="";if(G.text){G.text=""}else{while(1){G.moveStart("character",-1);if(B.length==G.text.length){break}B=G.text;if(notWord(B.charAt(0))){if(B.charCodeAt(0)==13){B=B.substr(2)}else{if(B.charAt(0)!="\\"){B=B.substr(1)}}break}}}if(B.length){G.collapse(false);G.moveStart("character",-B.length);C.cW=G.duplicate();return C}else{return false}}function ie_replaceChar(B,I,H){var G="",C=0;if(isNaN(H)){C=up(H)}if((whit)&&(up(B.substr(B.length-I-1,1))=="U")&&(I!=1)&&(up(B.substr(B.length-I-2,1))!="Q")){whit=false;if((up(unV(fcc(H)))=="Ơ")||(C=="O")){if(B.substr(B.length-I-1,1)=="u"){G=fcc(432)}else{G=fcc(431)}}if(C=="O"){if(H=="o"){H=417}else{H=416}}}if(!isNaN(H)){changed=true;G+=fcc(H);return B.substr(0,B.length-I-G.length+1)+G+B.substr(B.length-I+1)}else{return B.substr(0,B.length-I)+H+B.substr(B.length-I+1)}}function tr(G,P,K,I,H){var B,N=findC(P,G,I);if(N){if(N[1]){if(is_ie){return ie_replaceChar(P,N[0],N[1])}else{return replaceChar(oc,H-N[0],N[1])}}else{var L,C=P.substr(P.length-N,1),M;B=I;for(g=0;g<B.length;g++){if((nan(B[g]))||(B[g]=="e")){M=C}else{M=C.charCodeAt(0)}if(M==B[g]){if(!nan(K[g])){L=K[g]}else{L=K[g].charCodeAt(0)}if(is_ie){return ie_replaceChar(P,N,L)}else{return replaceChar(oc,H-N,L)}}}}}return false}function main(Q,G,H,P,C){var M=up(G),U=new Array(db1,ab1,eb1,ob1,mocb1,trangb1),N=false,T="d,D,a,A,a,A,o,O,u,U,e,E,o,O".split(",");var B=new Array(ds1,as1,es1,os1,mocs1,trangs1),L=new Array(),I=new Array();if((method==2)||((method==0)&&(P[0]=="9"))){DAWEO="6789";SFJRX="12534";S="1";F="2";J="5";R="3";X="4";Z="0";D="9";FRX="234";AEO="6";moc="7";trang="8";them="678";A="^";E="^";O="^"}else{if(method==3){DAWEO="^+(D";SFJRX="'`.?~";S="'";F="`";J=".";R="?";X="~";Z="-";D="D";FRX="`?~";AEO="^";moc="+";trang="(";them="^+(";A="^";E="^";O="^"}else{if(method==4){DAWEO="^*(D";SFJRX="'`.?~";S="'";F="`";J=".";R="?";X="~";Z="-";D="D";FRX="`?~";AEO="^";moc="*";trang="(";them="^*(";A="^";E="^";O="^"}else{if((method==1)||((method==0)&&(P[0]=="D"))){SFJRX="SFJRX";DAWEO="DAWEO";D="D";S="S";F="F";J="J";R="R";X="X";Z="Z";FRX="FRX";them="AOEW";trang="W";moc="W";A="A";E="E";O="O"}}}}if(SFJRX.indexOf(M)>=0){var K=sr(Q,G,H);N=true;if(K){return K}}else{if(M==Z){I=repSign(null);for(h=0;h<english.length;h++){I[I.length]=lowen.charCodeAt(h);I[I.length]=english.charCodeAt(h)}for(h=0;h<5;h++){for(g=0;g<skey.length;g++){L[L.length]=skey[g]}}for(h=0;h<T.length;h++){L[L.length]=T[h]}N=true}else{for(h=0;h<P.length;h++){if(P[h]==M){N=true;L=L.concat(U[h]);I=I.concat(B[h])}}}}if(M==moc){whit=true}if(!N){if(C){return }return normC(Q,G,H)}return DAWEOZ(G,Q,L,I,H,M)}function DAWEOZ(C,B,K,I,G,H){if((DAWEO.indexOf(H)>=0)||(Z.indexOf(H)>=0)){return tr(C,B,K,I,G)}}function normC(T,G,K){var M=up(G),V=repSign(null),U,N,H,B=(G.charCodeAt(0)==32)?true:false;if((!is_ie)&&(B)){return }for(H=1;H<=T.length;H++){for(h=0;h<V.length;h++){if(V[h]==T.charCodeAt(T.length-H)){if(h<=23){U=S}else{if(h<=47){U=F}else{if(h<=71){U=J}else{if(h<=95){U=R}else{U=X}}}}N=skey[h%24];if((alphabet.indexOf(M)<0)&&(D2.indexOf(M)<0)){return T}T=unV(T);if((!B)&&(!changed)){T+=G}if(!is_ie){var C=oc.selectionStart,P=C;if(!changed){var W=oc.scrollTop;P+=G.length;if(!oc.data){oc.value=oc.value.substr(0,C)+G+oc.value.substr(oc.selectionEnd);changed=true;oc.scrollTop=W}else{oc.insertData(oc.pos,G);oc.pos++;range.setEnd(oc,oc.pos);specialChange=true}}if(!oc.data){oc.setSelectionRange(P,P)}if(!ckspell(T,U)){replaceChar(oc,K-H,N);if(!oc.data){var Q=new Array(D);main(T,U,P,Q,false)}else{var I=mozGetText(oc);var Q=new Array(D);main(I[0],U,I[1],Q,false)}}}else{var L=sr(T,U,0);if((B)&&(L)){L+=fcc(32)}if(L){return L}}}}}}function nospell(B,C){return false}function ckspell(Q,f){Q=unV(Q);var c="UOU,IEU".split(","),N,d=true,C="UU,UOU,UOI,IEU,AO,IA,AI,AY,AU,AO".split(","),n="YEU",q,v,u;var s=true,AA="UE,UYE,IU,EU,UY".split(","),I="AY,AU".split(","),r="UA",U=-1,m="IAO";var L=up(Q),x=L,M=false,p="IO",y="OE,OO,AO,EO,IA,AI".split(","),j="OA";var P="AA,AE,EE,OU,YY,YI,IY,EY,EA,EI,II,IO,YO,YA,OOO".split(","),V=up(f),H,B=unV2(L);var G="B,C,D,G,H,K,L,M,N,P,Q,R,S,T,V,X".split(","),Y="CH,GI,KH,NGH,GH,NG,NH,PH,QU,TH,TR".split(",");var K="CH,NG,NH".split(","),e="C,P,T,CH".split(","),T="C,M,N,P,T".split(",");var W="O,U,IE,Ô,Ơ,Ư,IÊ,Ă,Â,UYE,UYÊ,UO,ƯƠ,ƯO,UƠ,UA,ƯA,OĂ,OE,OÊ".split(","),o="UU,UOU".split(",");if(FRX.indexOf(V)>=0){for(v=0;v<e.length;v++){if(L.substr(L.length-e[v].length,e[v].length)==e[v]){return true}}}for(v=0;v<L.length;v++){if("FJZW1234567890".indexOf(L.substr(v,1))>=0){return true}for(u=0;u<P.length;u++){if(B.substr(v,P[u].length)==P[u]){for(N=0;N<c.length;N++){if(B.indexOf(c[N])>=0){d=false}}if((d)&&((p.indexOf(P[u])<0)||(v<=0)||(B.substr(v-1,1)!="G"))){return true}}}}for(u=0;u<Y.length;u++){if(x.indexOf(Y[u])==0){x=x.substr(Y[u].length);M=true;U=u;break}}if(!M){for(u=0;u<G.length;u++){if(x.indexOf(G[u])==0){x=x.substr(1);break}}}M=false;H=x;for(u=0;u<K.length;u++){if(x.substr(x.length-K[u].length)==K[u]){x=x.substr(0,x.length-K[u].length);if(u==2){for(N=0;N<W.length;N++){if(x==W[N]){return true}}if((V==trang)&&((x=="OA")||(x=="A"))){return true}}M=true;break}}if(!M){for(u=0;u<T.length;u++){if(x.substr(x.length-1)==T[u]){x=x.substr(0,x.length-1);break}}}if(x){for(v=0;v<Y.length;v++){for(u=0;u<x.length;u++){if(x.substr(u,Y[v].length)==Y[v]){return true}}}for(v=0;v<G.length;v++){if(x.indexOf(G[v])>=0){return true}}}q=x.substr(0,1);if((U==3)&&((q=="A")||(q=="O")||(q=="U")||(q=="Y"))){return true}if((U==5)&&((q=="E")||(q=="I")||(q=="Y"))){return true}B=unV2(x);if(B==m){return true}if(x!=H){for(N=0;N<C.length;N++){if(B==C[N]){return true}}}if((x!=L)&&(B==n)){return true}if(V!=moc){for(N=0;N<o.length;N++){if(x==o[N]){return true}}}if((B.indexOf("UYE")>0)&&(V=="E")){s=false}if((them.indexOf(V)>=0)&&(s)){for(v=0;v<y.length;v++){if(B.indexOf(y[v])>=0){return true}}if(V!=trang){if(B==j){return true}}if((V==trang)&&(trang!="W")){if(B==r){return true}}if(V==moc){for(v=0;v<AA.length;v++){if(B==AA[v]){return true}}}if((V==moc)||(V==trang)){for(v=0;v<I.length;v++){if(B==I[v]){return true}}}}tw5=x;if((B.charCodeAt(0)==272)||(B.charCodeAt(0)==273)){if(B.length>4){return true}}else{if(B.length>3){return true}}return false}function DAWEOF(M,G){var H=new Array(),I=new Array(A,moc,trang,E,O),L,C;H[0]=g;var B=new Array(aA,mocA,trangA,eA,oA),K=new Array(arA,mocrA,arA,erA,orA);for(C=0;C<I.length;C++){if(G==I[C]){for(L=0;L<B[C].length;L++){if(M==B[C][L]){H[1]=K[C][L]}}}}if(H[1]){return H}else{return false}}function findC(Q,e,o){if(((method==3)||(method==4))&&(Q.substr(Q.length-1,1)=="\\")){return new Array(1,e.charCodeAt(0))}var b="",q,Y="",B="",C="",H=new Array(),V="ÂĂÊÔƠƯêâăơôư",m=0,d=false,N=up(Q),p;var T=aA.join()+eA.join()+mocA.join()+trangA.join()+oA.join()+english;T=up(T);for(g=0;g<o.length;g++){if(nan(o[g])){b+=o[g]}else{b+=fcc(o[g])}}var W=up(e),f=Q.length,j=repSign(e),P=up(unV2(unV(Q))),M="ƯA,ƯU".split(",");if(DAWEO.indexOf(W)>=0){if(W==moc){if((P.indexOf("UU")>=0)&&(tw5!=M[1])){if(P.indexOf("UU")==(Q.length-2)){q=2}else{return false}}else{if(P.indexOf("UOU")>=0){if(P.indexOf("UOU")==(Q.length-3)){q=2}else{return false}}}}if(!q){for(g=1;g<=Q.length;g++){Y=Q.substr(Q.length-g,1);B=up(Q.substr(Q.length-g-1,1));uc=up(Y);for(h=0;h<M.length;h++){if((tw5==M[h])&&(tw5==unV(B+uc))){d=true}}if(d){d=false;continue}if(b.indexOf(uc)>=0){if(((W==moc)&&(unV(uc)=="U")&&(up(unV(Q.substr(Q.length-g+1,1)))=="A"))||((W==trang)&&(unV(uc)=="A")&&(unV(B)=="U"))){if(unV(uc)=="U"){p=1}else{p=2}ccc=up(Q.substr(Q.length-g-p,1));if(ccc!="Q"){q=g+p-1}else{if(W==trang){q=g}else{if(moc!=trang){return false}}}}else{q=g}if((!whit)||(N.indexOf("Ư")<0)||(N.indexOf("W")<0)){break}}else{if(T.indexOf(uc)>=0){if(W==D){if(Y=="đ"){q=new Array(g,"d")}else{if(Y=="Đ"){q=new Array(g,"D")}}}else{q=DAWEOF(Y,W)}if(q){break}}}}}}if((W!=Z)&&(DAWEO.indexOf(W)<0)){var L=retKC(W);for(g=0;g<L.length;g++){C+=fcc(L[g])}}for(g=1;g<=Q.length;g++){if(DAWEO.indexOf(W)<0){Y=up(Q.substr(Q.length-g,1));B=up(Q.substr(Q.length-g-1,1));if(b.indexOf(Y)>=0){if(Y=="U"){if(B!="Q"){m++;H[H.length]=g}}else{if(Y=="I"){if((B!="G")||(m<=0)){m++;H[H.length]=g}}else{m++;H[H.length]=g}}}else{if(W!=Z){for(h=0;h<j.length;h++){if(j[h]==Q.charCodeAt(Q.length-g)){if(spellerr(Q,e)){return false}return new Array(g,L[h%24])}}for(h=0;h<L.length;h++){if(L[h]==Q.charCodeAt(Q.length-g)){return new Array(g,fcc(skey[h]))}}}}}}if((W!=Z)&&(typeof (q)!="object")){if(spellerr(Q,e)){return false}}if(DAWEO.indexOf(W)<0){for(g=1;g<=Q.length;g++){if((W!=Z)&&(V.indexOf(Q.substr(Q.length-g,1))>=0)){return g}else{if(C.indexOf(Q.substr(Q.length-g,1))>=0){for(h=0;h<L.length;h++){if(Q.substr(Q.length-g,1).charCodeAt(0)==L[h]){return new Array(g,fcc(skey[h]))}}}}}}if(q){return q}if((m==1)||(W==Z)){return H[0]}else{if(m==2){var U=2;if(Q.substr(Q.length-1)==" "){U=3}var K=up(Q.substr(Q.length-U,2));if((dauCu==0)&&((K=="UY")||(K=="OA")||(K=="OE"))){return H[0]}var a=0,I,G="BCD"+fcc(272)+"GHKLMNPQRSTVX",n="CH,GI,KH,NGH,GH,NG,NH,PH,QU,TH,TR".split(",");for(h=1;h<=Q.length;h++){I=false;for(g=0;g<n.length;g++){if(up(Q.substr(Q.length-h-n[g].length+1,n[g].length)).indexOf(n[g])>=0){a++;I=true;if(n[g]!="NGH"){h++}else{h+=2}}}if(!I){if(G.indexOf(up(Q.substr(Q.length-h,1)))>=0){a++}else{break}}}if((a==1)||(a==2)){return H[0]}else{return H[1]}}else{if(m==3){return H[1]}else{return false}}}}function unV(G){var H=repSign(null),B,C;for(C=1;C<=G.length;C++){for(B=0;B<H.length;B++){if(H[B]==G.charCodeAt(G.length-C)){G=G.substr(0,G.length-C)+fcc(skey[B%24])+G.substr(G.length-C+1)}}}return G}function unV2(G){var C,B;for(C=1;C<=G.length;C++){for(B=0;B<skey.length;B++){if(skey[B]==G.charCodeAt(G.length-C)){G=G.substr(0,G.length-C)+skey2[B]+G.substr(G.length-C+1)}}}return G}function repSign(G){var I=new Array(),H=new Array(),C,B;for(C=0;C<5;C++){if((G==null)||(SFJRX.substr(C,1)!=up(G))){I=retKC(SFJRX.substr(C,1));for(B=0;B<I.length;B++){H[H.length]=I[B]}}}return H}function sr(B,C,G){var H=getSF();pos=findC(B,C,H);if(pos){if(pos[1]){if(!is_ie){replaceChar(oc,G-pos[0],pos[1])}else{return ie_replaceChar(B,pos[0],pos[1])}}else{var I=retUni(B,C,pos);if(!is_ie){replaceChar(oc,G-pos,I)}else{return ie_replaceChar(B,pos,I)}}}return false}function retUni(G,H,M){var I=retKC(up(H)),C,K,L=G.charCodeAt(G.length-M),B;for(B=0;B<skey.length;B++){if(skey[B]==L){if(B<12){K=B;C=B+12}else{K=B-12;C=B}t=fcc(L);if(t!=up(t)){return I[K]}return I[C]}}}function replaceChar(C,M,L){var K=false;if(!nan(L)){var I=fcc(L),H=up(unV(fcc(L)));changed=true}else{var I=L;if((up(L)=="O")&&(whit)){K=true}}if(!C.data){var G=C.selectionStart,N=C.scrollTop;if((up(C.value.substr(M-1,1))=="U")&&(M<G-1)&&(up(C.value.substr(M-2,1))!="Q")){if((H=="Ơ")||(K)){if(C.value.substr(M-1,1)=="u"){var B=fcc(432)}else{var B=fcc(431)}}if(K){changed=true;if(L=="o"){I="ơ"}else{I="Ơ"}}}C.value=C.value.substr(0,M)+I+C.value.substr(M+1);if(B){C.value=C.value.substr(0,M-1)+B+C.value.substr(M)}C.setSelectionRange(G,G);C.scrollTop=N}else{if((up(C.data.substr(M-1,1))=="U")&&(M<C.pos-1)){if((H=="Ơ")||(K)){if(C.data.substr(M-1,1)=="u"){var B=fcc(432)}else{var B=fcc(431)}}if(K){changed=true;if(L=="o"){I="ơ"}else{I="Ơ"}}}C.deleteData(M,1);C.insertData(M,I);if(B){C.deleteData(M-1,1);C.insertData(M-1,B)}}if(whit){whit=false}}function retKC(B){if(B==S){return new Array(225,7845,7855,233,7871,237,243,7889,7899,250,7913,253,193,7844,7854,201,7870,205,211,7888,7898,218,7912,221)}if(B==F){return new Array(224,7847,7857,232,7873,236,242,7891,7901,249,7915,7923,192,7846,7856,200,7872,204,210,7890,7900,217,7914,7922)}if(B==J){return new Array(7841,7853,7863,7865,7879,7883,7885,7897,7907,7909,7921,7925,7840,7852,7862,7864,7878,7882,7884,7896,7906,7908,7920,7924)}if(B==R){return new Array(7843,7849,7859,7867,7875,7881,7887,7893,7903,7911,7917,7927,7842,7848,7858,7866,7874,7880,7886,7892,7902,7910,7916,7926)}if(B==X){return new Array(227,7851,7861,7869,7877,297,245,7895,7905,361,7919,7929,195,7850,7860,7868,7876,296,213,7894,7904,360,7918,7928)}}function getEL(B){return document.getElementById(B)}function getSF(){var C=new Array(),B;for(B=0;B<skey.length;B++){C[C.length]=fcc(skey[B])}return C}function statusMessage(){var B="Kiểu gõ: ";if(on_off==0){B+="Tắt"}else{if(method==1){B+="TELEX"}else{if(method==2){B+="VNI"}else{if(method==3){B+="VIQR"}else{if(method==4){B+="VIQR*"}else{if(method==0){B+="Tự động"}}}}}}if(isKHTML){B+=" [Alt-F9]"}else{B+=" [F9]"}B+=" | Chính tả: ";B+=(dockspell==0)?"Tắt":"Bật";if(isKHTML){B+=" [Alt-F8]"}else{B+=" [F8]"}B+=" | Bỏ dấu: ";B+=(dauCu==1)?"Cũ":"Mới";if(isKHTML){B+=" [Alt-F7]"}else{B+=" [F7]"}B+=" | Bật/Tắt [F12] - AVIM 20071102";window.status=B}function updateInfo(){setCookie();if(support){statusMessage()}}function setMethod(B){if(B==-1){on_off=0;if(getEL(radioID[5])){getEL(radioID[5]).checked=true}}else{on_off=1;method=B;if(getEL(radioID[B])){getEL(radioID[B]).checked=true}}setSpell(dockspell);setDauCu(dauCu);updateInfo()}function setDauCu(B){if(typeof (B)=="number"){dauCu=B;if(getEL(radioID[7])){getEL(radioID[7]).checked=B}}else{dauCu=(B.checked)?1:0}updateInfo()}function setSpell(B){if(typeof (B)=="number"){spellerr=(B==1)?ckspell:nospell;if(getEL(radioID[6])){getEL(radioID[6]).checked=B}}else{if(B.checked){spellerr=ckspell;dockspell=1}else{spellerr=nospell;dockspell=0}}updateInfo()}function onKeyDown(C){if(C=="iframe"){frame=findF();var B=frame.event.keyCode}else{var B=(!is_ie)?C.which:window.event.keyCode}if((B==120)||(B==123)||(B==119)||(B==118)){if(B==120){on_off=1;setMethod(((method==4)?0:++method))}else{if(B==118){setDauCu(((dauCu==1)?0:1))}else{if(B==119){dockspell=(dockspell==0)?1:0;setSpell(dockspell)}else{if(B==123){on_off=(on_off==0)?1:0;if(on_off==0){setMethod(-1)}else{setMethod(method)}}}}}updateInfo()}}function ifInit(B){var C=B.getSelection();range=C?C.getRangeAt(0):document.createRange()}function ifMoz(I){var H=I.which,B=I.target.parentNode.wi;if(typeof (B)=="undefined"){B=I.target.parentNode.parentNode.wi}if((I.ctrlKey)||((I.altKey)&&(H!=92)&&(H!=126))){return }ifInit(B);var G=range.endContainer,C;sk=fcc(H);saveStr="";if(checkCode(H)||(!range.startOffset)||(typeof (G.data)=="undefined")){return }G.sel=false;if(G.data){saveStr=G.data.substr(range.endOffset);if(range.startOffset!=range.endOffset){G.sel=true}G.deleteData(range.startOffset,G.data.length)}range.setEnd(G,range.endOffset);range.setStart(G,0);if(!G.data){return }G.value=G.data;G.pos=G.data.length;G.which=H;start(G,I);G.insertData(G.data.length,saveStr);C=G.data.length-saveStr.length+kl;range.setEnd(G,C);range.setStart(G,C);kl=0;if(specialChange){specialChange=false;changed=false;G.deleteData(G.pos-1,1)}if(changed){changed=false;I.preventDefault()}}function FKeyPress(){var B=findF();sk=fcc(B.event.keyCode);if(checkCode(B.event.keyCode)||((B.event.ctrlKey)&&(B.event.keyCode!=92)&&(B.event.keyCode!=126))){return }start(B,fcc(B.event.keyCode));if(changed){changed=false;return false}}function checkCode(B){if(((on_off==0)||((B<45)&&(B!=42)&&(B!=32)&&(B!=39)&&(B!=40)&&(B!=43))||(B==145)||(B==255))){return true}return false}function fcc(B){return String.fromCharCode(B)}if(useCookie==1){setCookie=doSetCookie;getCookie=doGetCookie}else{setCookie=noCookie;getCookie=noCookie}function noCookie(){}function doSetCookie(){var C=new Date(11245711156480).toGMTString(),B=";expires="+C+";path=/";document.cookie="AVIM_on_off="+on_off+B;document.cookie="AVIM_method="+method+B;document.cookie="AVIM_ckspell="+dockspell+B;document.cookie="AVIM_daucu="+dauCu+B}function doGetCookie(){var B=document.cookie,G=/AVIM_method/.test(B);if((!G)||(B.indexOf("AVIM_ckspell")<0)){setCookie();return }var I,H=B.split(";");for(var C=0;C<H.length;C++){I=H[C].split("=");I[0]=I[0].replace(/^\s+/g,"");I[1]=parseInt(I[1]);if(I[0]=="AVIM_on_off"){on_off=I[1]}else{if(I[0]=="AVIM_method"){method=I[1]}else{if(I[0]=="AVIM_ckspell"){if(I[1]==0){dockspell=0;spellerr=nospell}else{dockspell=1;spellerr=ckspell}}else{if(I[0]=="AVIM_daucu"){dauCu=parseInt(I[1])}}}}}}if(!is_ie){if(agt.indexOf("opera")>=0){operaV=agt.split(" ");operaVersion=parseInt(operaV[operaV.length-1]);if(operaVersion>=8){is_opera=true}else{operaV=operaV[0].split("/");operaVersion=parseInt(operaV[1]);if(operaVersion>=8){is_opera=true}}}else{if(agt.indexOf("khtml")>=0){isKHTML=true}else{ver=agt.substr(agt.indexOf("rv:")+3);ver=parseFloat(ver.substr(0,ver.indexOf(" ")));if(agt.indexOf("mozilla")<0){ver=0}}}}function up(B){B=B.toUpperCase();if(isKHTML){str="êôơâăưếốớấắứềồờầằừễỗỡẫẵữệộợậặự",rep="ÊÔƠÂĂƯẾỐỚẤẮỨỀỒỜẦẰỪỄỖỠẪẴỮỆỘỢẶỰ";for(z=0;z<B.length;z++){io=str.indexOf(B.substr(z,1));if(io>=0){B=B.substr(0,z)+rep.substr(io,1)+B.substr(z+1)}}}return B}function findIgnore(B){for(i=0;i<va.length;i++){if((B.id==va[i])&&(va[i].length>0)){return true}}}if((is_ie)||(ver>=1.3)||(is_opera)||(isKHTML)){getCookie();if(on_off==0){setMethod(-1)}else{setMethod(method)}setSpell(dockspell);setDauCu(dauCu);statusMessage()}else{support=false}function onKeyPress(G){if(!support){return }if(!is_ie){var B=G.target,C=G.which;if(G.ctrlKey){return }if((G.altKey)&&(C!=92)&&(C!=126)){return }}else{var B=window.event.srcElement,C=window.event.keyCode;if((event.ctrlKey)&&(C!=92)&&(C!=126)){return }}if(((B.type!="textarea")&&(B.type!="text"))||checkCode(C)){return }sk=fcc(C);if(findIgnore(B)){return }if(!is_ie){start(B,G)}else{start(B,sk)}if(changed){changed=false;if(!is_ie){G.preventDefault()}else{return false}}}function attachEvt(H,B,G,C){if(is_ie){H.attachEvent("on"+B,G);H.attachEvent("on"+B,getCookie)}else{H.addEventListener(B,G,C);H.addEventListener(B,getCookie,C)}}attachEvt(document,"keydown",onKeyDown,false);attachEvt(document,"keypress",onKeyPress,false);function findF(){for(g=0;g<fID.length;g++){if(findIgnore(fID[g])){continue}frame=fID[g];if(typeof (frame)!="undefined"){try{if((frame.contentWindow.document)&&(frame.contentWindow.event)){return frame.contentWindow}}catch(B){if((frame.document)&&(frame.event)){return frame}}}}}function onKeyDownI(){onKeyDown("iframe")}function init(){var H=false;if((support)&&(!isKHTML)){if(is_opera){if(operaVersion<9){return }}for(g=0;g<fID.length;g++){if(findIgnore(fID[g])){continue}if(is_ie){var G;try{frame=fID[g];if(typeof (frame)!="undefined"){if(frame.contentWindow.document){G=frame.contentWindow.document}else{if(frame.document){G=frame.document}}}if((G)&&((up(G.designMode)=="ON")||(G.body.contentEditable))){for(l=0;l<attached.length;l++){if(G==attached[l]){H=true;break}}if(!H){attached[attached.length]=G;attachEvt(G,"keydown",onKeyDownI,false);attachEvt(G,"keypress",FKeyPress,false)}else{H=false}}}catch(C){}}else{var B;try{wi=fID[g].contentWindow;B=wi.document;B.wi=wi;if((B)&&(up(B.designMode)=="ON")){attachEvt(B,"keypress",ifMoz,false);attachEvt(B,"keydown",onKeyDown,true)}}catch(C){}}}}}function uglyF(){ugly=50;while(ugly<5000){setTimeout("init()",ugly);ugly+=50}}uglyF();attachEvt(document,"mousedown",uglyF,false);(function(){tinymce.PluginManager.requireLangPack("vietunicode");tinymce.create("tinymce.plugins.VietUnicode",{createControl:function(G,C){switch(G){case"vietunicode_method_listbox":var B=C.createListBox("vietunicode_method_listbox",{title:"vietunicode.select_input_method",onselect:function(H){setMethod(H)}});B.add("vietunicode.off_desc",-1);B.add("vietunicode.telex_desc",1);B.add("vietunicode.vni_desc",2);B.add("vietunicode.viqr_desc",3);B.add("vietunicode.auto_desc",0);B.select(method);return B}return null},init:function(B,C){B.onBeforeRenderUI.add(function(){tinymce.DOM.loadCSS(C+"/css/content.css")})},getInfo:function(){return{longname:"VietUnicode",author:"S.H.Mohanjith",authorurl:"http://mohanjith.com",infourl:"http://mohanjith.com/portfolio/tinymce/vietunicode",version:"1.0"}}});tinymce.PluginManager.add("vietunicode",tinymce.plugins.VietUnicode)})(); \ No newline at end of file Added: trunk/vietunicode/editor_plugin_src.js =================================================================== --- trunk/vietunicode/editor_plugin_src.js (rev 0) +++ trunk/vietunicode/editor_plugin_src.js 2008-04-14 10:01:40 UTC (rev 2) @@ -0,0 +1,788 @@ +/** + * $Id: editor_plugin_src.js 2 2008-04-10 13:09:46Z mohanjith $ + * + * @author Mohanjith + */ + +/** + * AVIM JavaScript Vietnamese Input Method Source File dated 02-11-2007 + * + * Copyright (C) 2004-2007 Hieu Tran Dang <lt2hieu2004 (at) users (dot) sf (dot) net> + * Website: http://hdang.co.uk + * + * You are allowed to use this software in any way you want providing: + * 1. You must retain this copyright notice at all time + * 2. You must not claim that you or any other third party is the author + * of this software in any way. + */ + +va="email".split(','); //Put the ID of the fields you DON'T want to let users type Vietnamese in, multiple fields allowed, separated by a comma (,) +method=0; //Default input method, 0=AUTO, 1=TELEX, 2=VNI, 3=VIQR, 4=VIQR* +on_off=1; //Start AVIM on +dockspell=1; //Start AVIM with spell checking on +dauCu=1; //Start AVIM with old way of marking accent (o`a, o`e, u`y) +useCookie=1; //Set this to 0 to NOT use cookies +radioID="him_auto,him_telex,him_vni,him_viqr,him_viqr2,him_off,him_ckspell,him_daucu".split(","); +var agt=navigator.userAgent.toLowerCase(),alphabet="QWERTYUIOPASDFGHJKLZXCVBNM\ ",them,spellerr,setCookie,getCookie,attached=new Array(); +var is_ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1)),S,F,J,R,X,D,oc,sk,saveStr,wi,frame,is_opera=false,D2,isKHTML=false; +var ver=0,support=true,changed=false,specialChange=false,uni,uni2,g,h,SFJRX,DAWEO,Z,AEO,moc,trang,kl=0,tw5,range=null,fID=document.getElementsByTagName("iframe"); +skey=new Array(97,226,259,101,234,105,111,244,417,117,432,121,65,194,258,69,202,73,79,212,416,85,431,89); +var skey2="a,a,a,e,e,i,o,o,o,u,u,y,A,A,A,E,E,I,O,O,O,U,U,Y".split(','),A,E,O,whit=false,english="ĐÂĂƠƯÊÔ",lowen="đâăơưêô",ds1="d,D".split(","),db1=new Array(273,272); +os1="o,O,ơ,Ơ,ó,Ó,ò,Ò,ọ,Ọ,ỏ,Ỏ,õ,Õ,ớ,Ớ,ờ,Ờ,ợ,Ợ,ở,Ở,ỡ,Ỡ".split(","),ob1="ô,Ô,ô,Ô,ố,Ố,ồ,Ồ,ộ,Ộ,ổ,Ổ,ỗ,Ỗ,ố,Ố,ồ,Ồ,ộ,Ộ,ổ,Ổ,ỗ,Ỗ".split(","); +mocs1="o,O,ô,Ô,u,U,ó,Ó,ò,Ò,ọ,Ọ,ỏ,Ỏ,õ,Õ,ú,Ú,ù,Ù,ụ,Ụ,ủ,Ủ,ũ,Ũ,ố,Ố,ồ,Ồ,ộ,Ộ,ổ,Ổ,ỗ,Ỗ".split(",");mocb1="ơ,Ơ,ơ,Ơ,ư,Ư,ớ,Ớ,ờ,Ờ,ợ,Ợ,ở,Ở,ỡ,Ỡ,ứ,Ứ,ừ,Ừ,ự,Ự,ử,Ử,ữ,Ữ,ớ,Ớ,ờ,Ờ,ợ,Ợ,ở,Ở,ỡ,Ỡ".split(","); +trangs1="a,A,â,Â,á,Á,à,À,ạ,Ạ,ả,Ả,ã,Ã,ấ,Ấ,ầ,Ầ,ậ,Ậ,ẩ,Ẩ,ẫ,Ẫ".split(",");trangb1="ă,Ă,ă,Ă,ắ,Ắ,ằ,Ằ,ặ,Ặ,ẳ,Ẳ,ẵ,Ẵ,ắ,Ắ,ằ,Ằ,ặ,Ặ,ẳ,Ẳ,ẵ,Ẵ".split(","); +as1="a,A,ă,Ă,á,Á,à,À,ạ,Ạ,ả,Ả,ã,Ã,ắ,Ắ,ằ,Ằ,ặ,Ặ,ẳ,Ẳ,ẵ,Ẵ,ế,Ế,ề,Ề,ệ,Ệ,ể,Ể,ễ,Ễ".split(",");ab1="â,Â,â,Â,ấ,Ấ,ầ,Ầ,ậ,Ậ,ẩ,Ẩ,ẫ,Ẫ,ấ,Ấ,ầ,Ầ,ậ,Ậ,ẩ,Ẩ,ẫ,Ẫ,é,É,è,È,ẹ,Ẹ,ẻ,Ẻ,ẽ,Ẽ".split(","); +es1="e,E,é,É,è,È,ẹ,Ẹ,ẻ,Ẻ,ẽ,Ẽ".split(",");eb1="ê,Ê,ế,Ế,ề,Ề,ệ,Ệ,ể,Ể,ễ,Ễ".split(","); +arA="á,à,ả,ã,ạ,a,Á,À,Ả,Ã,Ạ,A".split(',');mocrA="ó,ò,ỏ,õ,ọ,o,ú,ù,ủ,ũ,ụ,u,Ó,Ò,Ỏ,Õ,Ọ,O,Ú,Ù,Ủ,Ũ,Ụ,U".split(',');erA="é,è,ẻ,ẽ,ẹ,e,É,È,Ẻ,Ẽ,Ẹ,E".split(',');orA="ó,ò,ỏ,õ,ọ,o,Ó,Ò,Ỏ,Õ,Ọ,O".split(','); +aA="ấ,ầ,ẩ,ẫ,ậ,â,Ấ,Ầ,Ẩ,Ẫ,Ậ,Â".split(',');mocA="ớ,ờ,ở,ỡ,ợ,ơ,ứ,ừ,ử,ữ,ự,ư,Ớ,Ờ,Ở,Ỡ,Ợ,Ơ,Ứ,Ừ,Ử,Ữ,Ự,Ư".split(',');trangA="ắ,ằ,ẳ,ẵ,ặ,ă,Ắ,Ằ,Ẳ,Ẵ,Ặ,Ă".split(',');eA="ế,ề,ể,ễ,ệ,ê,Ế,Ề,Ể,Ễ,Ệ,Ê".split(',');oA="ố,ồ,ổ,ỗ,ộ,ô,Ố,Ồ,Ổ,Ỗ,Ộ,Ô".split(','); + +function notWord(w) { + var str="\ \r\n#,\\;.:-_()<>+-*/=?!\"$%{}[]\'~|^\@\&\t"+fcc(160) + return (str.indexOf(w)>=0) +} +function nan(w) { + if ((isNaN(w))||(w=='e')) return true + else return false +} +function mozGetText(obj) { + var v,pos,w="";g=1 + v=(obj.data)?obj.data:obj.value + if(v.length<=0) return false + if(!obj.data) { + if(!obj.setSelectionRange) return false + pos=obj.selectionStart + } else pos=obj.pos + if(obj.selectionStart!=obj.selectionEnd) return new Array("",pos) + while(1) { + if(pos-g<0) break + else if(notWord(v.substr(pos-g,1))) { if(v.substr(pos-g,1)=="\\") w=v.substr(pos-g,1)+w; break } + else w=v.substr(pos-g,1)+w; g++ + } + return new Array(w,pos) +} +function start(obj,key) { + var w="",nnc;oc=obj;uni2=false + if(method==0) { uni="D,A,E,O,W,W".split(','); uni2="9,6,6,6,7,8".split(','); D2="DAWEO6789" } + else if(method==1) { uni="D,A,E,O,W,W".split(','); D2="DAWEO" } + else if(method==2) { uni="9,6,6,6,7,8".split(','); D2="6789" } + else if(method==3) { uni="D,^,^,^,+,(".split(','); D2="D^+(" } + else if(method==4) { uni="D,^,^,^,*,(".split(','); D2="D^*(" } + if(!is_ie) { + key=fcc(key.which) + w=mozGetText(obj) + if(D2.indexOf(up(key))>=0) nnc=true + else nnc=false + if((!w)||(obj.sel)) return + main(w[0],key,w[1],uni,nnc) + if(!dockspell) w=mozGetText(obj) + if((w)&&(uni2)&&(!changed)) main(w[0],key,w[1],uni2,nnc) + } else { + obj=ieGetText(obj) + if(obj) { + var sT=obj.cW.text + w=main(obj.cW.text,key,0,uni,false) + if((uni2)&&((w==sT)||(typeof(w)=='undefined'))) w=main(obj.cW.text,key,0,uni2,false) + if(w) obj.cW.text=w + } + } + if(D2.indexOf(up(key))>=0) { + if(!is_ie) { + w=mozGetText(obj) + if(!w) return + normC(w[0],key,w[1]) + } else if(typeof(obj)=="object") { + obj=ieGetText(obj) + if(obj) { + w=obj.cW.text + if(!changed) { w+=key; changed=true } + obj.cW.text=w + w=normC(w,key,0) + if(w) { obj=ieGetText(obj); obj.cW.text=w } + } + } + } +} +function ieGetText(obj) { + var caret=obj.document.selection.createRange(),w="" + if(caret.text) caret.text="" + else { + while(1) { + caret.moveStart("character",-1) + if(w.length==caret.text.length) break + w=caret.text + if(notWord(w.charAt(0))) { + if(w.charCodeAt(0)==13) w=w.substr(2) + else if(w.charAt(0)!="\\") w=w.substr(1) + break + } + } + } + if(w.length) { + caret.collapse(false) + caret.moveStart("character",-w.length) + obj.cW=caret.duplicate() + return obj + } else return false +} +function ie_replaceChar(w,pos,c) { + var r="",uc=0 + if(isNaN(c)) uc=up(c) + if((whit)&&(up(w.substr(w.length-pos-1,1))=='U')&&(pos!=1)&&(up(w.substr(w.length-pos-2,1))!='Q')) { + whit=false + if((up(unV(fcc(c)))=="Ơ")||(uc=="O")) { + if(w.substr(w.length-pos-1,1)=='u') r=fcc(432) + else r=fcc(431) + } + if(uc=="O") { + if(c=="o") c=417 + else c=416 + } + } + if(!isNaN(c)) { + changed=true;r+=fcc(c) + return w.substr(0,w.length-pos-r.length+1)+r+w.substr(w.length-pos+1) + } else return w.substr(0,w.length-pos)+c+w.substr(w.length-pos+1) +} +function tr(k,w,by,sf,i) { + var r,pos=findC(w,k,sf) + if(pos) { + if(pos[1]) { + if(is_ie) return ie_replaceChar(w,pos[0],pos[1]) + else return replaceChar(oc,i-pos[0],pos[1]) + } else { + var c,pC=w.substr(w.length-pos,1),cmp;r=sf + for(g=0;g<r.length;g++) { + if((nan(r[g]))||(r[g]=="e")) cmp=pC + else cmp=pC.charCodeAt(0) + if(cmp==r[g]) { + if(!nan(by[g])) c=by[g] + else c=by[g].charCodeAt(0) + if(is_ie) return ie_replaceChar(w,pos,c) + else return replaceChar(oc,i-pos,c) + } + } + } + } + return false +} +function main(w,k,i,a,nnc) { + var uk=up(k),bya=new Array(db1,ab1,eb1,ob1,mocb1,trangb1),got=false,t="d,D,a,A,a,A,o,O,u,U,e,E,o,O".split(",") + var sfa=new Array(ds1,as1,es1,os1,mocs1,trangs1),by=new Array(),sf=new Array() + if((method==2)||((method==0)&&(a[0]=="9"))) { + DAWEO="6789";SFJRX="12534";S="1";F="2";J="5";R="3";X="4";Z="0";D="9";FRX="234";AEO="6";moc="7";trang="8";them="678";A="^";E="^";O="^" + } else if(method==3) { + DAWEO="^+(D";SFJRX="'`.?~";S="'";F="`";J=".";R="?";X="~";Z="-";D="D";FRX="`?~";AEO="^";moc="+";trang="(";them="^+(";A="^";E="^";O="^" + } else if(method==4) { + DAWEO="^*(D";SFJRX="'`.?~";S="'";F="`";J=".";R="?";X="~";Z="-";D="D";FRX="`?~";AEO="^";moc="*";trang="(";them="^*(";A="^";E="^";O="^" + } else if((method==1)||((method==0)&&(a[0]=="D"))) { + SFJRX="SFJRX";DAWEO="DAWEO";D='D';S='S';F='F';J='J';R='R';X='X';Z='Z';FRX="FRX";them="AOEW";trang="W";moc="W";A="A";E="E";O="O" + } + if(SFJRX.indexOf(uk)>=0) { + var ret=sr(w,k,i); got=true + if(ret) return ret + } else if(uk==Z) { + sf=repSign(null) + for(h=0;h<english.length;h++) { + sf[sf.length]=lowen.charCodeAt(h) + sf[sf.length]=english.charCodeAt(h) + } + for(h=0;h<5;h++) for(g=0;g<skey.length;g++) by[by.length]=skey[g] + for(h=0;h<t.length;h++) by[by.length]=t[h] + got=true + } + else for(h=0;h<a.length;h++) if(a[h]==uk) { got=true; by=by.concat(bya[h]); sf=sf.concat(sfa[h]) } + if(uk==moc) whit=true; + if(!got) { + if(nnc) return + return normC(w,k,i) + } + return DAWEOZ(k,w,by,sf,i,uk) +} +function DAWEOZ(k,w,by,sf,i,uk) { if((DAWEO.indexOf(uk)>=0)||(Z.indexOf(uk)>=0)) return tr(k,w,by,sf,i) } +function normC(w,k,i) { + var uk=up(k),u=repSign(null),fS,c,j,space=(k.charCodeAt(0)==32)?true:false + if((!is_ie)&&(space)) return + for(j=1;j<=w.length;j++) { + for(h=0;h<u.length;h++) { + if(u[h]==w.charCodeAt(w.length-j)) { + if(h<=23) fS=S + else if(h<=47) fS=F + else if(h<=71) fS=J + else if(h<=95) fS=R + else fS=X + c=skey[h%24]; if((alphabet.indexOf(uk)<0)&&(D2.indexOf(uk)<0)) return w; w=unV(w) + if((!space)&&(!changed)) w+=k + if(!is_ie) { + var sp=oc.selectionStart,pos=sp + if(!changed) { + var sst=oc.scrollTop;pos+=k.length + if(!oc.data) { oc.value=oc.value.substr(0,sp)+k+oc.value.substr(oc.selectionEnd);changed=true;oc.scrollTop=sst } + else { oc.insertData(oc.pos,k);oc.pos++;range.setEnd(oc,oc.pos);specialChange=true } + } + if(!oc.data) oc.setSelectionRange(pos,pos) + if(!ckspell(w,fS)) { + replaceChar(oc,i-j,c) + if(!oc.data) { + var a=new Array(D) + main(w,fS,pos,a,false) + } else { + var ww=mozGetText(oc) + var a=new Array(D) + main(ww[0],fS,ww[1],a,false) + } + } + } else { + var ret=sr(w,fS,0) + if((space)&&(ret)) ret+=fcc(32) + if(ret) return ret + } + } + } + } +} +function nospell(w,k) { return false } +function ckspell(w,k) { + w=unV(w); var exc="UOU,IEU".split(','),z,next=true,noE="UU,UOU,UOI,IEU,AO,IA,AI,AY,AU,AO".split(','),noBE="YEU",test,a,b + var check=true,noM="UE,UYE,IU,EU,UY".split(','),noMT="AY,AU".split(','),noT="UA",t=-1,notV2="IAO" + var uw=up(w),tw=uw,update=false,gi="IO",noAOEW="OE,OO,AO,EO,IA,AI".split(','),noAOE="OA" + var notViet="AA,AE,EE,OU,YY,YI,IY,EY,EA,EI,II,IO,YO,YA,OOO".split(','),uk=up(k),twE,uw2=unV2(uw) + var vSConsonant="B,C,D,G,H,K,L,M,N,P,Q,R,S,T,V,X".split(','),vDConsonant="CH,GI,KH,NGH,GH,NG,NH,PH,QU,TH,TR".split(',') + var vDConsonantE="CH,NG,NH".split(','),sConsonant="C,P,T,CH".split(','),vSConsonantE="C,M,N,P,T".split(',') + var noNHE="O,U,IE,Ô,Ơ,Ư,IÊ,Ă,Â,UYE,UYÊ,UO,ƯƠ,ƯO,UƠ,UA,ƯA,OĂ,OE,OÊ".split(','),oMoc="UU,UOU".split(',') + if(FRX.indexOf(uk)>=0) for(a=0;a<sConsonant.length;a++) if(uw.substr(uw.length-sConsonant[a].length,sConsonant[a].length)==sConsonant[a]) return true + for(a=0;a<uw.length;a++) { + if("FJZW1234567890".indexOf(uw.substr(a,1))>=0) return true + for(b=0;b<notViet.length;b++) { + if(uw2.substr(a,notViet[b].length)==notViet[b]) { + for(z=0;z<exc.length;z++) if(uw2.indexOf(exc[z])>=0) next=false + if((next)&&((gi.indexOf(notViet[b])<0)||(a<=0)||(uw2.substr(a-1,1)!='G'))) return true + } + } + } + for(b=0;b<vDConsonant.length;b++) if(tw.indexOf(vDConsonant[b])==0){tw=tw.substr(vDConsonant[b].length);update=true;t=b;break} + if(!update) for(b=0;b<vSConsonant.length;b++) if(tw.indexOf(vSConsonant[b])==0){tw=tw.substr(1);break} + update=false;twE=tw + for(b=0;b<vDConsonantE.length;b++) { + if(tw.substr(tw.length-vDConsonantE[b].length)==vDConsonantE[b]) { + tw=tw.substr(0,tw.length-vDConsonantE[b].length) + if(b==2){ + for(z=0;z<noNHE.length;z++) if(tw==noNHE[z]) return true + if((uk==trang)&&((tw=="OA")||(tw=="A"))) return true + } + update=true;break + } + } + if(!update) for(b=0;b<vSConsonantE.length;b++) if(tw.substr(tw.length-1)==vSConsonantE[b]){tw=tw.substr(0,tw.length-1);break} + if(tw) { + for(a=0;a<vDConsonant.length;a++) { + for(b=0;b<tw.length;b++) { if(tw.substr(b,vDConsonant[a].length)==vDConsonant[a]) return true } + } + for(a=0;a<vSConsonant.length;a++) { if(tw.indexOf(vSConsonant[a])>=0) return true } + } + test=tw.substr(0,1) + if((t==3)&&((test=="A")||(test=="O")||(test=="U")||(test=="Y"))) return true + if((t==5)&&((test=="E")||(test=="I")||(test=="Y"))) return true + uw2=unV2(tw) + if(uw2==notV2) return true + if(tw!=twE) for(z=0;z<noE.length;z++) if(uw2==noE[z]) return true + if((tw!=uw)&&(uw2==noBE)) return true + if(uk!=moc) for(z=0;z<oMoc.length;z++) if(tw==oMoc[z]) return true + if((uw2.indexOf('UYE')>0)&&(uk=='E')) check=false + if((them.indexOf(uk)>=0)&&(check)) { + for(a=0;a<noAOEW.length;a++) if(uw2.indexOf(noAOEW[a])>=0) return true + if(uk!=trang) if(uw2==noAOE) return true + if((uk==trang)&&(trang!='W')) if(uw2==noT) return true + if(uk==moc) for(a=0;a<noM.length;a++) if(uw2==noM[a]) return true + if((uk==moc)||(uk==trang)) for(a=0;a<noMT.length;a++) if(uw2==noMT[a]) return true + } + tw5=tw + if((uw2.charCodeAt(0)==272)||(uw2.charCodeAt(0)==273)) { if(uw2.length>4) return true } + else if(uw2.length>3) return true + return false +} +function DAWEOF(cc,k) { + var ret=new Array(),kA=new Array(A,moc,trang,E,O),z,a;ret[0]=g + var ccA=new Array(aA,mocA,trangA,eA,oA),ccrA=new Array(arA,mocrA,arA,erA,orA) + for(a=0;a<kA.length;a++) if(k==kA[a]) for(z=0;z<ccA[a].length;z++) if(cc==ccA[a][z]) ret[1]=ccrA[a][z] + if(ret[1]) return ret + else return false +} +function findC(w,k,sf) { + if(((method==3)||(method==4))&&(w.substr(w.length-1,1)=="\\")) return new Array(1,k.charCodeAt(0)) + var str="",res,cc="",pc="",tE="",vowA=new Array(),s="ÂĂÊÔƠƯêâăơôư",c=0,dn=false,uw=up(w),tv + var DAWEOFA=aA.join()+eA.join()+mocA.join()+trangA.join()+oA.join()+english;DAWEOFA=up(DAWEOFA) + for(g=0;g<sf.length;g++) { + if(nan(sf[g])) str+=sf[g] + else str+=fcc(sf[g]) + } + var uk=up(k),i=w.length,uni_array=repSign(k),w2=up(unV2(unV(w))),dont="ƯA,ƯU".split(',') + if (DAWEO.indexOf(uk)>=0) { + if(uk==moc) { + if((w2.indexOf("UU")>=0)&&(tw5!=dont[1])) { + if(w2.indexOf("UU")==(w.length-2)) res=2 + else return false + } else if(w2.indexOf("UOU")>=0) { + if(w2.indexOf("UOU")==(w.length-3)) res=2 + else return false + } + } + if(!res) { + for(g=1;g<=w.length;g++) { + cc=w.substr(w.length-g,1) + pc=up(w.substr(w.length-g-1,1)) + uc=up(cc) + for(h=0;h<dont.length;h++) if((tw5==dont[h])&&(tw5==unV(pc+uc))) dn=true + if(dn) { dn=false; continue } + if(str.indexOf(uc)>=0) { + if(((uk==moc)&&(unV(uc)=="U")&&(up(unV(w.substr(w.length-g+1,1)))=="A"))||((uk==trang)&&(unV(uc)=='A')&&(unV(pc)=='U'))) { + if(unV(uc)=="U") tv=1 + else tv=2 + ccc=up(w.substr(w.length-g-tv,1)) + if(ccc!="Q") res=g+tv-1 + else if(uk==trang) res=g + else if(moc!=trang) return false + } else res=g + if((!whit)||(uw.indexOf("Ư")<0)||(uw.indexOf("W")<0)) break + } else if(DAWEOFA.indexOf(uc)>=0) { + if(uk==D) { + if(cc=="đ") res=new Array(g,'d') + else if(cc=="Đ") res=new Array(g,'D') + } else res=DAWEOF(cc,uk) + if(res) break + } + } + } + } + if((uk!=Z)&&(DAWEO.indexOf(uk)<0)) { var tEC=retKC(uk); for (g=0;g<tEC.length;g++) tE+=fcc(tEC[g]) } + for(g=1;g<=w.length;g++) { + if(DAWEO.indexOf(uk)<0) { + cc=up(w.substr(w.length-g,1)) + pc=up(w.substr(w.length-g-1,1)) + if(str.indexOf(cc)>=0) { + if(cc=='U') { + if(pc!='Q') { c++;vowA[vowA.length]=g } + } else if(cc=='I') { + if((pc!='G')||(c<=0)) { c++;vowA[vowA.length]=g } + } else { c++;vowA[vowA.length]=g } + } else if(uk!=Z) { + for(h=0;h<uni_array.length;h++) if(uni_array[h]==w.charCodeAt(w.length-g)) { + if(spellerr(w,k)) return false + return new Array(g,tEC[h%24]) + } + for(h=0;h<tEC.length;h++) if(tEC[h]==w.charCodeAt(w.length-g)) return new Array(g,fcc(skey[h])) + } + } + } + if((uk!=Z)&&(typeof(res)!='object')) if(spellerr(w,k)) return false + if(DAWEO.indexOf(uk)<0) { + for(g=1;g<=w.length;g++) { + if((uk!=Z)&&(s.indexOf(w.substr(w.length-g,1))>=0)) return g + else if(tE.indexOf(w.substr(w.length-g,1))>=0) { + for(h=0;h<tEC.length;h++) { + if(w.substr(w.length-g,1).charCodeAt(0)==tEC[h]) return new Array(g,fcc(skey[h])) + } + } + } + } + if(res) return res + if((c==1)||(uk==Z)) return vowA[0] + else if(c==2) { + var v=2 + if(w.substr(w.length-1)==" ") v=3 + var ttt=up(w.substr(w.length-v,2)) + if((dauCu==0)&&((ttt=="UY")||(ttt=="OA")||(ttt=="OE"))) return vowA[0] + var c2=0,fdconsonant,sc="BCD"+fcc(272)+"GHKLMNPQRSTVX",dc="CH,GI,KH,NGH,GH,NG,NH,PH,QU,TH,TR".split(',') + for(h=1;h<=w.length;h++) { + fdconsonant=false + for(g=0;g<dc.length;g++) { + if(up(w.substr(w.length-h-dc[g].length+1,dc[g].length)).indexOf(dc[g])>=0) { + c2++;fdconsonant=true + if(dc[g]!='NGH') h++ + else h+=2 + } + } + if(!fdconsonant) { + if(sc.indexOf(up(w.substr(w.length-h,1)))>=0) c2++ + else break + } + } + if((c2==1)||(c2==2)) return vowA[0] + else return vowA[1] + } else if(c==3) return vowA[1] + else return false +} +function unV(w) { + var u=repSign(null),b,a + for(a=1;a<=w.length;a++) { + for(b=0;b<u.length;b++) { + if(u[b]==w.charCodeAt(w.length-a)) { + w=w.substr(0,w.length-a)+fcc(skey[b%24])+w.substr(w.length-a+1) + } + } + } + return w +} +function unV2(w) { + var a,b + for(a=1;a<=w.length;a++) { + for(b=0;b<skey.length;b++) { + if(skey[b]==w.charCodeAt(w.length-a)) w=w.substr(0,w.length-a)+skey2[b]+w.substr(w.length-a+1) + } + } + return w +} +function repSign(k) { + var t=new Array(),u=new Array(),a,b + for(a=0;a<5;a++) { + if((k==null)||(SFJRX.substr(a,1)!=up(k))) { + t=retKC(SFJRX.substr(a,1)) + for(b=0;b<t.length;b++) u[u.length]=t[b] + } + } + return u +} +function sr(w,k,i) { + var sf=getSF() + pos=findC(w,k,sf) + if(pos) { + if(pos[1]) { + if(!is_ie) replaceChar(oc,i-pos[0],pos[1]) + else return ie_replaceChar(w,pos[0],pos[1]) + } else { + var c=retUni(w,k,pos) + if (!is_ie) replaceChar(oc,i-pos,c) + else return ie_replaceChar(w,pos,c) + } + } + return false +} +function retUni(w,k,pos) { + var u=retKC(up(k)),uC,lC,c=w.charCodeAt(w.length-pos),a + for(a=0;a<skey.length;a++) if(skey[a]==c) { + if(a<12) { lC=a;uC=a+12 } + else { lC=a-12;uC=a } + t=fcc(c);if(t!=up(t)) return u[lC] + return u[uC] + } +} +function replaceChar(o,pos,c) { + var bb=false; if(!nan(c)) { var replaceBy=fcc(c),wfix=up(unV(fcc(c))); changed=true } + else { var replaceBy=c; if((up(c)=="O")&&(whit)) bb=true } + if(!o.data) { + var savePos=o.selectionStart,sst=o.scrollTop + if ((up(o.value.substr(pos-1,1))=='U')&&(pos<savePos-1)&&(up(o.value.substr(pos-2,1))!='Q')) { + if((wfix=="Ơ")||(bb)) + { + if (o.value.substr(pos-1,1)=='u') var r=fcc(432) + else var r=fcc(431) + } + if(bb) { + changed=true; if(c=="o") replaceBy="ơ" + else replaceBy="Ơ" + } + } + o.value=o.value.substr(0,pos)+replaceBy+o.value.substr(pos+1) + if(r) o.value=o.value.substr(0,pos-1)+r+o.value.substr(pos) + o.setSelectionRange(savePos,savePos);o.scrollTop=sst + } else { + if ((up(o.data.substr(pos-1,1))=='U')&&(pos<o.pos-1)) { + if((wfix=="Ơ")||(bb)) + { + if (o.data.substr(pos-1,1)=='u') var r=fcc(432) + else var r=fcc(431) + } + if(bb) { + changed=true; if(c=="o") replaceBy="ơ" + else replaceBy="Ơ" + } + } + o.deleteData(pos,1);o.insertData(pos,replaceBy) + if(r) { o.deleteData(pos-1,1);o.insertData(pos-1,r) } + } + if(whit) whit=false +} +function retKC(k) { + if(k==S) return new Array(225,7845,7855,233,7871,237,243,7889,7899,250,7913,253,193,7844,7854,201,7870,205,211,7888,7898,218,7912,221) + if(k==F) return new Array(224,7847,7857,232,7873,236,242,7891,7901,249,7915,7923,192,7846,7856,200,7872,204,210,7890,7900,217,7914,7922) + if(k==J) return new Array(7841,7853,7863,7865,7879,7883,7885,7897,7907,7909,7921,7925,7840,7852,7862,7864,7878,7882,7884,7896,7906,7908,7920,7924) + if(k==R) return new Array(7843,7849,7859,7867,7875,7881,7887,7893,7903,7911,7917,7927,7842,7848,7858,7866,7874,7880,7886,7892,7902,7910,7916,7926) + if(k==X) return new Array(227,7851,7861,7869,7877,297,245,7895,7905,361,7919,7929,195,7850,7860,7868,7876,296,213,7894,7904,360,7918,7928) +} +function getEL(id) { return document.getElementById(id) } +function getSF() { var sf=new Array(),x; for(x=0;x<skey.length;x++) sf[sf.length]=fcc(skey[x]); return sf } +function statusMessage() { + var str='Kiểu gõ: ' + if(on_off==0) str+='Tắt' + else if(method==1) str+='TELEX' + else if(method==2) str+='VNI' + else if(method==3) str+='VIQR' + else if(method==4) str+='VIQR*' + else if(method==0) str+='Tự động' + if(isKHTML) str+=" [Alt-F9]" + else str+=" [F9]" + str+=" | Chính tả: " + str+=(dockspell==0)?"Tắt":"Bật" + if(isKHTML) str+=" [Alt-F8]" + else str+=" [F8]" + str+=" | Bỏ dấu: " + str+=(dauCu==1)?"Cũ":"Mới" + if(isKHTML) str+=" [Alt-F7]" + else str+=" [F7]" + str+=" | Bật/Tắt [F12] - AVIM 20071102" + window.status=str +} +function updateInfo() { setCookie(); if(support) statusMessage() } +function setMethod(m) { + if(m==-1) { on_off=0;if(getEL(radioID[5])) getEL(radioID[5]).checked=true } + else { on_off=1;method=m;if(getEL(radioID[m])) getEL(radioID[m]).checked=true } + setSpell(dockspell);setDauCu(dauCu);updateInfo() +} +function setDauCu(box) { + if(typeof(box)=="number") { + dauCu=box;if(getEL(radioID[7])) getEL(radioID[7]).checked=box + } else dauCu=(box.checked)?1:0 + updateInfo() +} +function setSpell(box) { + if(typeof(box)=="number") { + spellerr=(box==1)?ckspell:nospell + if(getEL(radioID[6])) getEL(radioID[6]).checked=box + } + else { + if(box.checked) { spellerr=ckspell;dockspell=1 } + else { spellerr=nospell;dockspell=0 } + } + updateInfo() +} +function onKeyDown(e) { + if (e=='iframe') { frame=findF();var key=frame.event.keyCode } + else var key=(!is_ie)?e.which:window.event.keyCode + if((key==120)||(key==123)||(key==119)||(key==118)) { + if(key==120) { on_off=1;setMethod(((method==4)?0:++method)) } + else if(key==118) { setDauCu(((dauCu==1)?0:1)) } + else if(key==119) { dockspell=(dockspell==0)?1:0;setSpell(dockspell) } + else if(key==123) { + on_off=(on_off==0)?1:0 + if(on_off==0) setMethod(-1) + else setMethod(method) + } + updateInfo() + } +} +function ifInit(w) { + var sel=w.getSelection() + range=sel?sel.getRangeAt(0):document.createRange() +} +function ifMoz(e) { + var code=e.which,cwi=e.target.parentNode.wi + if(typeof(cwi)=="undefined") cwi=e.target.parentNode.parentNode.wi + if((e.ctrlKey)||((e.altKey)&&(code!=92)&&(code!=126))) return;ifInit(cwi) + var node=range.endContainer,newPos;sk=fcc(code);saveStr="" + if(checkCode(code)||(!range.startOffset)||(typeof(node.data)=='undefined')) return;node.sel=false + if(node.data) { + saveStr=node.data.substr(range.endOffset) + if(range.startOffset!=range.endOffset) node.sel=true + node.deleteData(range.startOffset,node.data.length) + } + range.setEnd(node,range.endOffset) + range.setStart(node,0) + if(!node.data) return + node.value=node.data; node.pos=node.data.length; node.which=code + start(node,e) + node.insertData(node.data.length,saveStr) + newPos=node.data.length-saveStr.length+kl + range.setEnd(node,newPos);range.setStart(node,newPos);kl=0 + if(specialChange) { specialChange=false; changed=false; node.deleteData(node.pos-1,1) } + if(changed) { changed=false; e.preventDefault() } +} +function FKeyPress() { + var obj=findF() + sk=fcc(obj.event.keyCode) + if(checkCode(obj.event.keyCode)||((obj.event.ctrlKey)&&(obj.event.keyCode!=92)&&(obj.event.keyCode!=126))) return + start(obj,fcc(obj.event.keyCode)) + if (changed) { changed=false; return false } +} +function checkCode(code) { if(((on_off==0)||((code<45)&&(code!=42)&&(code!=32)&&(code!=39)&&(code!=40)&&(code!=43))||(code==145)||(code==255))) return true; return false } +function fcc(x) { return String.fromCharCode(x) } +if(useCookie==1) { setCookie=doSetCookie; getCookie=doGetCookie } +else { setCookie=noCookie; getCookie=noCookie } +function noCookie() {} +function doSetCookie() { + var exp=new Date(11245711156480).toGMTString(),end=';expires='+exp+';path=/' + document.cookie='AVIM_on_off='+on_off+end + document.cookie='AVIM_method='+method+end + document.cookie='AVIM_ckspell='+dockspell+end + document.cookie='AVIM_daucu='+dauCu+end +} +function doGetCookie() { + var ck=document.cookie, res=/AVIM_method/.test(ck) + if((!res)||(ck.indexOf('AVIM_ckspell')<0)) { setCookie(); return } + var p,ckA=ck.split(';') + for(var i=0;i<ckA.length;i++) { + p=ckA[i].split('='); p[0]=p[0].replace(/^\s+/g,""); p[1]=parseInt(p[1]) + if(p[0]=='AVIM_on_off') on_off=p[1] + else if(p[0]=='AVIM_method') method=p[1] + else if(p[0]=='AVIM_ckspell') { + if(p[1]==0) { dockspell=0; spellerr=nospell } + else { dockspell=1; spellerr=ckspell } + } else if(p[0]=='AVIM_daucu') dauCu=parseInt(p[1]) + } +} +if(!is_ie) { + if(agt.indexOf("opera")>=0) { + operaV=agt.split(" ");operaVersion=parseInt(operaV[operaV.length-1]) + if(operaVersion>=8) is_opera=true + else { + operaV=operaV[0].split("/");operaVersion=parseInt(operaV[1]) + if(operaVersion>=8) is_opera=true + } + } else if(agt.indexOf("khtml")>=0) isKHTML=true + else { + ver=agt.substr(agt.indexOf("rv:")+3) + ver=parseFloat(ver.substr(0,ver.indexOf(" "))) + if(agt.indexOf("mozilla")<0) ver=0 + } +} +function up(w) { + w=w.toUpperCase() + if(isKHTML) { + str="êôơâăưếốớấắứềồờầằừễỗỡẫẵữệộợậặự",rep="ÊÔƠÂĂƯẾỐỚẤẮỨỀỒỜẦẰỪỄỖỠẪẴỮỆỘỢẶỰ" + for(z=0;z<w.length;z++) { + io=str.indexOf(w.substr(z,1)) + if(io>=0) w=w.substr(0,z)+rep.substr(io,1)+w.substr(z+1) + } + } + return w +} +function findIgnore(el) { + for(i=0;i<va.length;i++) if((el.id==va[i])&&(va[i].length>0)) return true +} +if((is_ie)||(ver>=1.3)||(is_opera)||(isKHTML)) { + getCookie() + if(on_off==0) setMethod(-1) + else setMethod(method) + setSpell(dockspell);setDauCu(dauCu);statusMessage() +} else support=false +function onKeyPress(e) { + if(!support) return + if(!is_ie) { var el=e.target,code=e.which; if(e.ctrlKey) return; if((e.altKey)&&(code!=92)&&(code!=126)) return } + else { var el=window.event.srcElement,code=window.event.keyCode; if((event.ctrlKey)&&(code!=92)&&(code!=126)) return } + if(((el.type!='textarea')&&(el.type!='text'))||checkCode(code)) return + sk=fcc(code); if (findIgnore(el)) return + if(!is_ie) start(el,e) + else start(el,sk) + if(changed) { + changed=false + if (!is_ie) e.preventDefault() + else return false + } +} +function attachEvt(obj,evt,handle,capture) { + if(is_ie) { obj.attachEvent("on"+evt,handle); obj.attachEvent("on"+evt,getCookie) } + else { obj.addEventListener(evt,handle,capture); obj.addEventListener(evt,getCookie,capture) } +} +attachEvt(document,"keydown",onKeyDown,false) +attachEvt(document,"keypress",onKeyPress,false) +function findF() { + for(g=0;g<fID.length;g++) { + if(findIgnore(fID[g])) continue;frame=fID[g] + if(typeof(frame)!="undefined") { + try { if((frame.contentWindow.document)&&(frame.contentWindow.event)) return frame.contentWindow } + catch(e) { if((frame.document)&&(frame.event)) return frame } + } + } +} +function onKeyDownI() { onKeyDown("iframe") } +function init() { +var kkk=false +if((support)&&(!isKHTML)) { + if(is_opera) { if(operaVersion<9) return } + for(g=0;g<fID.length;g++) { + if(findIgnore(fID[g])) continue + if(is_ie) { + var doc + try { + frame=fID[g];if(typeof(frame)!="undefined") { + if(frame.contentWindow.document) doc=frame.contentWindow.document + else if(frame.document) doc=frame.document + } + if((doc)&&((up(doc.designMode)=="ON")||(doc.body.contentEditable))) { + for(l=0;l<attached.length;l++) if(doc==attached[l]) { kkk=true; break } + if(!kkk) { + attached[attached.length]=doc + attachEvt(doc,"keydown",onKeyDownI,false) + attachEvt(doc,"keypress",FKeyPress,false) + } else kkk=false + } + } + catch(e) { } + } else { + var iframedit + try { + wi=fID[g].contentWindow;iframedit=wi.document;iframedit.wi=wi + if((iframedit)&&(up(iframedit.designMode)=="ON")) { + attachEvt(iframedit,"keypress",ifMoz,false) + attachEvt(iframedit,"keydown",onKeyDown,true) + } + } catch(e) { } + } + } +} +} +function uglyF() { ugly=50;while(ugly<5000) {setTimeout("init()",ugly);ugly+=50} } +uglyF();attachEvt(document,"mousedown",uglyF,false); + +// end AVIM JavaScript Vietnamese Input Method + +(function() { + // Load plugin specific language pack + tinymce.PluginManager.requireLangPack('vietunicode'); + + tinymce.create('tinymce.plugins.VietUnicode', { + + createControl: function(n, cm) { + switch (n) { + case 'vietunicode_method_listbox': + var mlb = cm.createListBox('vietunicode_method_listbox', { + title : 'vietunicode.select_input_method', + onselect : function(v) { + setMethod(v); + } + }); + + // Add some values to the list box + mlb.add('vietunicode.off_desc', -1); + mlb.add('vietunicode.telex_desc', 1); + mlb.add('vietunicode.vni_desc', 2); + mlb.add('vietunicode.viqr_desc', 3); + mlb.add('vietunicode.auto_desc', 0); + + mlb.select(method); + + // Return the new listbox instance + return mlb; + } + + return null; + }, + + init : function(ed, url) { + ed.onBeforeRenderUI.add(function() { + tinymce.DOM.loadCSS(url + "/css/content.css"); + }); + }, + + getInfo : function() { + return { + longname : 'VietUnicode', + author : 'S.H.Mohanjith', + authorurl : 'http://mohanjith.com', + infourl : 'http://mohanjith.com/portfolio/tinymce/vietunicode', + version : '1.0' + }; + } + }); + + // Register plugin + tinymce.PluginManager.add('vietunicode', tinymce.plugins.VietUnicode); +})(); \ No newline at end of file Added: trunk/vietunicode/langs/en.js =================================================================== --- trunk/vietunicode/langs/en.js (rev 0) +++ trunk/vietunicode/langs/en.js 2008-04-14 10:01:40 UTC (rev 2) @@ -0,0 +1,8 @@ +tinyMCE.addI18n({en:{vietunicode:{ +select_input_method:"Gõ Tiếng Việt", +off_desc:"Normal", +telex_desc:"Telex", +vni_desc:"VNI", +viqr_desc:"VIQR", +auto_desc:"Tự Động" +}}}); \ No newline at end of file Added: trunk/vietunicode/readme.txt =================================================================== --- trunk/vietunicode/readme.txt (rev 0) +++ trunk/vietunicode/readme.txt 2008-04-14 10:01:40 UTC (rev 2) @@ -0,0 +1,54 @@ +AVIM JavaScript Vietnamese Input Method TinyMCE plugin +====================================================== + +Installation +------------- + 1. Place the vietunicode directory in jscripts/tiny_mce/plugins directory. Directory + structure should look like bellow. + + - jscripts/ + |- ... + |- plugins/ + |-- ... + |-- vietunicode/ + |-- ... + |- .. + + 2. Add vietunicode to the list of plugins in the tinyMCE.init object. (Specified in the file you + are using TinyMCE in) + + e.g. + tinyMCE.init({ + mode : "textareas", + theme : "simple", + plugins : "vietunicode" + }); + + 3. Add vietunicode_method_listbox to theme options. Specified in the file you are using TinyMCE in) + + e.g. + tinyMCE.init({ + mode : "textareas", + theme : "simple", + plugins : "vietunicode", + theme_advanced_buttons1 : "vietunicode_method_listbox" + }); + + If you find step 2 and 3 confusing please send me the file you are using TinyMCE in. + +Changing captions +----------------- +All captions relating to the plugin are found in the file vietunicode/langs/en.js. The file is a +standard TinyMCE plug-in language file. + + e.g. + tinyMCE.addI18n({en:{vietunicode:{ + select_input_method:"Gõ Tiếng Việt", + off_desc:"Normal", + telex_desc:"Telex", + vni_desc:"VNI", + viqr_desc:"VIQR", + auto_desc:"Tự Động" + }}}); + +-- Mohanjith (moha at mohanjith.net) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |