var CookieManager={set:function(_1,_2){
var _3=new Date();
_3.setTime(_3.getTime()+(30*24*60*60*1000));
var _4="; expires="+_3.toGMTString();
document.cookie=_1+"="+escape(_2)+_4;
},get:function(_5){
var dc=document.cookie;
var _7=_5+"=";
var _8=dc.indexOf("; "+_7);
if(_8==-1){
_8=dc.indexOf(_7);
if(_8!==0){
return null;
}
}else{
_8+=2;
}
var _9=document.cookie.indexOf(";",_8);
if(_9==-1){
_9=dc.length;
}
return unescape(dc.substring(_8+_7.length,_9));
},erase:function(_a){
var _b=new Date(2000,1,1,19,30,30);
document.cookie=_a+"=; expires="+_b.toGMTString();
}};
CookieManager.setCookiePair=function(_c,_d,_e){
var _f,end;
var _11=CookieManager.get(_c);
var _12=[_d,"@",_e,"#"].join("");
function trimEntry(s){
var a=s.split(",");
return a.slice(3).join(",");
}
if(!_11){
CookieManager.set(_c,_12);
}else{
_f=_11.search(eval("/(^|#)"+_d+"@/"));
if(_f===-1){
_11+=_12;
}else{
if(_11.charAt(_f)==="#"){
_f+=1;
}
end=_11.indexOf("#",_f);
_11=_11.replace(_11.substring(_f,end+1),_12);
}
while(_11.length>600){
_11=trimEntry(_11);
}
CookieManager.set(_c,_11);
}
};
CookieManager.getCookiePair=function(_15,key){
var _17=CookieManager.get(_15);
if(!_17){
return null;
}
var _18=_17.search(eval("/(^|#)"+key+"@/"));
if(_18===-1){
return null;
}
var end=_17.indexOf("#",_18+1);
var s=_17.substring(_18,end);
return s.split("@")[1];
};

var QuillUtil={lang:"hindi",getLangLegacy:function(){
if(window.defaultLang){
return window.defaultLang;
}
var _1;
try{
_1=window.location.pathname.match(/\/[a-z]+/g);
if(window.location.pathname.slice(-1)==="/"){
return _1[_1.length-1].substring(1);
}
return _1[_1.length-2].substring(1);
}
catch(e){
return "hindi";
}
},getLang:function(){
return QuillUtil.lang;
},setLang:function(_2){
QuillUtil.lang=_2;
},isValidEmailID:function(_3){
var _4=_3.match(/^[0-9a-zA-Z_\.-]+@([0-9a-zA-Z_-]+\.)+[a-zA-Z0-9_-]+$/);
return (_4!==null);
},isValidEmailIDGroup:function(_5){
var _6=_5.split(/[\s\+,]+/);
var _7;
for(var i=0;i<_6.length;++i){
logger.info(_6[i]);
_7=_6[i].match(/^[0-9a-zA-Z_\.-]+@([0-9a-zA-Z_-]+\.)+[a-zA-Z0-9_-]+$/);
if(_7===null){
return false;
}
}
return true;
},getRandom:function(_9){
var _a=Math.random()-0.5;
_a=_a*Math.pow(2,32);
return Math.floor(_a);
},getBrowser:function(){
var ua=window.navigator.userAgent.toLowerCase();
var _c;
var _d;
var _e;
if(ua.indexOf("opera")!=-1){
return "opera";
}else{
if(ua.indexOf("safari")!=-1){
return "safari";
}else{
if(ua.indexOf("msie 6.0")!=-1||ua.indexOf("msie 7.0")!=-1){
return "ie";
}else{
if(ua.indexOf("mozilla")!=-1){
_d=ua.indexOf("gecko/");
if(_d==-1){
return "oldmoz";
}
_e=ua.indexOf(" ",_d);
if(_e==-1){
_e=ua.length;
}
_c=parseInt(ua.substring(_d+6,_e),10);
if(_c<20051107){
return "oldmoz";
}
return "moz";
}
}
}
}
return "unknown";
},isBlank:function(_f){
if(_f.match(/^\s*$/)){
return true;
}
return false;
},isValidURL:function(_10){
if(_10.match(/^http:\/\/.*$/)){
return true;
}
return false;
},isAlpha:function(_11){
if(_11.match(/^[a-zA-Z]$/)){
return true;
}
return false;
},getServerAddr:function(){
if(document.domain){
return ("http://"+document.domain);
}else{
return quillConfig.server.location;
}
},getServerPath:function(){
var _12=window.location.pathname.match(/.*\//g);
return ["http://",window.location.host,_12].join("");
},isValidAlpha:function(_13){
if(_13.match(/[a-zA-Z]+/)){
return true;
}
return false;
},getMeta:function(){
var d=document.getElementsByTagName("meta");
var ret={};
var i;
if(!d||!d.length){
logger.error("Could not read meta tags.");
}else{
for(i=0;i<d.length;i++){
if(d[i].name){
ret[d[i].name]=d[i].content;
}
}
}
return ret;
},makeURL:function(_17,req){
var _19="";
for(var i in req){
_19+=[i,"=",encodeURIComponent(req[i])].join("");
}
if(_19){
return [_17,"?",_19].join("");
}else{
return _17;
}
},setupLogging:function(){
try{
try{
if(console.log){
logger={log:console.log,debug:console.debug,info:console.info,warn:console.warn,error:console.error};
}
}
catch(e){
if(logDebug){
logger={log:log,debug:logDebug,info:logDebug,warn:logWarning,error:logError};
}
}
}
catch(e){
logger={log:function(){
},debug:function(){
},info:function(){
},warn:function(){
},error:function(){
}};
}
},setCharEncoding:function(_1b){
if(document.defaultCharset){
document.defaultCharset=_1b;
}
if(document.charset){
document.charset=_1b;
}
}};
getNodeText=function(){
var n=SPAN();
if(typeof (n.textContent)!=="undefined"){
return function(_1d){
return _1d.textContent;
};
}else{
if(typeof (n.innerText)!=="undefined"){
return function(_1e){
return _1e.innerText;
};
}else{
return function(_1f){
return _1f.text;
};
}
}
}();
setNodeText=function(){
var n=SPAN();
if(typeof (n.textContent)!=="undefined"){
return function(_21,_22){
_21.textContent=_22;
};
}else{
if(typeof (n.innerText)!=="undefined"){
return function(_23,_24){
_23.innerText=_24;
};
}else{
return function(_25,_26){
_25.text=_26;
};
}
}
}();
function getFontSize(){
if(quillConfig.fontSizes&&quillConfig.fontSizes.hasOwnProperty(QuillUtil.getLang())){
return quillConfig.fontSizes[QuillUtil.getLang()];
}else{
return ["12px","20px"];
}
}
function addStyleSheet(doc,url){
var _29=doc.createElement("LINK");
_29.rel="stylesheet";
_29.type="text/css";
_29.href=url;
var _2a=doc.getElementsByTagName("head")[0];
if(_2a){
_2a.appendChild(_29);
}else{
logger.error("addStyleSheet: document.head not found for",doc);
}
}
function enableLogPane(){
var _2b=getElement("logpane");
logger.info=function(){
var s="";
for(var i=0;i<arguments.length;i++){
s+=arguments[i]+" ";
}
_2b.appendChild(DIV(s));
if(_2b.scrollHeight>_2b.clientHeight){
_2b.scrollTop=_2b.scrollHeight-_2b.clientHeight;
}
};
}
function getCursorPosition(_2e){
var _2f;
if(typeof (_2e.selectionStart)!=="undefined"){
_2f=_2e.selectionEnd;
}else{
if(document.selection){
_2e.focus();
var sel=document.selection.createRange();
var _31=sel.duplicate();
_31.collapse(true);
var _32=_31.moveStart("character",-1000);
return -_32;
}
}
return _2f;
}
function setCursorPosition(_33,pos){
if(typeof (_33.selectionStart)!=="undefined"){
_33.selectionStart=pos;
_33.selectionEnd=pos;
}else{
if(document.selection){
_33.focus();
var _35=_33.createTextRange();
_35.collapse(true);
_35.moveStart("character",pos);
_35.moveEnd("character",pos);
_35.select();
}
}
}
iframePos=function(){
return elementPosition("indicOutput");
};

WordMapping=function(_1,_2,_3,_4,_5){
this.engWord=_1;
this.tWordList=_2;
this.preferred=_3;
this.itrans=_4;
this.optmap=_5;
};
var WordMap=function WordMap(_6){
this.localCache=_6;
this.wordMap={};
for(var i in quillConfig.supportedLanguages){
this.wordMap[i]={};
}
};
WordMap.prototype.responseFunc=function(_8,_9,o,_b,r){
var a=[];
var _e;
var i;
var itr=true;
var _11=false;
var _12;
var _13;
try{
_e=eval("("+r.responseText+")");
_12=CookieManager.getCookiePair(_8+"_prefs",_9);
_13=quillConfig.client.maxWordOptions;
if(_e.twords[0].options.length<_13){
_13=_e.twords[0].options.length;
}
for(i=0;i<_13;i++){
if(_e.twords[0].options[i]===_e.itrans){
itr=false;
}
a.push(_e.twords[0].options[i]);
}
var _14=_e.twords[0].optmap;
if(!itr){
_e.itrans=null;
}else{
a=a.splice(0,quillConfig.client.maxWordOptions-1);
if(_e.inString.slice(1).match(/[A-Z]+/)){
a.unshift(_e.itrans);
}else{
a.push(_e.itrans);
}
}
if(a.length<1){
logger.error("goofup in responseFunc, len(a) < 1");
return;
}
if(_12!=null){
for(i=0;i<a.length;i++){
if(a[i]===_12){
_11=true;
break;
}
}
}
if(!_11){
if(_9.match(/[\.\/~\^]/)){
o.wordMap[_8][_9]=new WordMapping(_9,[_e.itrans],_e.itrans,_e.itrans,_14);
}else{
o.wordMap[_8][_9]=new WordMapping(_9,a,a[0],_e.itrans,_14);
}
}else{
o.wordMap[_8][_9]=new WordMapping(_9,a,_12,_e.itrans,_14);
}
var _15=CookieManager.getCookiePair(_8+"_userMaps",_9);
if(_15){
_15=_15.split(",");
for(i=0;i<_15.length;i++){
if(_15[i]===_12){
o.wordMap[_8][_9].preferred=_12;
break;
}
}
o.wordMap[_8][_9].userMapping=_15;
}
_b(o.getMapping(_8,_9));
}
catch(e){
logger.error(e);
return;
}
};
WordMap.prototype.secondaryResp=function(_16,_17,o,_19,r){
try{
_19(o.getMapping(_16,_17));
}
catch(e){
logger.error(e);
return;
}
};
WordMap.prototype.getMapping=function(_1b,_1c){
if(_1b=="english"){
return (new WordMapping(_1c,[_1c],_1c));
}
var m=this.wordMap[_1b][_1c];
if(m&&m.engWord){
return m;
}else{
return null;
}
};
WordMap.prototype.getWordMapping=function(_1e,_1f,_20){
if(_1e=="english"){
_20(new WordMapping(_1f,[_1f],_1f));
return;
}
var _21=this.wordMap[_1e][_1f];
if(_21&&this.wordMap[_1e].hasOwnProperty(_1f)){
if(_21.def){
_21.def.addCallback(partial(this.secondaryResp,_1e,_1f,this,_20));
}else{
_20(this.getMapping(_1e,_1f));
}
return;
}
req={rand:QuillUtil.getRandom(),lang:_1e,inString:_1f};
var d=doSimpleXMLHttpRequest(QuillUtil.getServerAddr()+quillConfig.server.processWord,req);
d.addCallbacks(partial(this.responseFunc,_1e,_1f,this,_20),function(e){
logger.error("getWordMapping failed");
});
this.wordMap[_1e][_1f]={"def":d};
};
WordMap.prototype.setPreferredMapping=function(_24,_25,_26){
if(_24=="english"){
return;
}
var wm=this.wordMap[_24][_25];
wm.preferred=_26;
CookieManager.setCookiePair(_24+"_prefs",_25,_26);
};
WordMap.prototype.getAllOptions=function(_28,_29){
if(this.wordMap[_28][_29]){
return this.wordMap[_28][_29].tWordList;
}else{
return [];
}
};
WordMap.prototype.correctionRespFunc=function(_2a,_2b,_2c,r){
var val;
var _2f;
try{
val=eval("("+r.responseText+")");
_2f=this.wordMap[_2a][_2b].optmap;
if(_2f){
for(var i in val.optmap){
if(val.optmap.hasOwnProperty(i)){
if(!_2f[i]){
_2f[i]=val.optmap[i];
}
}
}
}
_2c(val.options,val.optmap);
}
catch(e){
logger.error(e);
}
};
WordMap.prototype.getCorrections=function(_31,_32,_33,pos,_35,loc){
req={rand:QuillUtil.getRandom(),lang:_31,currWord:_32.toString(),userInput:_33,pos:pos};
var d=doSimpleXMLHttpRequest(QuillUtil.getServerAddr()+"/quillpad_backend2/"+loc,req);
d.addCallbacks(method(this,partial(this.correctionRespFunc,_31,_33,_35)),function(e){
console.error("getCorrections failed");
});
};
WordMap.prototype.setUserMapping=function(_39,_3a,_3b){
var i;
var m=this.wordMap[_39][_3a];
for(i=0;i<m.tWordList.length;i++){
if(m.tWordList[i]===_3b){
return;
}
}
if(m.userMapping){
for(var i=0;i<m.userMapping.length;i++){
if(m.userMapping[i]===_3b){
return;
}
}
m.userMapping.unshift(_3b);
}else{
m.userMapping=[_3b];
}
CookieManager.setCookiePair(_39+"_userMaps",_3a,m.userMapping.toString());
};
WordMap.prototype.setUserMappingList=function(_3e,_3f,_40){
var m=this.wordMap[_3e][_3f];
m.userMapping=_40;
CookieManager.setCookiePair(_3e+"_userMaps",_3f,_40.toString());
};

var dFirstTime=true;
function isSpecial(c){
if(c=="."||c=="/"||c=="^"||c=="~"){
return true;
}
return false;
}
function splitSpecial(s){
var m=s.match(/((([a-zA-Z]+[\.\^~\/]*)*[a-zA-Z]+)|([^a-zA-Z])+)/g);
if(!m){
return [];
}
return m;
}
function diffStr(_4,_5){
DiffData=function(_6,_7,_8){
this.word=_6;
this.type=_7;
this.pos=_8;
};
function diff(o,n){
var ns={};
var os={};
var i;
try{
for(i=0;i<n.length;++i){
if(!ns.hasOwnProperty(n[i])){
ns[n[i]]={rows:[],o:null};
}
ns[n[i]].rows.push(i);
}
for(i=0;i<o.length;++i){
if(!os.hasOwnProperty(o[i])){
os[o[i]]={rows:[],n:null};
}
os[o[i]].rows.push(i);
}
for(i in ns){
if(ns[i].rows.length==1&&os.hasOwnProperty(i)&&os[i].rows.length==1){
n[ns[i].rows[0]]={text:n[ns[i].rows[0]],row:os[i].rows[0]};
o[os[i].rows[0]]={text:o[os[i].rows[0]],row:ns[i].rows[0]};
}
}
for(i=0;i<n.length-1;++i){
if(n[i].text&&!(n[i+1].text)&&(!(o[n[i].row+1])||!(o[n[i].row+1].text))&&n[i+1]==o[n[i].row+1]){
n[i+1]={text:n[i+1],row:n[i].row+1};
o[n[i].row+1]={text:o[n[i].row+1],row:i+1};
}
}
for(i=n.length-1;i>0;--i){
if(n[i].text&&!(n[i-1].text)&&(!(o[n[i].row-1])||!(o[n[i].row-1].text))&&n[i-1]==o[n[i].row-1]){
n[i-1]={text:n[i-1],row:n[i].row-1};
o[n[i].row-1]={text:o[n[i].row-1],row:i-1};
}
}
return {o:o,n:n};
}
catch(ex){
logger.error("diff(javascript) "+ex);
}
}
function diffArray(o,n){
try{
return diff(extend(["x"," "],splitSpecial(o)),extend(["x"," "],splitSpecial(n)));
}
catch(ex){
logger.error("diffArray(javascript) "+ex);
}
}
try{
return diffArray(_4,_5);
}
catch(e){
logger.error(e);
}
}

var TextEngine=function(_1){
var _2=getElement(_1);
this.doc=_2.contentDocument?_2.contentDocument:_2.contentWindow.document;
this.win=_2.contentWindow;
this.doc.designMode="on";
if(this.doc.body){
this.displayArea=this.doc.body;
}else{
this.doc.write("<head></head><body></body>");
this.doc.close();
this.displayArea=this.doc.body;
}
addStyleSheet(this.doc,QuillUtil.getServerPath()+"css/ifr.css");
this.setFontSizes();
ifrDoc=this.doc;
this.tooltip=new ToolTip("wordTip","wordTD","optTD","editorInput",this);
this.menu=new OptMenu();
connect(this.doc,"onkeypress",this,this.onKeyPress);
connect(this.doc,"onkeydown",this,this.onKeyDown);
connect(this.doc,"onkeyup",this,this.onKeyUp);
connect(this.doc,"onclick",this,this.showOptions);
if(QuillUtil.getBrowser()==="moz"){
connect(this.doc,"onblur",this,this.onBlur);
this.xlitText=this.xlitTextFF;
}else{
connect(this.win,"onblur",this,this.onBlur);
connect(this.displayArea,"onpaste",this,this.onPaste);
connect(this.displayArea,"oncut",this,this.onCut);
}
this.callback=method(this,this.callbackFunc);
};
TextEngine.prototype.setFontSizes=function(){
var _3=getFontSize();
this.doc.body.style.fontSize=_3[0];
this.doc.body.style.lineHeight=_3[1];
var _4=getElement("indicDic");
if(_4){
_4.style.fontSize=_3[0];
_4.style.lineHeight=_3[1];
}
var _5=getElement("cOptions");
if(_5){
_5.style.fontSize=_3[0];
}
var _6=getElement("langUnicode");
if(_6){
_6.style.fontSize=_3[0];
}
var ki=getElement("keyInput");
if(ki){
ki.style.lineHeight=_3[1];
}
};
TextEngine.prototype.onPaste=function(_8){
var _9=window.clipboardData.getData("Text");
var _a=this.getSelection();
var _b=this;
this.xlitText(_9,function(_c){
if(_a.atAnchorStart){
if(_a.anchorNode){
_b.setCursorBeforeWidget(_a.anchorNode);
}
_b.doc.selection.createRange().pasteHTML(_c);
}else{
if(_a.anchorNode){
_b.setCursorAfterWidget(_a.anchorNode);
}
_b.doc.selection.createRange().pasteHTML(_c);
}
});
_8.stop();
};
TextEngine.prototype.setText=function(_d){
var _e=this;
this.xlitText(_d,function(_f){
logger.info("got callback",_f);
_e.displayArea.innerHTML=_f;
});
};
TextEngine.prototype.xlitTextFF=function(_10,_11){
var _12=splitSpecial(_10);
var _13=_12.length;
function process(_14){
var s="<span>";
var i,_17;
for(i=0;i<_14.length;i++){
switch(_14.charAt(i)){
case " ":
_17=0;
while(i<_14.length&&_14.charAt(i)===" "){
_17+=1;
s+="&nbsp;";
i++;
}
if(_17>1){
s=[s.slice(0,-6)," "].join("");
}
i--;
break;
case "\n":
s=[s,"</span><br><span>"].join("");
break;
default:
s=[s,_14.charAt(i)].join("");
}
}
return s+"</span>";
}
function callbk(idx,m){
_13-=1;
_12[idx]=["<span word=\"",m.engWord,"\" lang=\"",QuillUtil.getLang(),"\">",m.preferred,"</span>"].join("");
if(_13<=0){
_11(_12.join("")+"<br _moz_editor_bogus_node=\"TRUE\" _moz_dirty=\"\"/>");
}
}
for(var i=0;i<_12.length;i++){
if(_12[i].match(/[a-zA-Z]/)){
wm.getWordMapping(QuillUtil.getLang(),_12[i],partial(callbk,i));
}else{
_12[i]=process(_12[i]);
_13-=1;
if(_13<=0){
_11(_12.join(""));
}
}
}
};
TextEngine.prototype.xlitText=function(_1b,_1c){
var _1d=splitSpecial(_1b);
var _1e=_1d.length;
function process(_1f){
var s="<span>";
var i,_22;
for(i=0;i<_1f.length;i++){
switch(_1f.charAt(i)){
case " ":
_22=0;
while(i<_1f.length&&_1f.charAt(i)===" "){
_22+=1;
s+="&nbsp;";
i++;
}
if(_22>1){
s=[s.slice(0,-6)," "].join("");
}
i--;
break;
case "\n":
s=[s,"</span><br><span>"].join("");
break;
default:
s=[s,_1f.charAt(i)].join("");
}
}
s+="</span>";
return s;
}
function callbk(idx,m){
_1e-=1;
_1d[idx]=["<span word=\"",m.engWord,"\" lang=\"",QuillUtil.getLang(),"\">",m.preferred,"</span>"].join("");
if(_1e<=0){
_1c(_1d.join(""));
}
}
for(var i=0;i<_1d.length;i++){
if(_1d[i].match(/[a-zA-Z]/)){
wm.getWordMapping(QuillUtil.getLang(),_1d[i],partial(callbk,i));
}else{
_1d[i]=process(_1d[i]);
_1e-=1;
if(_1e<=0){
_1c(_1d.join(""));
}
}
}
};
TextEngine.prototype.onCut=function(evt){
window.clipboardData.setData("Text",this.getTextSelection());
this.deleteSelection(this.getSelection(),evt);
};
TextEngine.prototype.onBlur=function(evt){
};
TextEngine.prototype.hideMenu=function(){
if(this.menu.enabled()){
this.menu.cleanup();
}
};
TextEngine.prototype.getSelection=function(){
var _28;
var _29;
var _2a;
var _2b;
var _2c=this;
var sel;
var ret={};
if(this.win.getSelection){
sel=this.win.getSelection();
if(sel.anchorNode.nodeName==="BODY"){
if(sel.anchorOffset===0){
ret.anchorNode=this.displayArea.childNodes[0];
}else{
ret.anchorNode=this.displayArea.childNodes[sel.anchorOffset-1];
}
ret.atAnchorEnd=true;
}else{
if(sel.anchorNode.parentNode&&sel.anchorNode.parentNode.nodeName!=="BODY"){
ret.anchorNode=sel.anchorNode.parentNode;
if(sel.anchorOffset===sel.anchorNode.nodeValue.length){
ret.atAnchorEnd=true;
}
}else{
ret.anchorNode=sel.anchorNode;
if(sel.anchorOffset===sel.anchorNode.nodeValue.length){
ret.atAnchorEnd=true;
}
}
if(sel.anchorOffset===0){
ret.atAnchorStart=true;
}
}
ret.anchorOffset=sel.anchorOffset;
ret.focusNode=sel.focusNode;
ret.focusOffset=sel.focusOffset;
ret.isCollapsed=sel.isCollapsed;
logger.info(ret);
return ret;
}else{
_28=this.doc.selection.createRange().duplicate();
_28.collapse(true);
_29=this.doc.selection.createRange().duplicate();
_29.collapse(false);
_28.pasteHTML("<span id=\"fuquaSpan1\"></span>");
_2a=this.doc.getElementById("fuquaSpan1");
ret.anchorNode=_2a.parentNode;
try{
if(_2a.previousSibling&&_2a.previousSibling.nodeName==="#text"){
ret.anchorOffset=_2a.previousSibling.nodeValue.length;
}
}
catch(e){
if(e.message==="Invalid Argument."){
ret.anchorOffset=0;
}
}
if(!_2a.nextSibling||_2a.parentNode.nodeName==="BODY"){
ret.atAnchorEnd=true;
}
if(!_2a.previousSibling){
ret.atAnchorStart=true;
}
if(_28.compareEndPoints("StartToStart",_29)===0){
ret.isCollapsed=true;
withDocument(this.doc,function(){
removeElement(_2a);
});
return ret;
}else{
ret.isCollapsed=false;
}
_29.pasteHTML("<span id=\"fuquaSpan2\"></span>");
_2b=this.doc.getElementById("fuquaSpan2");
ret.focusNode=_2b.parentNode;
if(_2b.previousSibling&&_2b.previousSibling.nodeName==="#text"){
ret.focusOffset=_2b.previousSibling.nodeValue.length;
}
if(!_2b.previousSibling||_2b.parentNode.nodeName==="BODY"){
ret.atFocusStart=true;
}
withDocument(this.doc,function(){
removeElement(_2a);
});
withDocument(this.doc,function(){
removeElement(_2b);
});
return ret;
}
};
TextEngine.prototype.addNewline=function(_2f){
var n=withDocument(this.doc,BR);
this.add(n,_2f);
return n;
};
TextEngine.prototype.setCursor=function(_31,_32){
var _33;
var sel;
if(this.win.getSelection){
_33=this.doc.createRange();
_33.selectNode(_32);
_33.collapse(_31);
sel=this.win.getSelection();
sel.removeAllRanges();
sel.addRange(_33);
}else{
if(this.doc.selection){
logger.info("where",_31,_32);
_33=this.displayArea.createTextRange();
_33.moveToElementText(_32);
_33.collapse(_31);
_33.select();
}
}
};
TextEngine.prototype.setCursorBeforeWidget=partial(TextEngine.prototype.setCursor,true);
TextEngine.prototype.setCursorAfterWidget=partial(TextEngine.prototype.setCursor,false);
TextEngine.prototype.getTextSelection=function(){
if(this.win.getSelection){
return this.win.getSelection().toString();
}else{
return this.doc.selection.createRange().text;
}
};
TextEngine.prototype.getWidgetAtCursor=function(){
var n;
var sel;
var _37;
var _38;
var _39;
if(this.win.getSelection){
sel=this.win.getSelection();
n=sel.anchorNode;
if(n.nodeName.toUpperCase()==="BODY"){
_38=sel.anchorOffset;
if(_38>0){
_38-=1;
}
n=this.displayArea.childNodes[_38];
}else{
if(n.parentNode&&n.parentNode.nodeName.toUpperCase()==="BODY"){
return n;
}
return n.parentNode;
}
return n;
}else{
_37=this.doc.selection.createRange().duplicate();
_37.collapse(true);
_37.pasteHTML("<span id=\"fuquaSpan\"></span>");
_39=this.doc.getElementById("fuquaSpan");
if(_39.parentNode&&_39.parentNode.nodeName!=="BODY"){
n=_39.parentNode;
}else{
n=_39.previousSibling;
}
withDocument(this.doc,function(){
removeElement(_39);
});
return n;
}
return null;
};
TextEngine.prototype.showOptions=function(evt){
var tgt=evt.target();
var _3c;
var mgr;
logger.info("got ShowOptions");
if(this.menu.enabled()){
this.menu.cleanup();
}
this.tooltip.hide();
if(!tgt||tgt===this.displayArea){
return;
}
_3c=this.getWidgetContent(tgt);
if(_3c[0]!=="word"){
return;
}
if(evt.modifier().ctrl||evt.modifier().alt){
evt.stop();
this.tooltip.editWord(tgt,_3c[1]);
}else{
this.menu.update(tgt,wm.getMapping(_3c[2],_3c[1]));
}
};
TextEngine.prototype.getWidgetContent=function(_3e){
var c=getNodeAttribute(_3e,"word");
if(c){
return ["word",c,getNodeAttribute(_3e,"lang")];
}
return ["",""];
};
TextEngine.prototype.addText=function(_40,_41,_42,_43){
var sp=withDocument(this.doc,function(){
var s=SPAN(_42);
setElementClass(s,"spanDispArea");
setNodeAttribute(s,"word",_41);
setNodeAttribute(s,"length",_41.length);
setNodeAttribute(s,"lang",_43);
return s;
});
var _46=quillConfig.fonts[_43];
if(_46){
sp.style.fontFamily=_46+",'Arial Unicode MS',Arial, Verdana, Helvetica,sans-serif";
}else{
sp.style.fontFamily="Arial, Verdana, Helvetica,sans-serif";
}
this.add(sp,_40);
return sp;
};
TextEngine.prototype.nuke=function(sel){
function removeRecurse(_48,_49){
if(!_48){
return;
}
if(_48==_49){
withDocument(this.doc,partial(removeElement,_48));
}else{
removeRecurse(_48.nextSibling,_49);
withDocument(this.doc,partial(removeElement,_48));
}
}
removeRecurse(sel.anchorNode,sel.focusNode);
};
TextEngine.prototype.replaceText=function(n,_4b,_4c){
if(n){
setNodeText(n,_4c);
}else{
logger.warn("Tried to replace non-existent widget at",n,_4b,_4c);
}
};
TextEngine.prototype.add=function(_4d,_4e){
this.displayArea.insertBefore(_4d,_4e);
};
TextEngine.prototype.addTextNode=function(_4f,_50){
var n=this.doc.createTextNode(_4f);
this.add(n,_50);
return n;
};
TextEngine.prototype.addSpan=function(_52,_53){
var t=withDocument(this.doc,partial(SPAN,_52));
if(_52===" "){
t.innerHTML="&nbsp;";
}
this.add(t,_53);
return t;
};
TextEngine.prototype.remove=function(_55){
if(!_55){
logger.warn("Tried to remove non-existent widget",_55);
}else{
removeElement(_55);
}
};
TextEngine.prototype.getText=function(){
var i;
var txt="";
var ret="";
for(i=0;i<this.displayArea.childNodes.length;i++){
txt=this.displayArea.childNodes[i].innerText;
if(txt){
ret+=txt;
}else{
txt=this.displayArea.childNodes[i].textContent;
if(txt){
ret+=txt;
}else{
if(this.displayArea.childNodes[i].nodeName==="BR"){
ret+="\n";
}else{
txt=getNodeText(this.displayArea.childNodes[i]);
txt=txt?txt:this.displayArea.childNodes[i].data;
ret+=txt;
}
}
}
}
return ret;
};
TextEngine.prototype.getHTML=function(){
return this.displayArea.innerHTML;
};
TextEngine.prototype.getEnglishText=function(){
var i;
var _5a;
var ret="";
for(i=0;i<this.displayArea.childNodes.length;i++){
_5a=getNodeAttribute(this.displayArea.childNodes[i],"word");
if(_5a){
ret+=_5a;
}else{
if(this.displayArea.childNodes[i].nodeName==="BR"){
ret+="\n";
}else{
ret+=getNodeText(this.displayArea.childNodes[i]);
}
}
}
return ret;
};
TextEngine.prototype.doneEditing=function(_5c,_5d,_5e){
this.win.focus();
if(_5d){
this.remove(_5c);
}else{
if(_5e){
this.setCursorBeforeWidget(_5c);
}else{
this.setCursorAfterWidget(_5c);
}
}
};
TextEngine.prototype.forceFocus=function(){
this.win.focus();
};
TextEngine.prototype.onKeyUp=function(evt){
var s=evt.key().string;
var _61;
var c;
var mgr;
var sel;
switch(s){
case "KEY_ARROW_UP":
case "KEY_ARROW_DOWN":
case "KEY_PAGE_UP":
case "KEY_PAGE_DOWN":
case "KEY_HOME":
case "KEY_END":
this.hideMenu();
_61=this.getWidgetAtCursor();
c=this.getWidgetContent(_61);
if(c[0]==="word"){
mgr=new OptMgr(wm.getMapping(c[2],c[1]),getNodeText(_61));
this.tooltip.update(_61,c[1]);
this.tooltip.updateOpts(mgr.chosenOption,mgr.numOptions);
}else{
this.tooltip.hide();
}
break;
}
};
TextEngine.prototype.onKeyDown=function(evt){
var s=evt.key().string;
var _67;
var n;
var c;
var _6a;
var _6b;
var mgr,opt;
var sel;
switch(s){
case "KEY_ENTER":
this.tooltip.hide();
if(QuillUtil.getBrowser()==="moz"){
return;
}
_67=this.getWidgetAtCursor();
if(_67){
n=this.addNewline(_67.nextSibling);
}else{
n=this.addNewline(null);
}
var t=withDocument(this.doc,partial(SPAN,""));
t.innerHTML="&nbsp;";
this.add(t,n.nextSibling);
this.setCursorAfterWidget(t);
t.parentNode.removeChild(t);
this.setCursorAfterWidget(n);
evt.stop();
break;
case "KEY_BACKSPACE":
sel=this.getSelection();
_67=sel.anchorNode;
if(!sel.isCollapsed){
this.deleteSelection(sel,evt);
return;
}
c=this.getWidgetContent(_67);
if(sel.atAnchorStart){
if(QuillUtil.getBrowser()==="moz"){
this.setCursorBeforeWidget(sel.anchorNode);
}else{
if(c[0]==="word"){
this.setCursorBeforeWidget(sel.anchorNode);
}
}
return;
}
_6a=c[1].slice(0,-1);
if(c[0]==="word"){
evt.stop();
if(_6a<=0){
_6b=_67.prevSibling;
this.remove(_67);
this.tooltip.hide();
if(_6b){
this.setCursorAfterWidget(_6b);
}
}else{
setNodeAttribute(_67,"word",_6a);
this.tooltip.update(_67,_6a);
wm.getWordMapping(c[2],_6a,partial(this.callback,_67));
this.setCursorAfterWidget(_67);
}
}
break;
case "KEY_ESCAPE":
evt.stop();
break;
case "KEY_ARROW_RIGHT":
sel=this.getSelection();
if(sel.atAnchorEnd&&sel.anchorNode.nextSibling){
c=this.getWidgetContent(sel.anchorNode.nextSibling);
if(c[0]==="word"){
this.tooltip.editWord(sel.anchorNode.nextSibling,c[1]);
this.tooltip.setCursorAtStart();
evt.stop();
}
}else{
if(sel.atAnchorStart){
c=this.getWidgetContent(sel.anchorNode);
if(c[0]==="word"){
this.tooltip.editWord(sel.anchorNode,c[1]);
this.tooltip.setCursorAtStart();
evt.stop();
}
}
}
break;
case "KEY_ARROW_LEFT":
sel=this.getSelection();
if(sel.atAnchorEnd){
c=this.getWidgetContent(sel.anchorNode);
if(c[0]==="word"){
this.tooltip.editWord(sel.anchorNode,c[1]);
evt.stop();
}
}else{
if(sel.atAnchorStart&&sel.anchorNode.previousSibling){
c=this.getWidgetContent(sel.anchorNode.previousSibling);
if(c[0]==="word"){
this.tooltip.editWord(sel.anchorNode.previousSibling,c[1]);
evt.stop();
}
}
}
break;
case "KEY_DELETE":
sel=this.getSelection();
if(sel.isCollapsed){
this.deleteChar(sel,evt);
}else{
this.deleteSelection(sel,evt);
}
break;
case "KEY_TAB":
this.hideMenu();
_67=this.getWidgetAtCursor();
c=this.getWidgetContent(_67);
if(c[0]==="word"){
evt.stop();
mgr=new OptMgr(wm.getMapping(c[2],c[1]));
if(evt.modifier().shift){
opt=mgr.choosePrevious();
}else{
opt=mgr.chooseNext();
}
this.tooltip.updateOpts(opt[0],mgr.numOptions);
setNodeText(_67,opt[1]);
this.setCursorAfterWidget(_67);
}
break;
case "KEY_L":
if(evt.modifier().ctrl&&evt.modifier().shift){
if(QuillUtil.getLang()==="english"){
QuillUtil.setLang(QuillUtil.getLangLegacy());
getElement("langind").checked=true;
}else{
QuillUtil.setLang("english");
getElement("langeng").checked=true;
}
evt.stop();
}
break;
}
};
TextEngine.prototype.deleteSelection=function(sel,evt){
if(sel.anchorNode.previousSibling){
this.setCursorAfterWidget(sel.anchorNode.previousSibling);
}
if(sel.focusNode.nextSibling){
this.setCursorBeforeWidget(sel.focusNode.nextSibling);
}
this.nuke(sel);
this.tooltip.hide();
evt.stop();
};
TextEngine.prototype.deleteChar=function(sel,evt){
var c;
if(sel.anchorNode.nodeName==="BODY"){
return;
}
logger.info(sel.anchorAtEnd);
var _75=this;
function modWord(_76,_77,_78,_79){
var _7a=_75;
if(_77.length<=1){
_75.remove(_76);
_75.tooltip.hide();
}else{
_77=_77.substring(1);
setNodeAttribute(_76,"word",_77);
logger.info("node is",_76);
_75.tooltip.update(_76,_77);
wm.getWordMapping(_78,_77,function(m){
_7a.callback(_76,m);
if(_79){
_7a.setCursorBeforeWidget(_76);
}
});
}
}
if(sel.atAnchorEnd){
c=this.getWidgetContent(sel.anchorNode.nextSibling);
logger.info("yo1",c);
if(c[0]==="word"){
evt.stop();
modWord(sel.anchorNode.nextSibling,c[1],c[2]);
}
}else{
if(sel.atAnchorStart){
c=this.getWidgetContent(sel.anchorNode);
if(c[0]==="word"){
evt.stop();
modWord(sel.anchorNode,c[1],c[2],true);
}
}else{
c=this.getWidgetContent(sel.anchorNode);
logger.info("yo2",c);
if(c[0]==="word"){
evt.stop();
}
}
}
};
TextEngine.prototype.callbackFunc=function(_7c,m){
var mgr=new OptMgr(m);
if(getNodeAttribute(_7c,"word")===m.engWord){
try{
this.replaceText(_7c,m.engWord,m.preferred);
}
catch(e){
logger.warn("Exception in callbackFunc",m,_7c,e);
}
}
if(this.tooltip.getWord()===m.engWord){
this.tooltip.updateOpts(mgr.chosenOption,mgr.numOptions);
}
};
TextEngine.prototype.onKeyPress=function(evt){
var s=evt.key().string;
var _81,_82;
var c;
var _84;
var t;
var mod=evt.modifier();
var sel=this.getSelection();
if(mod.alt||mod.ctrl){
return;
}
this.hideMenu();
if(s.match(/[a-zA-Z]/)){
_81=this.getWidgetAtCursor();
if(_81){
c=this.getWidgetContent(_81);
if(c[0]==="word"){
_84=c[1]+s;
setNodeAttribute(_81,"word",_84);
this.tooltip.update(_81,_84);
wm.getWordMapping(c[2],_84,partial(this.callback,_81));
this.setCursorAfterWidget(_81);
}else{
if(QuillUtil.getBrowser()==="moz"&&_81.nodeName==="BR"&&!_81.nextSibling){
_82=this.addText(_81,s," ",QuillUtil.getLang());
_82.innerHTML="&nbsp;";
}else{
_82=this.addText(_81.nextSibling,s," ",QuillUtil.getLang());
if(QuillUtil.getBrowser()==="moz"){
_82.innerHTML="&nbsp;";
}
}
this.setCursorAfterWidget(_82);
this.tooltip.update(_82,s);
wm.getWordMapping(QuillUtil.getLang(),s,partial(this.callback,_82));
}
}else{
_82=this.addText(null,s," ",QuillUtil.getLang());
this.setCursorAfterWidget(_82);
this.tooltip.update(_82,s);
wm.getWordMapping(QuillUtil.getLang(),s,partial(this.callback,_82));
}
evt.stop();
}else{
if(s.length!=0){
this.tooltip.hide();
_81=this.getWidgetAtCursor();
if(!_81){
t=this.addSpan(s,null);
evt.stop();
this.setCursorAfterWidget(t);
return;
}
c=this.getWidgetContent(_81);
if(c[0]==="word"){
if(sel.atAnchorStart){
if(sel.anchorNode.previousSibling){
c=this.getWidgetContent(sel.anchorNode.previousSibling);
if(c[0]==="word"){
t=this.addSpan(s,sel.anchorNode);
this.setCursorAfterWidget(t);
evt.stop();
}else{
if(QuillUtil.getBrowser()==="moz"){
this.setCursorAfterWidget(sel.anchorNode.previousSibling);
}else{
t=this.addSpan(s,sel.anchorNode);
this.setCursorAfterWidget(t);
evt.stop();
}
}
}else{
if(QuillUtil.getBrowser()==="moz"){
this.setCursorBeforeWidget(sel.anchorNode);
}else{
t=this.addSpan(s,sel.anchorNode);
this.setCursorAfterWidget(t);
evt.stop();
}
}
return;
}
if(QuillUtil.getBrowser()==="moz"){
this.setCursorAfterWidget(_81);
}else{
if(QuillUtil.getBrowser()==="ie"){
t=this.addSpan(s,_81.nextSibling);
this.setCursorAfterWidget(t);
evt.stop();
}
}
}
}
}
};
TextEngine.prototype.clearTextArea=function(){
var _88=this.displayArea.firstChild;
while(_88){
var _89=_88.nextSibling;
removeElement(_88);
_88=_89;
}
this.displayArea.focus();
};
TextEngine.prototype.setFocus=function(){
if(this.displayArea.lastChild){
this.setCursorAfterWidget(this.displayArea.lastChild);
}else{
this.displayArea.focus();
}
};
TextEngine.prototype.getSaveData=function(){
var i;
return serializeJSON(map(function(_8b){
var _8c=getNodeAttribute(_8b,"word");
if(_8c){
return ["word",_8c,getNodeText(_8b),getNodeAttribute(_8b,"lang")];
}else{
if(_8b.nodeName==="BR"){
return ["newline"];
}else{
if(_8b.nodeName==="#text"){
return (_8b.textContent?["text",_8b.textContent]:["text",_8b.data]);
}else{
if(_8b.nodeName==="SPAN"){
return ["text",getNodeText(_8b)];
}
}
}
}
},this.displayArea.childNodes));
};
TextEngine.prototype.load=function(_8d){
var arr=eval("("+_8d+")");
var i;
logger.info("load",arr);
function process(_90){
var s="";
var i,_93;
for(i=0;i<_90.length;i++){
switch(_90.charAt(i)){
case " ":
_93=0;
while(i<_90.length&&_90.charAt(i)===" "){
_93+=1;
s+="&nbsp;";
i++;
}
if(_93>1){
s=[s.slice(0,-6)," "].join("");
}
i--;
break;
default:
s=[s,_90.charAt(i)].join("");
}
}
return s;
}
var s;
for(i=0;i<arr.length;i++){
switch(arr[i][0]){
case "word":
wm.getWordMapping(arr[i][3],arr[i][1],function(){
});
this.addText(null,arr[i][1],arr[i][2],arr[i][3]);
break;
case "text":
s=withDocument(this.doc,SPAN);
setNodeText(s,arr[i][1]);
appendChildNodes(this.displayArea,s);
break;
case "newline":
this.addNewline(null);
break;
default:
logger.warn("Got unknown data in load",arr[i]);
}
}
};

function ToolTip(_1,_2,_3,_4,_5){
this.tdiv=getElement(_1);
this.textengine=_5;
if(QuillUtil.getBrowser()==="moz"){
this.tdiv.style.position="fixed";
this.updatePos=function(_6){
var _7=withDocument(this.textengine.doc,partial(elementPosition,_6));
var _8=iframePos();
_7.x+=_8.x;
_7.y+=_8.y+24-this.textengine.doc.body.scrollTop;
this.pos=_7;
_7.x-=window.pageXOffset;
_7.y-=window.pageYOffset;
setElementPosition(this.tdiv,_7);
};
window.onscroll=method(this,function(){
var _9=this.pos;
if(!_9){
return;
}
setElementPosition(this.tdiv,{x:_9.x-window.pageXOffset,y:_9.y-window.pageYOffset});
});
}else{
this.tdiv.style.position="absolute";
}
this.wordSpan=getElement(_2);
this.optSpan=getElement(_3);
this.editorInput=getElement(_4);
if(QuillUtil.getBrowser()==="ie"){
this.editorInput.onpaste=function(){
window.event.returnValue=false;
};
}else{
if(QuillUtil.getBrowser()==="moz"){
}
}
}
ToolTip.prototype={show:function(){
if(QuillUtil.getBrowser()==="moz"){
this.tdiv.style.display="table";
}else{
this.tdiv.style.display="block";
}
},hide:function(){
this.tdiv.style.display="none";
},updatePos:function(_a){
var _b=withDocument(this.textengine.doc,partial(elementPosition,_a));
var _c=iframePos();
_b.x+=_c.x;
_b.y+=_c.y+22-this.textengine.doc.body.scrollTop;
setElementPosition(this.tdiv,_b);
},update:function(_d,_e){
this.node=_d;
this.updatePos(_d);
this.setWord(_e);
setNodeText(this.optSpan,"...");
this.mgr=null;
this.show();
},changeColor:function(){
this.optSpan.style.color="#F66";
},restoreColor:function(){
this.optSpan.style.color="#66F";
},setWord:function(_f){
this.word=_f;
setNodeText(this.wordSpan,_f);
},updateOpts:function(_10,_11){
setNodeText(this.optSpan,""+_10+"/"+_11);
},getWord:function(){
return this.word;
},doneEditing:function(_12){
clearInterval(this.timer);
disconnect(this.sig1);
disconnect(this.sig2);
disconnect(this.sig3);
this.editorInput.style.display="none";
if(QuillUtil.getBrowser()==="moz"){
this.wordSpan.style.display="table-cell";
}else{
this.wordSpan.style.display="inline";
}
this.hide();
this.restoreColor();
if(this.mode==="correction"){
logger.info("Setting user mapping",this.editorInput.value,this.mgr.mapping.preferred);
wm.setUserMapping(getNodeAttribute(this.node,"lang"),this.editorInput.value,this.mgr.mapping.preferred);
}
if(this.editorInput.value===""){
this.textengine.doneEditing(this.node,true);
}else{
this.textengine.doneEditing(this.node,false,_12);
}
},editWord:function(_13,_14){
this.editorInput.style.display="inline";
this.wordSpan.style.display="none";
this.update(_13,_14);
this.oldText=_14;
this.mgr=new OptMgr(wm.getMapping(getNodeAttribute(_13,"lang"),_14));
this.mode="edit";
this.editorInput.focus();
this.editorInput.value=_14;
this.sig1=connect(this.editorInput,"onkeydown",this,this.onKeyDown);
this.sig2=connect(this.editorInput,"onblur",this,this.doneEditing);
this.sig3=connect(this.editorInput,"onkeypress",this,this.onKeyPress);
this.updateOpts(this.mgr.chosenOption,this.mgr.numOptions);
this.timer=setInterval(method(this,this.contentCheck),500);
},contentCheck:function(){
var _15=this.editorInput.value;
if(_15===this.oldText){
return;
}
this.mode="edit";
this.oldText=_15;
if(_15.length<=0){
setNodeText(this.node,"");
setNodeAttribute(this.node,"word","");
return;
}
setNodeAttribute(this.node,"word",_15);
wm.getWordMapping(getNodeAttribute(this.node,"lang"),_15,method(this,this.callbackFunc));
},callbackFunc:function(m){
this.mgr=new OptMgr(m);
this.textengine.replaceText(this.node,m.engWord,m.preferred);
this.updateOpts(this.mgr.chosenOption,this.mgr.numOptions);
this.restoreColor();
},onKeyPress:function(evt){
var s=evt.key().string;
if(!s.match(/[a-zA-Z\^\/~\.]/)&&s.length>0){
evt.stop();
}
},onKeyDown:function(evt){
var s=evt.key().string;
var opt;
logger.info(s);
switch(s){
case "KEY_BACKSPACE":
case "KEY_DELETE":
case "KEY_HOME":
case "KEY_END":
break;
case "KEY_ARROW_RIGHT":
if(getCursorPosition(this.editorInput)>=this.editorInput.value.length){
this.doneEditing();
}
break;
case "KEY_ARROW_LEFT":
if(getCursorPosition(this.editorInput)<=0){
this.doneEditing(true);
}
break;
case "KEY_Q":
if(evt.modifier().alt){
this.makeCorrection();
evt.stop();
}
break;
case "KEY_ESCAPE":
case "KEY_ENTER":
case "KEY_SPACEBAR":
evt.stop();
this.doneEditing();
break;
case "KEY_TAB":
evt.stop();
if(evt.modifier().shift){
this.chooseOption("previous");
}else{
this.chooseOption("next");
}
}
},chooseOption:function(_1c){
if(_1c==="prevous"){
opt=this.mgr.choosePrevious();
}else{
opt=this.mgr.chooseNext();
}
setNodeText(this.node,opt[1]);
this.updateOpts(opt[0],this.mgr.numOptions);
},setCursorAtStart:function(){
setCursorPosition(this.editorInput,0);
},makeCorrection:function(){
var pos=getCursorPosition(this.editorInput);
if(pos<=0){
return;
}
this.mode="correction";
var _1e=this;
var _1f=getNodeAttribute(this.node,"lang");
var opt=wm.getMapping(_1f,this.editorInput.value);
var _21=opt.optmap[this.editorInput.value];
function callback(_22,_23){
logger.info(_1f);
_1e.mgr=new OptMgr(new WordMapping(opt.engWord,_22,_22[0],"",_23),opt.preferred,_1f);
_1e.updateOpts(_1e.mgr.chosenOption,_1e.mgr.numOptions);
_1e.changeColor();
}
setNodeText(this.optSpan,"...");
if(_21){
wm.getCorrections(_1f,_21,opt.engWord,pos-1,callback,"getCorrections");
}else{
wm.getCorrections(_1f,opt.preferred,opt.engWord,pos-1,callback,"getCorrectionsStr");
}
}};

function SToolTip(_1,_2,_3,_4,_5,_6,_7){
this.tdiv=getElement(_1);
this.textengine=_7;
this.wordSpan=getElement(_2);
this.optSpan=getElement(_3);
this.editorInput=getElement(_4);
this.leftArr=getElement(_5);
this.rightArr=getElement(_6);
if(QuillUtil.getBrowser()==="ie"){
this.editorInput.onpaste=function(){
window.event.returnValue=false;
};
}else{
if(QuillUtil.getBrowser()==="moz"){
}
}
connect(this.leftArr,"onclick",this,this.prevOption);
connect(this.rightArr,"onclick",this,this.nextOption);
connect(this.wordSpan,"onclick",this,this.editIt);
}
SToolTip.prototype=clone(ToolTip.prototype);
SToolTip.prototype.updatePos=function(){
};
SToolTip.prototype.prevOption=function(_8){
if(this.mgr){
this.chooseOption("previous");
}
};
SToolTip.prototype.nextOption=function(_9){
if(this.mgr){
this.chooseOption("next");
}
};
SToolTip.prototype.updateOpts=function(_a,_b){
setNodeText(this.optSpan,""+_a+"/"+_b);
this.mgr=new OptMgr(wm.getMapping(getNodeAttribute(this.node,"lang"),getNodeAttribute(this.node,"word")),null,getNodeAttribute(this.node,"lang"));
};
SToolTip.prototype.updateOptsSpecial=function(){
this.mgr=new OptMgr(wm.getMapping(getNodeAttribute(this.node,"lang"),getNodeAttribute(this.node,"word")),null,getNodeAttribute(this.node,"lang"));
setNodeText(this.optSpan,""+this.mgr.chosenOption+"/"+this.mgr.numOptions);
};
SToolTip.prototype.restoreColor=function(){
this.optSpan.style.color="black";
};
SToolTip.prototype.editIt=function(_c){
if(!this.mgr){
return;
}
this.editWord(this.node,getNodeAttribute(this.node,"word"));
};

var STextEngine=function(_1,_2,_3,_4,_5,_6,_7){
var _8=getElement(_1);
this.bGo=getElement(_2);
this.queryURL=_4;
this.aClose=getElement(_3);
this.loadQueryInIFrame=_5;
this.key=_7;
this.doc=_8.contentDocument?_8.contentDocument:_8.contentWindow.document;
this.win=_8.contentWindow;
this.doc.designMode="on";
if(this.doc.body){
this.displayArea=this.doc.body;
}else{
this.doc.write("<head></head><body></body>");
this.doc.close();
this.displayArea=this.doc.body;
}
addStyleSheet(this.doc,QuillUtil.getServerPath()+"../css/ifrsearch.css");
this.tooltip=new SToolTip("swordTip","swordTD","soptTD","seditorInput","imgLeftArr","imgRightArr",this);
this.menu=new OptMenu();
connect(this.doc,"onkeypress",this,this.onKeyPress);
connect(this.doc,"onkeydown",this,this.onKeyDownSpecial);
connect(this.doc,"onkeyup",this,this.onKeyUp);
connect(this.doc,"onclick",this,this.showOptions);
connect(this.bGo,"onclick",this,this.buttonOnClick);
if(QuillUtil.getBrowser()==="moz"){
connect(this.doc,"onblur",this,this.onBlur);
this.xlitText=this.xlitTextFF;
}else{
connect(this.win,"onblur",this,this.onBlur);
connect(this.displayArea,"onpaste",this,this.onPaste);
connect(this.displayArea,"oncut",this,this.onCut);
}
this.callback=method(this,this.callbackFunc);
};
STextEngine.prototype=clone(TextEngine.prototype);
STextEngine.prototype.onPaste=function(_9){
_9.stop();
};
STextEngine.prototype.hideMenu=function(){
};
STextEngine.prototype.showOptions=function(_a){
var _b=_a.target();
var _c;
var _d;
logger.info("got ShowOptions");
this.tooltip.hide();
if(!_b||_b===this.displayArea){
return;
}
_c=this.getWidgetContent(_b);
if(_c[0]!=="word"){
return;
}
_a.stop();
this.tooltip.update(_b,_c[1]);
this.tooltip.updateOptsSpecial();
};
STextEngine.prototype.onKeyDownSpecial=function(_e){
var s=_e.key().string;
if(s==="KEY_ENTER"){
_e.stop();
this.buttonOnClick();
}else{
this.onKeyDown(_e);
}
};
STextEngine.prototype.buttonOnClick=function(evt){
if(this.queryURL){
var _11=this.queryURL.replace("@quill@",this.getText());
if(this.loadQueryInIFrame){
req={"key":this.key,"searchstr":this.getText()};
var d=doSimpleXMLHttpRequest(QuillUtil.getServerAddr()+quillConfig.server.archiveSearch,req);
frames["externalSite"].location.href=encodeURI(_11);
}else{
window.open(encodeURI(_11));
}
}
};
connect(window,"onload",function(){
QuillUtil.setupLogging();
QuillUtil.setCharEncoding("UTF-8");
var _13=false;
var _14=QuillUtil.getMeta();
var _15=_14["queryURL"];
var _16=_14["initialText"];
var key=_14["key"];
var _18=_14["lang"];
if(_14["loadQueryInIFrame"]){
_13=true;
}
if(quillConfig.server.domain){
document.domain=quillConfig.server.domain;
}
QuillUtil.setLang(_18);
wm=new WordMap();
t2=new STextEngine("searchKeyInput","bGo","aClose",_15,_13,_16,key);
connect(getElement("langeng"),"onclick",function(){
QuillUtil.setLang("english");
});
connect(getElement("langind"),"onclick",function(){
QuillUtil.setLang(_18);
});
});

var OptMgr=function(_1,_2,_3){
var i;
this.mapping=_1;
this.options=[];
var _5;
try{
_5=_2?_2:_1.preferred;
this.lang=_3?_3:QuillUtil.getLang();
extend(this.options,_1.tWordList);
extend(this.options,_1.userMapping);
}
catch(e){
_5=null;
this.lang=_3?_3:QuillUtil.getLang();
}
this.numOptions=this.options.length;
for(i=0;i<this.options.length;i++){
if(this.options[i]===_5){
this.chosenOption=i+1;
break;
}
}
};
OptMgr.prototype.chooseOptionWord=function(_6){
var i;
for(i=0;i<this.options.length;i++){
if(this.options[i]===_6){
this.chooseOption(i+1);
break;
}
}
};
OptMgr.prototype.chooseOption=function(_8){
if(_8<1||_8>this.numOptions){
return;
}
if(_8===this.chosenOption){
return [_8,this.options[_8-1]];
}
this.chosenOption=_8;
this.mapping.preferred=this.options[_8-1];
wm.setPreferredMapping(this.lang,this.mapping.engWord,this.options[_8-1]);
return [_8,this.options[_8-1]];
};
OptMgr.prototype.chooseNext=function(){
if(this.chosenOption>=this.numOptions){
return this.chooseOption(1);
}else{
return this.chooseOption(this.chosenOption+1);
}
};
OptMgr.prototype.choosePrevious=function(){
if(this.chosenOption<=1){
return this.chooseOption(this.numOptions);
}else{
return this.chooseOption(this.chosenOption-1);
}
};

var OptMenu=function(){
this.visible=false;
this.table=null;
this.fontSize=getFontSize()[0];
};
OptMenu.prototype={enabled:function(){
return this.visible;
},update:function(_1,_2){
this.node=_1;
this.mgr=new OptMgr(_2,null,getNodeAttribute(_1,"lang"));
var _3=this;
function makeTR(_4){
var td;
if(_4===_3.mgr.mapping.preferred){
td=TD({style:{background:"#C0DAFF"}},_4);
}else{
td=TD({style:{background:"#FFF"}},_4);
td.onmouseover=function(){
td.style.background="#C0DAFF";
};
td.onmouseout=function(){
td.style.background="#FFF";
};
}
setElementClass(td,"linkCursor");
return TR(null,td);
}
function makeTRUserMapped(_6){
var td;
if(_6===_3.mgr.mapping.preferred){
td=TD({style:{background:"#FFBFC2"}},_6);
}else{
td=TD({style:{background:"#FFFEF0"}},_6);
td.onmouseover=function(){
td.style.background="#FFBFC2";
};
td.onmouseout=function(){
td.style.background="#FFFEF0";
};
}
setElementClass(td,"linkCursor");
return TR(null,td);
}
if(!this.mgr.mapping){
return;
}
var _8=map(makeTR,this.mgr.mapping.tWordList);
if(this.mgr.mapping.userMapping){
extend(_8,map(makeTRUserMapped,this.mgr.mapping.userMapping));
}
this.table=TABLE({cellspacing:"1",cellpadding:"2","class":"optsTable"},TBODY(null,_8));
this.table.style.border="1px #C0DAFF solid";
this.table.style.background="white";
this.table.style.padding="1px";
this.table.style.fontSize=this.fontSize;
this.table.style.lineHeight=this.fontSize;
this.sig=connect(this.table,"onclick",this,this.onTblClick);
var _9=withDocument(ifrDoc,partial(elementPosition,_1));
var _a=iframePos();
_9.x+=_a.x;
_9.y+=_a.y+22-ifrDoc.body.scrollTop;
this.table.style.position="absolute";
setElementPosition(this.table,_9);
document.body.appendChild(this.table);
this.visible=true;
},onTblClick:function(_b){
var _c=_b.target();
if(_c!==this.table&&_c.nodeName==="TD"){
setNodeText(this.node,scrapeText(_c));
this.mgr.chooseOptionWord(getNodeText(_c));
this.cleanup();
}
_b.stop();
},cleanup:function(){
disconnect(this.sig);
removeElement(this.table);
this.table=null;
this.visible=false;
}};

