Discovered my credits code wont display in f***erFox mozilla.

how can I can make it cross browser?

<script>

/*
Credits screen script

*/

function opencredit(){
//set this to the file of the credit
var creditfile="http://herproom.5.forumer.com/index.php?act=Attach&type=post&id=7261"

if (document.all)
creditwindow=window.open(creditfile,"","width=445,height=250")
else
creditwindow=window.open(creditfile,"","width=445,height=250,scrollbars")
}
</script>

<center><b><a href="javascript:opencredit()">See credits for Reptile Planet!</a></b></center>

the credit page script

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Welcome To Reptile Planet">
<meta name="keywords"
content="Reptiles">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title> Credit Screen</title>
</head>

<body background="http://i14.photobucket.com/albums/a345/Instar/escher_background.gif">
<script language="JavaScript1.2">


var currentpos=0,alt=1,curpos1=0,curpos2=-1
function initialize(){
startit()
}
function scrollwindow(){
if (document.all)
temp=document.body.scrollTop
else
temp=window.pageYOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
currentpos=document.body.scrollTop+1
else
currentpos=window.pageYOffset+1
window.scroll(0,currentpos)
}
else{
currentpos=0
window.scroll(0,currentpos)
}
}
function startit(){
setInterval("scrollwindow()",2)
}
window.onload=initialize
</script>

<p>&nbsp;</p>
<p>&nbsp;</p>

<p align="center"><img src="http://i14.photobucket.com/albums/a345/Instar/rp2-1.jpg" width="371" height="35"
alt="logo (5979"><br>
<small><font face="Verdana">Credits Page</font></small></p>

<p align="left"><strong><font face="Verdana">~Main credits~</font></strong></p>

<p align="left"><font face="Verdana"><strong>Creator and main operator: </strong>Inny</font></p>

<p align="left"><font face="Verdana"><strong>Co-Admin: </strong>Gecko Girl</font></p>

<p align="left"><font face="Verdana"><strong>Design: </strong> Inny</font></p>

<p align="left"><font face="Verdana"><strong> Main Affiliate: </strong>TheHerpHouse.Com</font></p>

<p align="left"><font face="Verdana"><strong>Address: </strong>http://www.theherphouse.com/</font></p>

<p align="left"><font face="Verdana"><strong>Banner Creator: </strong> Scaleman</font></p>

<p align="left"><strong><font face="Verdana">~Additional credits~</font></strong></p>

<p align="left"><font face="Verdana"><strong>Ambassador: </strong>Dragon</font></p>

<p align="left"><font face="Verdana"><strong>Footer Banner Creator: </strong>Poppette</font></p>

<p><strong><font face="Verdana">~Misc credits~</font></strong></p>

<p><font face="Verdana"><strong>Web host provider: </strong>WWW.Forumer.com</font></p>
<p><center><image src="http://i14.photobucket.com/albums/a345/Instar/spashapic.jpg"></img></center></p>
<p>&nbsp;</p>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

Try putting semicolons at the end of each statement. Also, check whether you are using any IE specific extensions in your code. Hope this helps.

Steven.

What are IE specific Extentions?

I added semi colons to what I thought was each statement (see below) but it failed to scroll in Ie and no change in Firefox ??

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Welcome To Reptile Planet">
<meta name="keywords"
content="Reptiles">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title> Credit Screen</title>
</head>

<body background="http://i14.photobucket.com/albums/a345/Instar/escher_background.gif">
<script language="JavaScript1.2">


var currentpos=0,alt=1,curpos1=0,curpos2=-1;
function initialize();{
startit();
}
function scrollwindow();{
if (document.all)
temp=document.body.scrollTop;
else
temp=window.pageYOffset;
if (alt==0)
alt=1;
else
alt=0;
if (alt==0)
curpos1=temp;
else
curpos2=temp;
if (curpos1!=curpos2);{
if (document.all)
currentpos=document.body.scrollTop+1;
else
currentpos=window.pageYOffset+1
window.scroll(0,currentpos);
}
else{
currentpos=0
window.scroll(0,currentpos);
}
}
function startit();{
setInterval("scrollwindow()",2);
}
window.onload=initialize;
</script>

<p>&nbsp;</p>
<p>&nbsp;</p>

<p align="center"><img src="http://i14.photobucket.com/albums/a345/Instar/rp2-1.jpg" width="371" height="35"
alt="logo (5979"><br>
<small><font face="Verdana">Credits Page</font></small></p>

<p align="left"><strong><font face="Verdana">~Main credits~</font></strong></p>

<p align="left"><font face="Verdana"><strong>Creator and main operator: </strong>Inny</font></p>

<p align="left"><font face="Verdana"><strong>Co-Admin: </strong>Gecko Girl</font></p>

<p align="left"><font face="Verdana"><strong>Design: </strong> Inny</font></p>

<p align="left"><font face="Verdana"><strong> Main Affiliate: </strong>TheHerpHouse.Com</font></p>

<p align="left"><font face="Verdana"><strong>Address: </strong>http://www.theherphouse.com/</font></p>

<p align="left"><font face="Verdana"><strong>Banner Creator: </strong> Scaleman</font></p>

<p align="left"><strong><font face="Verdana">~Additional credits~</font></strong></p>

<p align="left"><font face="Verdana"><strong>Ambassador: </strong>Dragon</font></p>

<p align="left"><font face="Verdana"><strong>Footer Banner Creator: </strong>Poppette</font></p>

<p><strong><font face="Verdana">~Misc credits~</font></strong></p>

<p><font face="Verdana"><strong>Web host provider: </strong>WWW.Forumer.com</font></p>
<p><center><image src="http://i14.photobucket.com/albums/a345/Instar/spashapic.jpg"></img></center></p>
<p>&nbsp;</p>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

OK, I've had a longer look at your code this time. First, user defined functions (i.e. function name () { } ) should all be inside a <script> tag within the document <head>. I've re - formatted your code so the semicolons are in the right places as well:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Welcome To Reptile Planet">
<meta name="keywords"
content="Reptiles">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title> Credit Screen</title>
<script type="text/javascript">
function initialize() {
startit();
}
function scrollwindow() {
if (document.all)
temp=document.body.scrollTop;
else
temp=window.pageYOffset;
if (alt==0)
alt=1;
else
alt=0;
if (alt==0)
curpos1=temp;
else
curpos2=temp;
if (curpos1!=curpos2) {
if (document.all)
currentpos=document.body.scrollTop+1;
else
currentpos=window.pageYOffset+1;
window.scroll(0,currentpos);
}
else{
currentpos=0;
window.scroll(0,currentpos);
}
}
function startit() {
setInterval("scrollwindow()",2);
}
</script>
</head>

<body background="http://i14.photobucket.com/albums/a345/Instar/escher_background.gif">
<script type="text/javascript">
var currentpos=0;
alt=1;
curpos1=0;
curpos2=-1;

/*This script block will be run when the page has loaded anyway, so no need to use the window.onload handler*/
initialise();
</script>

<p>&nbsp;</p>
<p>&nbsp;</p>

<p align="center"><img src="http://i14.photobucket.com/albums/a345/Instar/rp2-1.jpg" width="371" height="35"
alt="logo (5979"><br>
<small><font face="Verdana">Credits Page</font></small></p>

<p align="left"><strong><font face="Verdana">~Main credits~</font></strong></p>

<p align="left"><font face="Verdana"><strong>Creator and main operator: </strong>Inny</font></p>

<p align="left"><font face="Verdana"><strong>Co-Admin: </strong>Gecko Girl</font></p>

<p align="left"><font face="Verdana"><strong>Design: </strong> Inny</font></p>

<p align="left"><font face="Verdana"><strong> Main Affiliate: </strong>TheHerpHouse.Com</font></p>

<p align="left"><font face="Verdana"><strong>Address: </strong>http://www.theherphouse.com/</font></p>

<p align="left"><font face="Verdana"><strong>Banner Creator: </strong> Scaleman</font></p>

<p align="left"><strong><font face="Verdana">~Additional credits~</font></strong></p>

<p align="left"><font face="Verdana"><strong>Ambassador: </strong>Dragon</font></p>

<p align="left"><font face="Verdana"><strong>Footer Banner Creator: </strong>Poppette</font></p>

<p><strong><font face="Verdana">~Misc credits~</font></strong></p>

<p><font face="Verdana"><strong>Web host provider: </strong>WWW.Forumer.com</font></p>
<p><center><image src="http://i14.photobucket.com/albums/a345/Instar/spashapic.jpg"></img></center></p>
<p>&nbsp;</p>
</body>
</html>

A few points to mention here:

1. The <!DOCTYPE> definition needs to be at the top, just before <html>.
2. The var keyword has the effect of making variables declared inside a function with it, local to that function. Using it in a <script> block in the document body has (I think) no effect.
3. It is OK to use

if (test == 0)
document.write("Some code run");

where only one line is to be run as a result of the condition. But, it can make your code look a bit unclear sometimes. Consider using

if (test == 0) {
document.write("Some code run");
}

more.
4. Most browsers are able to show you errors in javascript. In IE look in Tools > Internet options > general and turn on script debugging to get error messages like from a proper compiler. In other browsers look for an error console in the menus (Opera has one).
5. Use <script type="text/javascript"> rather than the language attribute you were using. It's the standard method and more likely to work on all browsers.

Hope this helps.

Steven.

I forgot to mention this is opened with a link

<center><b><a href="javascript:opencredit()">See credits for Reptile Planet!</a></b></center>

Your new version still opens but dosent scroll, and sadly still dosent render in Firefox, just displays raw code !?!

p.s unrelated..

/*This script block will be run when the page has loaded anyway, so no need to use the window.onload handler*/

can the above be done with this code? some way around using the event listener?

try{
(new Array()).indexOf(null);
}
catch(e){
Array.prototype.indexOf=function(v,i){
if(i==null){
i=0;
}
for(var j=i;j<this.length;j++){
if(this[j]===v){
return j;
}
}
return -1;
};
}
if(!window.Jacuba){
window.Jacuba=new Object();
}
if(!Jacuba.Checker){
Jacuba.Checker=new Object();
}
Jacuba.INSECURE_HOST="www.jacuba.com:80";
Jacuba.SECURE_HOST="www.jacuba.com:443";
Jacuba.IMAGE_PATH="http://www.jacuba.com:80//images/";
Jacuba.HOME_PAGE="http://www.jacuba.com";
Jacuba.DICTIONARY_AVAILABLE=true;
Jacuba.STYLESHEET_PATH="/styles/checker.css";
Jacuba.TEXT={jacuba_link:"Jacuba",spell_link:"Spelling",dict_link:"Dictionary",mywords_link:"My Words",help_link:"Help",ignore_option:"Ignore Word",unignore_option:"Unignore Word",dict_option:"Dictionary...",spell_option:"Spelling...",add_option:"Add to My Words",remove_option:"Remove from My Words",more_option:"...{0} more",newer_favelet_message:"A newer version of the favelet is available. Would you like to visit the jacuba website and upgrade now?",required_favelet_message:"Your favelet is no longer compatible with this service. Would you like to visit the jacuba website and upgrade now?"};
Jacuba.FAVELET_SUFFICIENCE="spell-1.0.0";
Jacuba.FAVELET_NEWEST="spell-1.0.0";
Jacuba.DATA_HOST=window.location.protocol+"//"+(window.location.protocol=="https:"?Jacuba.SECURE_HOST:Jacuba.INSECURE_HOST);
Jacuba.STYLESHEET_HREF=Jacuba.DATA_HOST+Jacuba.STYLESHEET_PATH;
Jacuba.detectBrowser=function(){
var _4=navigator.userAgent.toLowerCase();
var _5,substring;
var _6,OS,version;
var _7=function(_8){
_5=_4.indexOf(_8)+1;
substring=_8;
return _5;
};
if(_7("konqueror")){
_6="KQ";
OS="LX";
}else{
if(_7("safari")){
_6="SF";
}else{
if(_7("omniweb")){
_6="OW";
}else{
if(_7("opera")){
_6="OP";
}else{
if(_7("webtv")){
_6="TV";
}else{
if(_7("icab")){
_6="IC";
}else{
if(_7("msie")){
_6="IE";
}else{
if(!_7("compatible")){
_6="NS";
version=_4.charAt(8);
}else{
_6="";
}
}
}
}
}
}
}
}
if(!version){
version=_4.charAt(_5+substring.length);
}
if(!OS){
if(_7("linux")){
OS="LX";
}else{
if(_7("x11")){
OS="UX";
}else{
if(_7("mac")){
OS="MC";
}else{
if(_7("win")){
OS="WN";
}else{
OS="";
}
}
}
}
}
Jacuba.BROWSER_NAME=_6;
Jacuba.BROWSER_VERSION=version;
Jacuba.BROWSER_OS=OS;
};
Jacuba.detectBrowser();
Jacuba.FAVELET_PATTERN=/^([a-zA-Z0-9]+)-((\d+)(\.\d+)*)$/;
Jacuba.INTERVAL_PERIOD=100;
Jacuba.TIMEOUT_PERIOD=60000;
Jacuba.ID_PREFIX="jacuba";
Jacuba.MINIMUM_SERVER_DELAY=500;
Jacuba.MAXIMUM_WORDS_LENGTH=500;
Jacuba.isIE=Jacuba.BROWSER_NAME=="IE";
Jacuba.MYWORDS_POLL_PERIOD=500;
Jacuba.initialized=false;
Jacuba.textareaSelectors=new Array();
Jacuba.logElement;
Jacuba.uid=0;
Jacuba.iframe;
Jacuba.interval;
Jacuba.serverLast;
Jacuba.serverDelay=Jacuba.MINIMUM_SERVER_DELAY;
Jacuba.serverNext=0;
Jacuba.entries=new Object();
Jacuba.pendingArray=new Array();
Jacuba.pendingMap=new Object();
Jacuba.locale;
Jacuba.editors=new Object();
Jacuba.activeEditor=null;
Jacuba.mywords=new Object();
Jacuba.mywords.add=new Array();
Jacuba.mywords.remove=new Array();
Jacuba.mywords.user=null;
Jacuba.mywords.refresh=true;
Jacuba.myWordsWindow=null;
Jacuba.myWordsInterval=null;
Jacuba.elementOffset=function(el){
var x=0;
var y=0;
for(;el;el=el.offsetParent){
y+=el.offsetTop;
x+=el.offsetLeft;
}
return {x:x,y:y};
};
Jacuba.textToWords=function(_12){
var _13=new Array();
if(_12.length==0){
return _13;
}
var _14=/[a-zA-Z0-9]/;
var _15=0;
var _16;
var _17;
var _18=[[0,1,4,4,1],[2,2,3,3,2],[1,1,3,3,1],[1,1,4,4,1],];
for(var i=0;i<=_12.length;i++){
var c=_12.charAt(i);
if(!c){
_16=0;
}else{
if(c.match(_14)){
_16=1;
}else{
if(c=="'"&&i!=_12.length&&_12.charAt(i+1).match(_14)){
_16=2;
}else{
_16=3;
}
}
}
_15=_18[_16][_15];
switch(_15){
case 1:
break;
case 2:
_17=i;
break;
case 3:
break;
case 4:
_13[_13.length]=_12.substring(_17,i);
break;
default:
throw "unexpected state: "+_15;
}
}
return _13;
};
Jacuba.trimId=function(id){
var i=id.lastIndexOf("_");
if(i==-1){
return "";
}
return id.substring(0,i);
};
Jacuba.trimWord=function(_21){
if(_21==null){
return _21;
}
return _21.replace(/[^a-zA-Z0-9']/g,"");
};
Jacuba.openSpelling=function(id){
if(!id){
return;
}
var _22=Jacuba.editors[id];
if(!_22){
return;
}
_22.openSpelling();
};
Jacuba.openDictionary=function(_23){
var _24=470;
var _25=500;
var _26=Math.round((screen.height-_25)/2);
var _27=Math.round((screen.width-_24)/2);
var _28=_23?"?words="+escape(_23):"";
var win=window.open(Jacuba.DATA_HOST+"/service/dictionary/-/-/"+_28,Jacuba.ID_PREFIX+"_dict","resizable=yes,width="+_24+",height="+_25+",left="+_27+",top="+_26);
if(win){
win.focus();
}
};
Jacuba.openMyWords=function(){
var win=Jacuba.myWordsWindow;
if(!win){
var _30=340;
var _31=260;
var _32=Math.round((screen.height-_31)/2);
var _33=Math.round((screen.width-_30)/2);
win=window.open(Jacuba.DATA_HOST+"/service/mywordseditor/-/-/",Jacuba.ID_PREFIX+"_mywords","resizable=yes,width="+_30+",height="+_31+",left="+_33+",top="+_32);
if(win){
Jacuba.myWordsWindow=win;
Jacuba.myWordsInterval=window.setInterval("if (Jacuba.myWordsWindow.closed) { clearInterval(Jacuba.myWordsInterval); Jacuba.myWordsInterval = null; Jacuba.myWordsWindow = null; Jacuba.mywords.refresh = true }",Jacuba.MYWORDS_POLL_PERIOD);
}
}
if(win){
win.focus();
}
};
Jacuba.openHelp=function(){
var _34=450;
var _35=550;
var _36=Math.round((screen.height-_35)/2);
var _37=Math.round((screen.width-_34)/2);
window.open(Jacuba.DATA_HOST+"/help.html",Jacuba.ID_PREFIX+"_help","scrollbars=yes,resizable=yes,width="+_34+",height="+_35+",left="+_37+",top="+_36);
};
Jacuba.addMyWord=function(_38){
if(!_38){
throw ("no word supplied");
}
var _39=Jacuba.mywords.add;
var i=_39.indexOf(_38);
if(i!=-1){
return;
}
_39[_39.length]=_38;
};
Jacuba.removeMyWord=function(_40){
if(!_40){
throw ("no word supplied");
}
var _41=Jacuba.mywords.remove;
var i=_41.indexOf(_40);
if(i!=-1){
return;
}
_41[_41.length]=_40;
};
Jacuba.setMyWords=function(_42){
var _43=this.mywords.user;
this.mywords.user=_42;
this.mywords.refresh=false;
if(_43){
for(var i=0;i<_43.length;i++){
var _44=_43[i];
if(_42.indexOf(_44)==-1){
var _45=this.entries[_44];
if(_45&&_45.correctness=="user"){
_45.setCorrectness("incorrect");
}
}
}
for(var i=0;i<_42.length;i++){
var _44=_42[i];
if(_43.indexOf(_44)==-1){
var _45=this.entries[_44];
if(_45&&_45.correctness=="incorrect"){
_45.setCorrectness("user");
}
}
}
}
};
Jacuba.escapeHTML=function(str){
if(str==null){
return "null";
}
return str.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
};
Jacuba.unescapeHTML=function(str){
if(str==null){
return null;
}
str=str.toString().replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g,"\xa0").replace(/&amp;/g,"&");
return str;
};
Jacuba.textValue=function(_47,str){
if(str==null){
str="";
}
var _48=_47.nodeType;
switch(_48){
case 9:
case 1:
var _49=_47.nodeName;
if(_49!="HEAD"){
if(_49=="BR"){
str+="\r\n";
}
for(var c=_47.firstChild;c!=null;c=c.nextSibling){
str+=Jacuba.textValue(c);
}
if(_49=="P"&&_47.nextSibling){
str+="\r\n";
}
}
break;
case 4:
case 3:
str+=_47.nodeValue;
break;
case 8:
break;
default:
throw "Unexpected node type "+_48;
}
return str;
};
Jacuba.doWithoutRefresh=function(f){
try{
screen.updateInterval=1000;
f();
}
catch(e){
Jacuba.log(e);
}
finally{
screen.updateInterval=0;
}
};
Jacuba.HFN_LOAD=function(){
Jacuba.startup();
};
Jacuba.HFN_UNLOAD=function(){
Jacuba.shutdown();
};
Jacuba.now=function(){
return (new Date()).getTime();
};
Jacuba.nextUID=function(){
return this.uid++;
};
Jacuba.log=function(_51,_52){
if(!this.logElement){
return;
}
var div=document.createElement("div");
if(_52){
div.className=_52;
}
div.innerHTML=this.escapeHTML(_51);
var _54=document.createElement("span");
var now=new Date();
_54.innerHTML=now.getHours()+":"+now.getMinutes()+":"+now.getSeconds()+"("+now.getMilliseconds()+")";
div.insertBefore(_54,div.firstChild);
this.logElement.appendChild(div);
this.logElement.scrollTop=100000;
};
Jacuba.start=function(){
if(!this.iframe){
var _56=document.createElement("iframe");
_56.className=Jacuba.ID_PREFIX+"_comms";
_56.frameBorder="no";
document.body.appendChild(_56);
this.iframe=_56;
}
if(Jacuba.interval){
return;
}
this.interval=window.setInterval("Jacuba.poll()",this.INTERVAL_PERIOD);
};
Jacuba.stop=function(){
if(!Jacuba.interval){
return;
}
window.clearInterval(Jacuba.interval);
this.interval=null;
};
Jacuba.poll=function(){
if(this.serverLast){
if(this.timestamp+this.TIMEOUT_PERIOD<this.now()){
this.stop();
}
}else{
if(this.mywords.add.length||this.mywords.remove.length||this.mywords.refresh){
this.pullMyWords();
}else{
if(this.pendingArray.length>0&&this.serverNext<this.now()){
this.pullPending();
}
}
}
};
Jacuba.pullMyWords=function(){
var _57=this.now();
var _58,action;
if(this.mywords.add.length){
_58=this.mywords.add.join(" ");
action="add";
this.mywords.add=new Array();
}else{
if(this.mywords.remove.length){
_58=this.mywords.remove.join(" ");
action="remove";
this.mywords.remove=new Array();
}else{
_58="";
action="get";
}
}
this.pull(Jacuba.DATA_HOST+"/service/mywords/-/-/?action="+action+"&timestamp="+_57+"&words="+_58);
};
Jacuba.pullPending=function(){
var _59=this.now();
var _60=this.pendingArray;
var _61="";
for(var i=0;i<_60.length;i++){
if(escape(_61).length>=Jacuba.MAXIMUM_WORDS_LENGTH){
break;
}
var _62=_60[i].word;
_61+=i==0?_62:" "+_62;
}
this.pull(Jacuba.DATA_HOST+"/service/spelling/-/-/?timestamp="+_59+"&words="+_61);
};
Jacuba.pull=function(url){
this.serverLast=this.now();
var win=Jacuba.iframe.contentWindow;
win.location.replace("javascript: \"<html><head><script type='text/javascript' src=\\\""+url+"\\\"></scr"+"ipt></head><body onload='if (jacubaRun) jacubaRun()'><p>Loading...<p></body></html>\"");
};
Jacuba.pend=function(_64){
var _65=this.pendingMap[_64];
if(_65){
return _65;
}
_65=new Jacuba.PendingEntry(_64);
_64=_65.word;
this.pendingArray[this.pendingArray.length]=_65;
this.pendingMap[_64]=_65;
return _65;
};
Jacuba.getWordEntry=function(_66){
var _67=this.entries[_66];
if(_67){
return _67;
}else{
return this.pend(_66);
}
};
Jacuba.setWordEntry=function(_68){
var _69=_68.word;
var _70=this.pendingMap[_69];
if(_70){
delete this.pendingMap[_69];
var i=this.pendingArray.indexOf(_70);
this.pendingArray.splice(i,1);
}
this.entries[_69]=_68;
if(_70){
var _71=_70.functions;
for(var i=0;i<_71.length;i++){
_71[i](_68);
}
}
};
Jacuba.withWordEntry=function(_72,fn){
var _74=this.getWordEntry(_72);
if(_74.pending){
var _75=this.pendingMap[_72];
_75.addFunction(fn);
return false;
}else{
fn(_74);
return true;
}
};
Jacuba.wordEntryChanged=function(_76){
for(var id in this.editors){
var _77=this.editors[id];
_77.wordEntryChanged(_76);
}
};
Jacuba.editorForTextarea=function(_78){
if(!_78){
throw "no textarea";
}
var _79=this.editors;
for(var id in _79){
var _80=_79[id];
if(_80.textarea==_78){
return _80;
}
}
return null;
};
Jacuba.applyToSelections=function(){
var _81=this.textareaSelectors;
var _82=document.getElementsByTagName("TEXTAREA");
for(var i=0;i<_82.length;i++){
var _83=_82[i];
for(var j=0;j<_81.length;j++){
var _84=_81[j];
var _85;
var _86=_84.value;
switch(_84.axis){
case "element":
_85=_83.nodeName==_84.value;
break;
case "class":
_85=_83.className==_84.value;
break;
case "name":
_85=_83.name==_84.value;
break;
case "id":
_85=_83.id==_84.value;
break;
default:
_85=false;
}
if(_85&&!this.editorForTextarea(_83)){
this.attachToTextarea(_83);
}
}
}
};
Jacuba.open=function(){
};
Jacuba.read=function(_87){
if(_87!=1&&_87!=2){
return;
}
if(_87==1){
var _88=arguments[1];
var _89=new Jacuba.WordEntry(_88);
var _90=0;
var _91=true;
for(var i=2;i<arguments.length;i++){
var arg=arguments[i];
if(_91){
if(typeof (arg)!="number"){
throw "expected field number: "+arg;
}
_90=arg;
_91=false;
}else{
if(arg==null){
_91=true;
}else{
switch(_90){
case 1:
_89.setCorrectness(arg);
_91=true;
break;
case 2:
_89.addCorrection(arg);
break;
default:
}
}
}
}
if(!_91){
throw "unexpected end to arguments";
}
this.setWordEntry(_89);
}
if(_87==2){
var _93=arguments[1];
if(_93=="user"){
var _94=new Array();
if(arguments[2]==1){
for(var i=3;i<arguments.length;i++){
_94[i-3]=arguments[i];
}
}
this.setMyWords(_94);
}
}
};
Jacuba.wait=function(_95){
if(typeof (_95)!="number"){
throw "expected a number for delay: "+_95;
}
if(_95<Jacuba.MINIMUM_SERVER_DELAY){
_95=Jacuba.MINIMUM_SERVER_DELAY;
}
this.serverDelay=_95;
};
Jacuba.close=function(){
this.serverNext=this.serverLast+this.serverDelay;
this.serverLast=null;
};
Jacuba.applyTo=function(){
var _96=this.textareaSelectors;
for(var i=0;i<arguments.length;i++){
var _97=arguments[i];
if(_97==null){
throw "null selector at index "+i;
}
if(!_97.match(/^\s*(class|id|name|element)\s*\:\s*(\S+)\s*$/)){
throw "illegal selector: "+_97;
}
var _97={axis:RegExp.$1,value:RegExp.$2};
_96[_96.length]=_97;
}
if(this.initialized){
this.applyToSelections();
}
};
Jacuba.init=function(){
if(this.initialized){
return;
}
this.logElement=document.getElementById("jacuba_log");
Jacuba.Event.addListener(document,"click",Jacuba.Editor.HFN_CLICK);
Jacuba.Event.addListener(document,"contextmenu",Jacuba.Editor.HFN_CONTEXTMENU);
this.initialized=true;
this.applyToSelections();
};
Jacuba.destroy=function(){
if(!this.initialized){
return;
}
this.initialized=false;
this.stop();
var _98=this.iframe;
if(this.iframe){
this.iframe=null;
_98.parentNode.removeChild(_98);
}
Jacuba.Event.removeListener(document,"click",Jacuba.Editor.HFN_CLICK);
Jacuba.Event.removeListener(document,"contextmenu",Jacuba.Editor.HFN_CONTEXTMENU);
this.logElement=null;
};
Jacuba.attachToTextarea=function(_99){
if(!_99){
throw "no textarea";
}
if(!_99.nodeName){
throw "textarea not a node";
}
if(!_99.nodeName=="textarea"){
throw "not a textarea";
}
var _100=this.editorForTextarea(_99);
if(_100){
throw "textarea already attached";
}
_100=new Jacuba.Editor(_99);
this.start();
_100.attach();
this.editors[_100.id]=_100;
};
Jacuba.detachFromTextarea=function(_101){
if(!_101){
throw "no textarea";
}
var _102=this.editorForTextarea(_101);
if(!_102){
throw "textarea not attached";
}
_102.detach();
delete this.editors[_102.id];
};
Jacuba.setActiveEditor=function(_103){
if(this.activeEditor==_103){
return;
}
if(this.activeEditor){
this.activeEditor.bar.removeUse("active");
}
this.activeEditor=_103;
if(this.activeEditor){
this.activeEditor.bar.addUse("active");
}
};
Jacuba.activateEditor=function(_104){
if(!_104){
throw "no editor";
}
this.setActiveEditor(_104);
};
Jacuba.deactivateEditor=function(_105){
if(_105&&_105!=this.activeEditor){
return;
}
this.setActiveEditor(null);
};
Jacuba.hideAllPopups=function(){
var _106=Jacuba.editors;
var _107=false;
for(var id in _106){
var _108=_106[id];
if(_108.popup){
_107=_108.popup.hide()||_107;
}
}
return _107;
};
Jacuba.insertStyles=function(){
var _109=document.getElementsByTagName("LINK");
for(var i=0;i<_109.length;i++){
var link=_109[i];
if(link.rel=="Stylesheet"&&link.href==Jacuba.STYLESHEET_HREF){
return;
}
}
var head=document.getElementsByTagName("HEAD")[0];
var link=document.createElement("link");
link.rel="Stylesheet";
link.type="text/css";
link.href=Jacuba.STYLESHEET_HREF;
head.appendChild(link);
};
Jacuba.isCompatible=function(){
return (this.BROWSER_NAME=="NS"&&this.BROWSER_VERSION>=5)||(this.BROWSER_NAME=="IE"&&this.BROWSER_VERSION>=5&&this.BROWSER_OS=="WN");
};
Jacuba.startup=function(){
if(!this.isCompatible()){
return;
}
this.insertStyles();
this.init();
};
Jacuba.shutdown=function(){
if(!this.isCompatible()){
return;
}
Jacuba.Event.removeListener(window,"load",Jacuba.HFN_LOAD);
Jacuba.Event.removeListener(window,"unload",Jacuba.HFN_UNLOAD);
var tmp=new Object();
for(var id in Jacuba.editors){
tmp[id]=Jacuba.editors[id];
}
for(var id in tmp){
Jacuba.detachFromTextarea(tmp[id].textarea);
}
Jacuba.destroy();
};
Jacuba.Favelet=function(_113){
if(!_113){
throw "No favelet supplied";
}
var _114=_113.match(Jacuba.FAVELET_PATTERN);
if(_114==null){
throw "Illegal favelet: "+_113;
}
this.favelet=_113;
this.name=_114[1];
this.version=_114[2];
var _115=this.version.split(".");
this.major=parseInt(_115[0]);
if(_115.length>1){
this.minor=parseInt(_115[1]);
}
if(_115.length>2){
this.revision=parseInt(_115[2]);
}
return _113;
};
Jacuba.Favelet.prototype.fails=function(_116){
if(!_116){
return false;
}
_116=_116.split(";");
for(var i=0;i<_116.length;i++){
var _117=new Jacuba.Favelet(_116[i]);
if(_117==null){
continue;
}
if(this.compare(_117)&&!_117.compare(this)){
return true;
}
}
return false;
};
Jacuba.Favelet.prototype.isOld=function(){
return this.fails(Jacuba.FAVELET_NEWEST);
};
Jacuba.Favelet.prototype.isTooOld=function(){
return this.fails(Jacuba.FAVELET_SUFFICIENCE);
};
Jacuba.Favelet.prototype.compare=function(that){
if(that==null){
return false;
}
if(that.name!=this.name){
return false;
}
if(this.major>that.major){
return false;
}
if(this.major<that.major){
return true;
}
if(this.minor>that.minor){
return false;
}
if(this.minor<that.minor){
return true;
}
if(this.revision>that.revision){
return false;
}
if(this.revision<that.revision){
return true;
}
return true;
};
Jacuba.Favelet.prototype.toString=function(){
return this.favelet;
};
Jacuba.Favelet.lastInvoked=function(){
try{
return new Jacuba.Favelet(window["jacuba_favelet"]);
}
catch(e){
return null;
}
};
Jacuba.Event=function(e){
if(!e){
e=window.event;
}
this.originalEvent=e;
this.screenX=e.screenX;
this.screenY=e.screenY;
this.clientX=e.clientX;
this.clientY=e.clientY;
if(Jacuba.isIE){
this.target=e.srcElement;
this.relatedTarget=e.type=="mouseout"?e.toElement:e.fromElement;
}else{
this.target=e.target;
this.relatedTarget=e.relatedTarget;
}
this.type=e.type;
this.keyCode=e.keyCode;
this.ctrlKey=e.ctrlKey;
};
Jacuba.Event.prototype.stop=function(){
if(Jacuba.isIE){
this.originalEvent.cancelBubble=true;
}else{
this.originalEvent.preventDefault();
}
};
Jacuba.Event.addListener=function(el,type,fn){
if(Jacuba.isIE){
el.attachEvent("on"+type,fn);
}else{
el.addEventListener(type,fn,false);
}
};
Jacuba.Event.removeListener=function(el,type,fn){
if(Jacuba.isIE){
el.detachEvent("on"+type,fn);
}else{
el.removeEventListener(type,fn,false);
}
};
Jacuba.WordEntry=function(word){
if(!word){
throw "no word";
}
this.word=word;
this.corrections=new Array();
};
Jacuba.WordEntry.prototype.correctness="unknown";
Jacuba.WordEntry.prototype.pending=false;
Jacuba.WordEntry.prototype.setCorrectness=function(_122){
if(_122!="unknown"&&_122!="incorrect"&&_122!="correct"&&_122!="user"){
throw "unknown correctness: "+_122;
}
var _123=this.correctness!="unknown";
this.correctness=_122;
if(_123){
Jacuba.wordEntryChanged(this);
}
};
Jacuba.WordEntry.prototype.addCorrection=function(_124){
var _125=this.corrections;
var i;
for(i=0;i<_125.length;i++){
if(_125[i]==_124){
return false;
}
}
_125[i]=_124;
};
Jacuba.WordEntry.prototype.addCorrections=function(){
for(var i=0;i<arguments.length;i++){
this.addCorrection(arguments[i]);
}
};
Jacuba.WordEntry.prototype.toString=function(){
return "[WordEntry "+this.word+"]";
};
Jacuba.PendingEntry=function(word){
word=Jacuba.trimWord(word);
if(!word){
throw "no word or bad word: "+word;
}
this.word=word;
this.functions=new Array();
};
Jacuba.PendingEntry.prototype.pending=true;
Jacuba.PendingEntry.prototype.addFunction=function(fn){
this.functions[this.functions.length]=fn;
};
Jacuba.Editor=function(_126){
if(!_126){
throw "no textarea";
}
this.textarea=_126;
var id=_126.id;
if(!id){
id="anon";
}
this.id=Jacuba.ID_PREFIX+"_"+id+"_"+Jacuba.nextUID();
this.assignGlobalFns();
this.textareaStyle=new Object();
this.bar=new Jacuba.Editor.Bar(this);
this.popup=new Jacuba.Editor.Popup(this);
this.spans=new Object();
};
Jacuba.Editor.WRAP_PAUSE=500;
Jacuba.Editor.MAXIMUM_WRAP_DELAY=2000;
Jacuba.Editor.WATCH_INTERVAL=100;
Jacuba.Editor.HFN_FOCUS=function(_127){
var _128=(new Jacuba.Event(_127)).target;
var id=_128.nodeName=="#document"?_128.title:_128.id;
var _129=Jacuba.editors[id];
if(!_129){
return;
}
Jacuba.activateEditor(_129);
};
Jacuba.Editor.HFN_BLUR=function(_130){
var _131=(new Jacuba.Event(_130)).target;
if(!_131){
return;
}
var id=_131.nodeName=="#document"?_131.title:_131.id;
var _132=Jacuba.editors[id];
if(!_132){
return;
}
Jacuba.deactivateEditor(_132);
};
Jacuba.Editor.HFN_KEYDOWN=function(_133){
var ev=new Jacuba.Event(_133);
if(ev.keyCode==90&&ev.ctrlKey){
return false;
}
};
Jacuba.Editor.HFN_KEYPRESS=function(_135){
var ev=new Jacuba.Event(_135);
var doc=ev.target;
var id=doc.ownerDocument.title;
var _137=Jacuba.editors[id];
if(ev.keyCode>=33&&ev.keyCode<=40){
return;
}
var body=doc.nodeName=="BODY"?doc:doc.getElementsByTagName("BODY")[0];
Jacuba.Editor.stripNonSpans(body);
_137.identifySelection();
el=_137.selectionParentElement;
if(el&&el.nodeName=="SPAN"&&el.className=="incorrect"){
el.className="unknown";
}
_137.scheduleWrap();
};
Jacuba.Editor.HFN_CONTEXTMENU=function(_139){
var ev=new Jacuba.Event(_139);
Jacuba.hideAllPopups();
var _140=ev.target;
var id=_140.ownerDocument.title;
var _141=Jacuba.editors[id];
if(!_141){
return true;
}
if(_140.nodeName!="SPAN"){
ev.stop();
return false;
}
_141.populatePopup(_140);
if(_141.popup.count>0){
var win=_141.iframe.contentWindow;
if(Jacuba.isIE){
var _142=win.document.selection;
var _143=_142.createRange();
_143.moveToElementText(_140);
_143.select();
}else{
var _142=win.getSelection();
var _143=_142.getRangeAt(0);
_143.selectNode(_140);
}
var _144=_141.iframe;
var y=ev.clientY;
var x=ev.clientX;
var e=_144;
for(var e=_144;e;e=e.offsetParent){
y+=e.offsetTop;
x+=e.offsetLeft;
}
_141.popup.show(x,y);
}
ev.stop();
return false;
};
Jacuba.Editor.HFN_CLICK=function(_145){
Jacuba.hideAllPopups();
};
Jacuba.Editor.stripElements=function(e,name){
var _147=e.getElementsByTagName(name);
while(_147.length){
this.extricate(_147[0]);
}
};
Jacuba.Editor.stripNonSpans=function(e,name){
var _148=e.getElementsByTagName("*");
var i=0;
while(i<_148.length){
var node=_148[i];
var name=node.nodeName;
if(name=="SPAN"||name=="BR"||name=="P"){
i++;
}else{
this.extricate(node);
}
}
};
Jacuba.Editor.extricate=function(e){
if(!e){
throw "no element";
}
var _150=e.parentNode;
if(Jacuba.isIE&&e.nodeName=="A"){
_150.insertBefore(e.ownerDocument.createTextNode(e.innerText),e);
}else{
while(e.firstChild){
_150.insertBefore(e.firstChild,e);
}
}
_150.removeChild(e);
return e;
};
Jacuba.Editor.prototype.textarea;
Jacuba.Editor.prototype.id;
Jacuba.Editor.prototype.textareaStyle;
Jacuba.Editor.prototype.iframe=null;
Jacuba.Editor.prototype.bar=null;
Jacuba.Editor.prototype.popup=null;
Jacuba.Editor.prototype.contextSpan=null;
Jacuba.Editor.prototype.timeout=null;
Jacuba.Editor.prototype.firstScheduled=null;
Jacuba.Editor.prototype.bar=null;
Jacuba.Editor.prototype.spans=null;
Jacuba.Editor.prototype.selectionParentElement=null;
Jacuba.Editor.prototype.applied=null;
Jacuba.Editor.prototype.globalThis;
Jacuba.Editor.prototype.globalRevisitWord;
Jacuba.Editor.prototype.assignGlobalFns=function(){
var _151=new Function("return Jacuba.editors['"+this.id+"'];");
this.globalThis=_151;
this.globalRevisitWord=function(_152){
_151().revisitWord(_152);
};
};
Jacuba.Editor.prototype.htmlFromTextarea=function(){
var html=Jacuba.escapeHTML(this.textarea.value);
html=html.replace(/\r\n/g,"<BR>").replace(/\n/g,"<BR>");
return html;
};
Jacuba.Editor.prototype.attach=function(){
if(this.iframe){
throw "already attached";
}
var el=this.textarea;
if(el.offsetWidth==0){
throw "textarea not displayed";
}
var _154=el.offsetWidth-2;
var _155=el.offsetHeight-2;
var _156=document.createElement("iframe");
_156.id=this.id;
_156.className=Jacuba.ID_PREFIX+"_iframe";
_156.style.display="block";
_156.style.width=_154+"px";
_156.style.height=_155+"px";
_156.frameBorder="0";
_156.marginHeight="0";
_156.marginWidth="0";
this.textareaStyle.visibility=el.style.visibility;
this.textareaStyle.position=el.style.position;
el.style.visibility="hidden";
el.style.position="absolute";
el.parentNode.insertBefore(_156,el);
var doc=_156.contentWindow.document;
doc.open();
doc.write("<html>");
doc.write("<head>");
doc.write("<style>");
doc.write("body {color: black; background-color: white; font-family: Arial, sans-serif; font-size: 14px; padding: 2px }");
doc.write("p {padding: 0px; margin: 0px}");
doc.write("a {color: black; text-decoration: none}");
doc.write("img { display: none}");
if(false){
doc.write("span.unknown {color: gray}");
doc.write("span.correct {text-decoration: underline; color: green}");
doc.write("span.incorrect {text-decoration: underline; color: red}");
doc.write("span.user {color: #00ffff}");
doc.write("span.ignored {color: blue}");
}else{
doc.write("span.unknown {}");
doc.write("span.correct {}");
doc.write("span.incorrect { background: url("+Jacuba.IMAGE_PATH+"red.gif) repeat-x center bottom }");
doc.write("span.user {}");
doc.write("span.ignored {}");
}
doc.write("</style>");
doc.write("<title>"+this.id+"</title>");
doc.write("</head>");
doc.write("<body>");
doc.write(this.htmlFromTextarea());
doc.write("</body></html>");
doc.close();
doc.designMode="On";
var doc=_156.contentWindow.document;
var fel=Jacuba.isIE?_156:doc;
Jacuba.Event.addListener(fel,"focus",Jacuba.Editor.HFN_FOCUS);
Jacuba.Event.addListener(fel,"blur",Jacuba.Editor.HFN_BLUR);
Jacuba.Event.addListener(doc,"keydown",Jacuba.Editor.HFN_KEYDOWN);
Jacuba.Event.addListener(doc,"keypress",Jacuba.Editor.HFN_KEYPRESS);
Jacuba.Event.addListener(doc,"keyup",Jacuba.Editor.HFN_KEYPRESS);
Jacuba.Event.addListener(doc,"contextmenu",Jacuba.Editor.HFN_CONTEXTMENU);
Jacuba.Event.addListener(doc,"click",Jacuba.Editor.HFN_CLICK);
this.iframe=_156;
this.bar.attach();
this.popup.attach();
this.watchStart();
this.scheduleWrap();
};
Jacuba.Editor.prototype.detach=function(){
var _158=this.iframe;
if(!_158){
throw "not attached";
}
var doc=_158.contentWindow.document;
this.watchStop();
this.apply(doc.body);
if(this.spelling){
this.spelling.detach();
}
this.bar.detach();
this.popup.detach();
this.cancelWrap();
var fel=Jacuba.isIE?_158:doc;
Jacuba.Event.removeListener(fel,"focus",Jacuba.Editor.HFN_FOCUS);
Jacuba.Event.removeListener(fel,"blur",Jacuba.Editor.HFN_BLUR);
Jacuba.Event.removeListener(doc,"keydown",Jacuba.Editor.HFN_KEYDOWN);
Jacuba.Event.removeListener(doc,"keypress",Jacuba.Editor.HFN_KEYPRESS);
Jacuba.Event.removeListener(doc,"keyup",Jacuba.Editor.HFN_KEYPRESS);
Jacuba.Event.removeListener(doc,"contextmenu",Jacuba.Editor.HFN_CONTEXTMENU);
Jacuba.Event.removeListener(doc,"click",Jacuba.Editor.HFN_CLICK);
this.textarea.value=this.value();
_158.parentNode.removeChild(_158);
this.iframe=null;
for(var _159 in this.textareaStyle){
this.textarea.style[_159]=this.textareaStyle[_159];
}
this.textareaStyle=new Object();
};
Jacuba.Editor.prototype.value=function(){
if(this.iframe){
return Jacuba.textValue(this.iframe.contentWindow.document);
}else{
return this.textarea.value;
}
};
Jacuba.Editor.prototype.watchStart=function(){
if(!this.watchInterval){
this.watchInterval=window.setInterval("var editor = Jacuba.editors['"+this.id+"']; if (editor) editor.watchCheck()",Jacuba.Editor.WATCH_INTERVAL);
}
};
Jacuba.Editor.prototype.watchCheck=function(){
if(this.applied!=null){
var _160=this.textarea.value;
if(_160!=this.applied){
var html=this.htmlFromTextarea();
this.iframe.contentWindow.document.body.innerHTML=html;
this.applied=_160;
}
}
};
Jacuba.Editor.prototype.watchStop=function(){
if(this.watchInterval){
window.clearInterval(this.watchInterval);
this.watchInterval=null;
}
};
Jacuba.Editor.prototype.identifySelection=function(){
var el;
if(Jacuba.isIE){
var _161=this.iframe.contentWindow.document.selection.createRange();
el=_161.parentElement();
}else{
var _162=this.iframe.contentWindow.getSelection();
var _161=_162.getRangeAt(0);
el=_161.commonAncestorContainer;
if(el.nodeType==3){
el=el.parentNode;
}
}
this.selectionParentElement=el;
};
Jacuba.Editor.prototype.wordFromSpan=function(span){
var word=span.innerHTML;
if(this.caretText){
word=word.replace(this.caretText,"");
}
return word;
};
Jacuba.Editor.prototype.recordSpan=function(span){
var id=Jacuba.ID_PREFIX+"_"+Jacuba.nextUID();
span.id=id;
var word=this.wordFromSpan(span);
if(word==""){
return;
}
var _164=Jacuba.getWordEntry(word);
if(word!=_164.word){
word=_164.word;
}
span.word=word;
var _165=this.spans;
var _166=_165[word];
if(!_166){
_166=new Object();
_165[word]=_166;
}
_166[id]=span;
var clss;
if(_164.pending){
Jacuba.withWordEntry(word,this.globalRevisitWord);
clss="unknown";
}else{
clss=_164.correctness;
}
span.className=clss;
};
Jacuba.Editor.prototype.wrap=function(){
var win=this.iframe.contentWindow;
var doc=win.document;
var _168;
if(Jacuba.isIE){
var sel=doc.selection;
var _170=sel.createRange();
var tmp=_170.duplicate();
tmp.collapse();
_168=_170.isEqual(tmp);
}else{
var sel=win.getSelection();
var _170=sel.getRangeAt(0);
_168=_170.collapsed;
}
if(!_168){
return;
}
var _171=this;
Jacuba.doWithoutRefresh(function(){
_171.mark();
_171.flatten(doc);
_171.scan(doc.body);
_171.merge(doc);
_171.clean();
_171.restore();
_171.apply(doc.body);
});
};
Jacuba.Editor.prototype.mark=function(){
var _172="X"+Math.floor(Math.random()*100000)+"X";
_172=_172.replace(/0/g,"A");
_172=_172.replace(/1/g,"B");
_172=_172.replace(/2/g,"C");
_172=_172.replace(/3/g,"D");
_172=_172.replace(/4/g,"E");
_172=_172.replace(/5/g,"F");
_172=_172.replace(/6/g,"G");
_172=_172.replace(/7/g,"H");
_172=_172.replace(/8/g,"I");
_172=_172.replace(/9/g,"J");
var win=this.iframe.contentWindow;
if(Jacuba.isIE){
var _173=win.document.selection;
var _174=_173.createRange();
var doc=_174.parentElement().ownerDocument;
if(doc!=win.document){
return;
}
_174.pasteHTML(_172);
}else{
var _173=this.iframe.contentWindow.getSelection();
var _174=_173.getRangeAt(0);
_174.insertNode(win.document.createTextNode(_172));
win.document.normalize();
}
this.caretText=_172;
};
Jacuba.Editor.prototype.restore=function(){
var _175=this.caretText;
if(!_175){
return;
}
var win=this.iframe.contentWindow;
if(Jacuba.isIE){
var _176=win.document.selection;
var _177=_176.createRange();
_177.expand("textedit");
_177.findText(_175);
_177.execCommand("Delete");
_177.select();
}else{
if(!win.find(_175,false,true,false,false,false)){
if(!win.find(_175,false,false,false,false,false)){
throw "Unable to restore mark: "+_175;
}
}
var _176=this.iframe.contentWindow.getSelection();
var _177=_176.getRangeAt(0);
_177.deleteContents();
}
this.caretText=null;
};
Jacuba.Editor.prototype.flatten=function(doc){
var _178=this.spans;
var tmp=doc.getElementsByTagName("SPAN");
var _179=new Array(tmp.length);
for(var i=0;i<_179.length;i++){
_179[i]=tmp[i];
}
for(var i=0;i<_179.length;i++){
var span=_179[i];
var _180=false;
var word=span.word;
if(word){
if(span.innerHTML==word){
var _181=_178[word];
if(_181){
var id=span.id;
if(id){
if(_181[id]==span){
_180=true;
}
}
}
}
}
if(!_180){
var _182=span.parentNode;
while(span.hasChildNodes()){
_182.insertBefore(span.firstChild,span);
}
_182.removeChild(span);
}
}
};
Jacuba.Editor.prototype.merge=function(doc){
var _183=this.spans;
var _184=doc.getElementsByTagName("SPAN");
for(var i=0;i<_184.length;i++){
var span=_184[i];
var next=span.nextSibling;
if(next){
var name=next.nodeName;
if(name=="SPAN"){
while(next.hasChildNodes()){
span.appendChild(next.firstChild);
}
next.parentNode.removeChild(next);
i=0;
}else{
if(name=="#text"&&next.length==0){
next.parentNode.removeChild(next);
}
}
}
}
};
Jacuba.Editor.prototype.clean=function(){
var _186=this.spans;
for(var word in _186){
var _187=_186[word];
if(!_187){
continue;
}
for(var id in _187){
if(id.indexOf(Jacuba.ID_PREFIX)!=0){
continue;
}
var span=_187[id];
if(!span.parentNode){
delete _187[id];
}else{
var word=this.wordFromSpan(span);
if(span.word!=word){
delete _187[id];
if(!Jacuba.trimWord(word).length){
if(word){
span.parentNode.insertBefore(document.createTextNode(word),span);
}
span.parentNode.removeChild(span);
}else{
this.recordSpan(span);
}
}else{
var _188=Jacuba.getWordEntry(span.word);
var clss=span.className;
if(_188.pending){
if(clss!="unknown"){
clss.className="unknown";
}
}else{
if(clss!=_188.correctness){
span.className=_188.correctness;
}
}
}
}
}
}
};
Jacuba.Editor.prototype.scan=function(node){
var doc=this.iframe.contentWindow.document;
var name=node.nodeName;
var clss=node.className;
if(name=="SPAN"){
}else{
if(node.nodeType==3){
var text=node.nodeValue;
var _190=Jacuba.textToWords(text);
var obj=new Object();
var arr=new Array();
var _193=false;
for(var i=0;i<_190.length;i++){
var word=_190[i];
if(word.length==0){
continue;
}
if(obj[word]){
continue;
}
obj[word]=true;
arr[arr.length]=word;
if(!_193&&word.indexOf("'")!=-1){
_193=true;
}
}
arr.sort(function(a,b){
if(a=="span"){
return -1;
}
if(b=="span"){
return 1;
}
if(a.length<b.length){
return 1;
}
if(a.length>b.length){
return -1;
}
if(a<b){
return -1;
}
if(a>b){
return 11;
}
return 0;
});
var apos=_193?"XXXAPOSXXX":"";
var html=null;
for(var i=0;i<arr.length;i++){
var word=arr[i];
var _197=_193?word.replace(/'/g,apos):word;
var _198="\\b"+_197+"\\b";
if(html==null){
html=Jacuba.escapeHTML(text);
if(_193){
html=html.replace(/'/g,apos);
}
}
html=html.replace(new RegExp(_198,"g"),"<span>"+_197+"</span>");
}
if(html!=null){
if(_193){
html=html.replace(new RegExp(apos,"g"),"'");
}
var _199=node.parentNode;
var sre=/^[ ]+/;
var iws=sre.exec(html);
var itn;
if(iws){
itn=doc.createTextNode(iws);
html=html.substring(iws.length);
}
var fre=/[ ]+$/;
var fws=fre.exec(html);
var ftn;
if(fws){
ftn=doc.createTextNode(fws);
html=html.substring(0,html.length-fws.length);
}
if(itn){
_199.insertBefore(itn,node);
}
var tmp=doc.createElement("div");
tmp.innerHTML=html;
var _206;
while(_206=tmp.firstChild){
if(_206.nodeName=="SPAN"){
this.recordSpan(_206);
}
_199.insertBefore(_206,node);
}
if(ftn){
_199.insertBefore(ftn,node);
}
_199.removeChild(node);
}
}else{
var _206=node.firstChild;
while(_206){
var next=_206.nextSibling;
this.scan(_206);
_206=next;
}
}
}
};
Jacuba.Editor.prototype.apply=function(body){
var text=body.innerHTML;
text=text.replace(/\r/g,"").replace(/\n/g,"");
var para=text.indexOf("<P")==0||text.indexOf("<p")==0;
text=text.replace(/\<BR\>/gi,"\r\n");
text=text.replace(/\<P\>/gi,"\r\n");
text=text.replace(/\<[^>]*\>/g,"");
if(para){
text=text.substring(2);
}
text=Jacuba.unescapeHTML(text);
var _208=this.cursorText;
this.textarea.value=_208?text.replace(_208,""):text;
this.applied=this.textarea.value;
};
Jacuba.Editor.prototype.revisitWord=function(_209){
var doc=this.iframe.contentWindow.document;
var word=_209.word;
var _210=this.spans[word];
if(!_210){
return;
}
for(var id in _210){
var span=_210[id];
span.className=_209.correctness;
}
};
Jacuba.Editor.prototype.cancelWrap=function(){
if(!this.timeout){
return;
}
clearTimeout(this.timeout);
this.timeout=null;
};
Jacuba.Editor.prototype.scheduleWrap=function(){
var now=Jacuba.now();
if(this.timeout){
if(now<this.firstScheduled+Jacuba.Editor.MAXIMUM_WRAP_DELAY-Jacuba.Editor.WRAP_PAUSE){
this.cancelWrap();
}
}else{
this.firstScheduled=now;
}
if(!this.timeout){
this.timeout=setTimeout("var editor = Jacuba.editors['"+this.id+"'].performWrap()",Jacuba.Editor.WRAP_PAUSE);
}
};
Jacuba.Editor.prototype.performWrap=function(){
this.timeout=null;
this.firstScheduled=null;
this.wrap();
};
Jacuba.Editor.prototype.wordEntryChanged=function(_211){
this.updateWordSpans(_211.word);
};
Jacuba.Editor.prototype.updateWordSpans=function(word,_212){
if(!_212){
var _213=Jacuba.getWordEntry(word);
if(_213.pending){
return;
}
_212=_213.correctness;
}
var _214=this.spans[word];
if(!_214){
return;
}
for(var id in _214){
_214[id].className=_212;
}
};
Jacuba.Editor.prototype.populatePopup=function(span){
var _215=this.popup;
_215.clearOptions();
this.contextSpan=span;
var text=Jacuba.TEXT;
if(span.className=="ignored"){
_215.addOption(text.unignore_option,"unignore");
return;
}
var word=span.word;
var _216=Jacuba.getWordEntry(word);
if(_216.pending){
return false;
}
if(_216.correctness=="unknown"){
return;
}
if(_216.correctness=="correct"){
if(Jacuba.DICTIONARY_AVAILABLE){
_215.addOption(text.dict_option,"dict");
}
return;
}
if(_216.correctness=="user"){
_215.addOption(text.remove_option,"remove");
return;
}
if(_216.correctness=="incorrect"){
var cs=_216.corrections;
var _218=Math.min(8,cs.length);
for(var i=0;i<_218;i++){
_215.addCorrection(cs[i],i);
}
if(_218<cs.length){
_215.addOption(text.more_option.replace("{0}",cs.length-_218),"spell");
}
_215.addSeparator();
_215.addOption(text.add_option,"add");
_215.addOption(text.ignore_option,"ignore");
_215.addOption(text.spell_option,"spell");
return;
}
};
Jacuba.Editor.prototype.contextAction=function(_219){
var span=this.contextSpan;
if(!span){
return;
}
switch(_219){
case "ignore":
span.className="ignored";
break;
case "unignore":
span.className="incorrect";
break;
case "add":
this.collapseSelection();
var word=span.word;
this.updateWordSpans(word,"user");
Jacuba.addMyWord(word);
break;
case "remove":
this.collapseSelection();
var word=span.word;
this.updateWordSpans(word,"incorrect");
Jacuba.removeMyWord(word);
break;
case "spell":
this.openSpelling(span);
break;
case "dict":
Jacuba.openDictionary(span.word);
break;
default:
var word=span.word;
var i=parseInt(_219);
if(isNaN(i)){
throw "Unknown context action: "+_219;
}
var _220=Jacuba.getWordEntry(word);
var _221=_220.corrections[i];
span.innerHTML=_221;
this.collapseSelection();
this.wrap();
}
};
Jacuba.Editor.prototype.openSpelling=function(span){
var _222=this.spelling;
if(!_222){
_222=new Jacuba.Editor.Spelling(this);
this.spelling=_222;
}
_222.attach();
if(span){
_222.setTraverse(false);
_222.setSpan(span);
}else{
_222.setTraverse(true);
_222.moveToIncorrect();
}
};
Jacuba.Editor.prototype.getSpansForWord=function(word){
var _223=new Array();
var _224=this.spans[word];
if(_224){
for(var id in _224){
_223[_223.length]=_224[id];
}
}
return _223;
};
Jacuba.Editor.prototype.collapseSelection=function(){
var win=this.iframe.contentWindow;
if(Jacuba.isIE){
win.document.selection.empty();
}else{
var _225=win.getSelection().getRangeAt(0);
_225.collapse(false);
}
};
Jacuba.Editor.prototype.toString=function(){
return "[Jacuba.Editor id=\""+this.id+"\"]";
};
Jacuba.Editor.Bar=function(_226){
if(!_226){
throw "no editor";
}
this.editor=_226;
this.id=_226.id+Jacuba.Editor.Bar.ID_SUFFIX;
this.uses=new Array();
};
Jacuba.Editor.Bar.ID_SUFFIX="_bar";
Jacuba.Editor.Bar.HIDE_DELAY=1000;
Jacuba.Editor.Bar.SLIDE_DELAY=400;
Jacuba.Editor.Bar.SLIDE_PERIOD=100;
Jacuba.Editor.Bar.HEIGHT=22;
Jacuba.Editor.Bar.isBarId=function(id){
if(!id){
return false;
}
var p=Jacuba.ID_PREFIX;
if(id.indexOf(p)!=0){
return false;
}
var s=Jacuba.Editor.Bar.ID_SUFFIX;
var i=id.lastIndexOf(s);
if(i==-1||i+s.length!=id.length){
return false;
}
return true;
};
Jacuba.Editor.Bar.barAncestor=function(el){
while(el&&el.nodeName!="BODY"){
var id=el.id;
if(Jacuba.Editor.Bar.isBarId(id)){
return el;
}
el=el.parentNode;
}
return null;
};
Jacuba.Editor.Bar.HFN_OVER=function(_229){
var ev=new Jacuba.Event(_229);
var to=Jacuba.Editor.Bar.barAncestor(ev.target);
var from=Jacuba.Editor.Bar.barAncestor(ev.relatedTarget);
if(to&&from){
return;
}
if(from){
return;
}
var id=Jacuba.trimId(to.id);
var _232=Jacuba.editors[id];
if(!_232){
return;
}
_232.bar.addUse("mouse");
};
Jacuba.Editor.Bar.HFN_OUT=function(_233){
var ev=new Jacuba.Event(_233);
var to=Jacuba.Editor.Bar.barAncestor(ev.target);
var from=Jacuba.Editor.Bar.barAncestor(ev.relatedTarget);
if(to&&from){
return;
}
if(from){
return;
}
var id=Jacuba.trimId(to.id);
var _234=Jacuba.editors[id];
if(!_234){
return;
}
_234.bar.removeUse("mouse");
};
Jacuba.Editor.Bar.staticHide=function(id){
id=Jacuba.trimId(id);
var _235=Jacuba.editors[id];
if(!_235){
return;
}
var bar=_235.bar;
bar.hideTimeout=null;
bar.hideNow();
};
Jacuba.Editor.Bar.staticSlide=function(id){
id=Jacuba.trimId(id);
var _237=Jacuba.editors[id];
if(!_237){
return;
}
var bar=_237.bar;
var _238=0;
var _239=Math.round(Jacuba.Editor.Bar.HEIGHT/Jacuba.Editor.Bar.SLIDE_DELAY*Jacuba.Editor.Bar.SLIDE_PERIOD);
switch(bar.status){
case "closing":
_238=-_239;
break;
case "opening":
_238=_239;
break;
default:
return;
}
var top=bar.div.offsetTop;
top+=_238;
var _241=0;
var _242=-Jacuba.Editor.Bar.HEIGHT-2;
if(top>=_241){
top=_241;
bar.setStatus("open");
}else{
if(top<=_242){
top=_242;
bar.setStatus("closed");
}
}
bar.div.style.top=top+"px";
var _243=bar.edges;
var _244=_243.previousSibling;
_243.style.left=(Jacuba.elementOffset(_244).x-Jacuba.elementOffset(_243.offsetParent).x)+"px";
};
Jacuba.Editor.Bar.prototype.editor=null;
Jacuba.Editor.Bar.prototype.id=null;
Jacuba.Editor.Bar.prototype.edges=null;
Jacuba.Editor.Bar.prototype.div=null;
Jacuba.Editor.Bar.prototype.uses=null;
Jacuba.Editor.Bar.prototype.hideTimeout=null;
Jacuba.Editor.Bar.prototype.status="closed";
Jacuba.Editor.Bar.prototype.attach=function(){
var _245=this.editor.iframe.offsetWidth;
var _246=Jacuba.Editor.Bar.HEIGHT;
if(Jacuba.isIE){
adj=document.compatMode=="CSS1Compat"?2:0;
}else{
adj=2;
}
_246-=adj;
_245-=adj;
var _247=document.createElement("div");
_247.className=Jacuba.ID_PREFIX+"_edges";
_247.style.width=(_245+2)+"px";
_247.style.height=(_246+2)+"px";
if(!Jacuba.isIE){
_247.style.display="none";
}
var div=document.createElement("div");
div.id=this.id;
div.className=Jacuba.ID_PREFIX+"_bar";
div.style.width=_245+"px";
div.style.height=_246+"px";
div.style.top=(-_246-adj)+"px";
_247.appendChild(div);
var _248=this.editor.iframe;
_248.parentNode.insertBefore(_247,_248.nextSibling);
Jacuba.Event.addListener(div,"mouseover",Jacuba.Editor.Bar.HFN_OVER);
Jacuba.Event.addListener(div,"mouseout",Jacuba.Editor.Bar.HFN_OUT);
this.edges=_247;
this.div=div;
var text=Jacuba.TEXT;
var _249="<table cellpadding='0' cellspacing='0' border='0' style='padding: 0px; margin: 0px; width: 100%'><tbody><tr>"+"<td style='width: 0%; font-size: 12px; padding: 1px 1px 1px 1px'><a href='"+Jacuba.HOME_PAGE+"' target='jacuba'><img src='"+Jacuba.IMAGE_PATH+"logo47x18.gif' border='0' width='47' height='18' alt='"+text.jacuba_link+"'></a></td>"+"<td style='width: 100%; text-align: right; font-size: 12px; vertical-align: top; padding: 2px 5px 2px 5px'><nobr>"+"<a href='javascript: Jacuba.openSpelling(\""+this.editor.id+"\")'>"+text.spell_link+"</a> | "+(Jacuba.DICTIONARY_AVAILABLE?"<a blue' href='javascript: Jacuba.openDictionary()'>"+text.dict_link+"</a> | ":"")+"<a href='javascript: Jacuba.openMyWords()'>"+text.mywords_link+"</a> | "+"<a href='javascript: Jacuba.openHelp()'>"+text.help_link+"</a></nobr></td>"+"</tr></tbody></table>";
this.setContent(_249);
};
Jacuba.Editor.Bar.prototype.detach=function(){
var div=this.div;
var _250=this.edges;
this.div=null;
this.edges=null;
Jacuba.Event.removeListener(div,"mouseover",Jacuba.Editor.Bar.HFN_OVER);
Jacuba.Event.removeListener(div,"mouseout",Jacuba.Editor.Bar.HFN_OUT);
_250.parentNode.removeChild(_250);
};
Jacuba.Editor.Bar.prototype.addUse=function(use){
if(!use){
throw "no use specified";
}
var uses=this.uses;
if(uses.indexOf(use)==-1){
uses[uses.length]=use;
if(uses.length==1){
this.show();
}
}
};
Jacuba.Editor.Bar.prototype.removeUse=function(use){
if(!use){
throw "no use specified";
}
var uses=this.uses;
var i=uses.indexOf(use);
if(i!=-1){
uses.splice(i,1);
if(uses.length==0){
this.hide();
}
}
};
Jacuba.Editor.Bar.prototype.show=function(){
if(this.hideTimeout){
clearTimeout(this.hideTimeout);
this.hideTimeout=null;
}
this.showNow();
};
Jacuba.Editor.Bar.prototype.showNow=function(){
if(this.status!="open"){
this.setStatus("opening");
}
};
Jacuba.Editor.Bar.prototype.hide=function(){
if(this.hideTimeout){
return;
}
this.hideTimeout=window.setTimeout("Jacuba.Editor.Bar.staticHide('"+this.id+"')",Jacuba.Editor.Bar.HIDE_DELAY);
};
Jacuba.Editor.Bar.prototype.hideNow=function(){
if(this.status!="closed"){
this.setStatus("closing");
}
};
Jacuba.Editor.Bar.prototype.setStatus=function(_253){
if(_253==this.status){
return;
}
if(_253!="opening"&&_253!="open"&&_253!="closing"&&_253!="closed"){
throw "Illegal status: "+_253;
}
if(_253=="opening"){
if(!Jacuba.isIE){
this.edges.style.display="";
}
}
var _254=this.edges.previousSibling;
if(this.status=="closed"){
if(this.div){
var adj=Jacuba.isIE&&document.compatMode!="CSS1Compat"?0:2;
var _254=this.edges.previousSibling;
var _256=this.div.firstChild.offsetWidth+adj;
var _257=_254.offsetWidth;
var _258=Math.max(_257,_256);
var _259=Math.round((_257-_258)/2);
this.edges.style.marginLeft=_259+"px";
this.edges.style.width=_258+"px";
this.div.style.width=(_258-adj)+"px";
}
}
this.status=_253;
if(_253=="opening"||_253=="closing"){
if(!this.slideInterval){
this.slideInterval=setInterval("Jacuba.Editor.Bar.staticSlide('"+this.id+"')",Jacuba.Editor.Bar.SLIDE_PERIOD);
}
}
if(_253=="open"||_253=="closed"){
if(this.slideInterval){
clearInterval(this.slideInterval);
this.slideInterval=null;
}
if(_253=="closed"){
if(!Jacuba.isIE){
this.edges.style.display="none";
}
}
}
};
Jacuba.Editor.Bar.prototype.setContent=function(_260){
if(!this.div){
return;
}
var _261=document.createElement("div");
_261.innerHTML=_260;
this.div.appendChild(_261);
};
Jacuba.Editor.Popup=function(_262){
if(!_262){
throw ("no editor supplied");
}
this.editor=_262;
this.id=_262.id+Jacuba.Editor.Popup.ID_SUFFIX;
};
Jacuba.Editor.Popup.HFN_CONTEXTMENU=function(_263){
var ev=new Jacuba.Event(_263);
ev.stop();
return false;
};
Jacuba.Editor.Popup.HFN_CLICK=function(_264){
var ev=new Jacuba.Event(_264);
var elid=ev.target.id;
var upid=Jacuba.trimId(elid);
var acid=elid.substring(upid.length+1,elid.length);
var edid=Jacuba.trimId(upid);
var _269=Jacuba.editors[edid];
if(!_269){
return;
}
_269.contextAction(acid);
};
Jacuba.Editor.Popup.ID_SUFFIX="_popup";
Jacuba.Editor.Popup.prototype.id=null;
Jacuba.Editor.Popup.prototype.editor=null;
Jacuba.Editor.Popup.prototype.div=null;
Jacuba.Editor.Popup.prototype.count=0;
Jacuba.Editor.Popup.prototype.attach=function(){
if(this.div){
throw "popup already attached";
}
var div=document.createElement("div");
div.id=this.id;
div.className=Jacuba.ID_PREFIX+"_popup";
var body=document.body;
body.insertBefore(div,body.firstChild);
this.div=div;
Jacuba.Event.addListener(div,"contextmenu",Jacuba.Editor.Popup.HFN_CONTEXTMENU);
Jacuba.Event.addListener(div,"click",Jacuba.Editor.Popup.HFN_CLICK);
};
Jacuba.Editor.Popup.prototype.detach=function(){
var div=this.div;
if(!div){
throw "popup not attached";
}
Jacuba.Event.removeListener(div,"contextmenu",Jacuba.Editor.Popup.HFN_CONTEXTMENU);
Jacuba.Event.removeListener(div,"click",Jacuba.Editor.Popup.HFN_CLICK);
this.div.parentNode.removeChild(this.div);
this.div=null;
};
Jacuba.Editor.Popup.prototype.show=function(x,y){
var div=this.div;
if(!div){
return false;
}
div.style.top=y+"px";
div.style.left=x+"px";
if(div.style.visibility=="visible"){
return false;
}
var adj;
if(Jacuba.isIE){
if(document.compatMode=="CSS1Compat"){
div.style.width="1px";
div.style.height="1px";
adj=0;
}else{
adj=2;
}
}else{
div.style.width="200px";
div.style.height="200px";
adj=0;
}
div.style.width=(adj+div.firstChild.offsetWidth)+"px";
div.style.height=(adj+div.firstChild.offsetHeight)+"px";
div.style.visibility="visible";
this.editor.bar.addUse("popup");
return true;
};
Jacuba.Editor.Popup.prototype.hide=function(){
var div=this.div;
if(!div){
return false;
}
if(div.style.visibility=="hidden"){
return false;
}
div.style.visibility="hidden";
this.editor.bar.removeUse("popup");
return true;
};
Jacuba.Editor.Popup.prototype.clearOptions=function(){
var div=this.div;
if(!div){
return;
}
var _270=div.firstChild;
if(_270){
div.removeChild(_270);
}
_270=document.createElement("div");
_270.style.overflow="visible";
_270.style.position="absolute";
if(Jacuba.isIE){
_270.style.width="100%";
}
div.appendChild(_270);
};
Jacuba.Editor.Popup.prototype.addSeparator=function(){
var div=this.div;
if(!div){
return;
}
var _271=div.firstChild;
if(!_271){
this.clearOptions();
}
var hr=document.createElement("hr");
_271.appendChild(hr);
};
Jacuba.Editor.Popup.prototype.addOption=function(_273,_274){
if(_273==null){
throw "label must be supplied";
}
var div=this.div;
if(!div){
return;
}
var _275=div.firstChild;
if(!_275){
this.clearOptions();
}
var _276=document.createElement("div");
_276.className=Jacuba.ID_PREFIX+"_option";
_276.onmouseover=function(){
if(this.id){
this.style.color="#ffffff";
this.style.backgroundColor="#3366ff";
}
};
_276.onmouseout=function(){
if(this.id){
this.style.color="#000000";
this.style.backgroundColor="#eeeeee";
}
};
if(_274!=null){
_276.id=this.id+"_"+_274;
}else{
_276.style.fontStyle="italic";
}
_276.innerHTML=Jacuba.escapeHTML(_273);
_275.appendChild(_276);
this.count++;
return _276;
};
Jacuba.Editor.Popup.prototype.addCorrection=function(word,_277){
var _278=this.addOption(word,_277);
_278.style.fontWeight="bold";
return _278;
};
Jacuba.Editor.Spelling=function(_279){
if(!_279){
throw "no editor";
}
this.editor=_279;
this.id=_279.id+Jacuba.Editor.Bar.ID_SUFFIX;
};
Jacuba.Editor.Spelling.prototype.win=null;
Jacuba.Editor.Spelling.prototype.traverse=false;
Jacuba.Editor.Spelling.prototype.span=null;
Jacuba.Editor.Spelling.prototype.word="";
Jacuba.Editor.Spelling.prototype.corrections=null;
Jacuba.Editor.Spelling.prototype.attach=function(){
try{
this.win.focus();
}
catch(e){
this.win=null;
}
if(!this.win){
var _280=340;
var _281=270;
var _282=Math.round((screen.height-_281)/2);
var _283=Math.round((screen.width-_280)/2);
var win=window.open("javascript: '<html><head><title>Loading...</title></head><body></body></html>'",Jacuba.ID_PREFIX+"_spell","resizable=yes,width="+_280+",height="+_281+",left="+_283+",top="+_282);
var doc=win.document;
doc.open();
doc.write("<html><head>");
doc.write("<title>Spelling</title>");
doc.write("<style>");
doc.write("html { background-color: #eeeeee; font-family: Tahoma, sans-serif; font-size: 13px }");
doc.write("td { vertical-align: top }");
doc.write("label { font-size: 13px }");
doc.write("input { width: 100% }");
doc.write("input#word { padding-left: 22px }");
doc.write("input.unknown { background: url('"+Jacuba.IMAGE_PATH+"unknown.gif') white no-repeat 2px center }");
doc.write("input.incorrect { background: url('"+Jacuba.IMAGE_PATH+"incorrect.gif') white no-repeat 2px center }");
doc.write("input.correct { background: url('"+Jacuba.IMAGE_PATH+"correct.gif') white no-repeat 2px center }");
doc.write("input.user { background: url('"+Jacuba.IMAGE_PATH+"user.gif') white no-repeat 2px center }");
doc.write("select { width: 100% }");
doc.write(".buttonrow { text-align: right }");
doc.write(".buttoncolumn { width: 25%; vertical-align: middle }");
doc.write(".buttoncolumn button { width: 100%; display: block }");
doc.write("</style>");
doc.write("</head><body>");
doc.write("<table style='width: 100%'><tr>");
doc.write("<td style='width: 75%'>");
doc.write("<label for='word'>Word</label><br>");
doc.write("<table style='width: 100%'><tr>");
doc.write("<td style='width: 100%; vertical-align: middle'><input type='TEXT' id='word'></td>");
doc.write("<td style='width: 0%; vertical-align: middle'><button id='check'><img src='"+Jacuba.IMAGE_PATH+"check.gif' alt='Check Spelling'></button></td>");
doc.write("</tr></table>");
doc.write("<label for='corrections'>Corrections</label><br>");
doc.write("<select size='8' id='corrections'></select><br>");
doc.write("</td>");
doc.write("<td class='buttoncolumn'>");
doc.write("<button style='margin: 0px 0px 3px 0px' id='replace'>Replace</button>");
doc.write("<button style='margin: 3px 0px 3px 0px' id='replaceall'>Replace All</button>");
doc.write("<button style='margin: 3px 0px 3px 0px' id='ignore'>Ignore</button>");
doc.write("<button style='margin: 3px 0px 3px 0px' id='ignoreall'>Ignore All</button>");
doc.write("<button style='margin: 3px 0px 0px 0px' id='add'>Add</button>");
doc.write("</td>");
doc.write("</tr><tr>");
doc.write("<td colspan='2'>");
doc.write("<hr>");
doc.write("</td>");
doc.write("</tr><tr>");
doc.write("<td></td>");
doc.write("<td>");
doc.write("<div class='buttonrow'>");
doc.write("<button class='sidebutton' id='close'>Close</button>");
doc.write("</div>");
doc.write("</td>");
doc.write("</div>");
doc.write("</td>");
doc.write("</tr></table>");
doc.write("</body></html>");
doc.close();
if(win){
win.focus();
}
var _284=this;
win.onunload=function(){
_284.close();
};
win.onload=function(){
doc.getElementById("corrections").focus();
};
doc.getElementById("word").onchange=function(){
_284.setWord(this.value);
};
doc.getElementById("word").onkeypress=function(_285){
if((new Jacuba.Event(_285?_285:win.event)).keyCode==13){
_284.check();
}
};
doc.getElementById("word").onkeyup=function(){
_284.setWord(this.value);
};
doc.getElementById("corrections").onchange=function(){
_284.setWord(this.value);
};
doc.getElementById("corrections").ondblclick=function(){
_284.replace();
};
doc.getElementById("check").onclick=function(){
_284.check();
};
doc.getElementById("replace").onclick=function(){
_284.replace();
};
doc.getElementById("replaceall").onclick=function(){
_284.replaceAll();
};
doc.getElementById("ignore").onclick=function(){
_284.ignore();
};
doc.getElementById("ignoreall").onclick=function(){
_284.ignoreAll();
};
doc.getElementById("add").onclick=function(){
_284.add();
};
doc.getElementById("close").onclick=function(){
win.close();
};
doc.getElementsByTagName("BODY")[0].onkeyup=function(_286){
if((new Jacuba.Event(_286?_286:win.event)).keyCode==27){
win.close();
}
};
this.win=win;
}
this.win.focus();
};
Jacuba.Editor.Spelling.prototype.detach=function(){
if(!this.win){
return;
}
this.win.close();
this.win=null;
};
Jacuba.Editor.Spelling.prototype.setTraverse=function(_287){
this.traverse=_287;
};
Jacuba.Editor.Spelling.prototype.moveToIncorrect=function(){
var _288=this.editor.iframe.contentWindow.document.getElementsByTagName("SPAN");
for(var i=0;i<_288.length;i++){
var span=_288[i];
if(span.className=="incorrect"){
this.setSpan(span);
return true;
}
}
return false;
};
Jacuba.Editor.Spelling.prototype.setSpan=function(span){
if(span==this.span){
return;
}
var word=span?span.word:null;
this.span=span;
this.setWord(word);
this.check();
};
Jacuba.Editor.Spelling.prototype.setWord=function(word){
if(word==null){
word="";
}
if(word==this.word){
return;
}
this.word=word;
var win=this.win;
if(win){
var doc=win.document;
var _289=doc.getElementById("word");
if(_289.value!=word){
_289.value=word;
}
var clss;
if(this.corrections&&this.corrections.indexOf(word)!=-1){
clss="correct";
}else{
clss="unknown";
}
_289.className=clss;
var _290=!this.span||this.span.word==word;
doc.getElementById("replace").disabled=_290;
doc.getElementById("replaceall").disabled=_290;
doc.getElementById("ignore").disabled=!this.span;
doc.getElementById("ignoreall").disabled=!this.span;
doc.getElementById("add").disabled=!this.word;
}
};
Jacuba.Editor.Spelling.prototype.setCorrections=function(_291){
this.corrections=_291;
var win=this.win;
if(win){
var doc=win.document;
var _292=doc.getElementById("corrections");
_292.innerHTML="";
for(var i=0;i<_291.length;i++){
var _293=_291[i];
var _294=doc.createElement("OPTION");
var text=doc.createTextNode(_293);
_294.appendChild(text);
_294.value=_293;
_292.appendChild(_294);
}
}
};
Jacuba.Editor.Spelling.prototype.check=function(){
var word=Jacuba.trimWord(this.word);
if(word){
var _295=Jacuba.getWordEntry(word);
var _296=this;
Jacuba.withWordEntry(word,function(_295){
var _297=_295.word==_296.word;
_296.win.document.getElementById("word").className=_297?_295.correctness:"incorrect";
_296.setCorrections(_295.corrections);
});
}else{
this.win.document.getElementById("corrections").innerHTML="";
}
};
Jacuba.Editor.Spelling.prototype.replace=function(){
var span=this.span;
if(!span){
return;
}
if(span.word==this.word){
return;
}
span.innerHTML=Jacuba.escapeHTML(this.word);
span.className="unknown";
this.setSpan(null);
this.editor.collapseSelection();
this.editor.wrap();
if(!this.traverse||!this.moveToIncorrect()){
this.close();
}
};
Jacuba.Editor.Spelling.prototype.replaceAll=function(){
var span=this.span;
if(!span){
return;
}
var _298=this.editor.getSpansForWord(this.span.word);
var html=Jacuba.escapeHTML(this.word);
for(var i=0;i<_298.length;i++){
var span=_298[i];
span.innerHTML=html;
span.className="unknown";
}
this.setSpan(null);
this.editor.collapseSelection();
this.editor.wrap();
if(!this.traverse||!this.moveToIncorrect()){
this.close();
}
};
Jacuba.Editor.Spelling.prototype.ignore=function(){
var span=this.span;
if(!span){
return;
}
span.className="ignored";
this.setSpan(null);
if(!this.traverse||!this.moveToIncorrect()){
this.close();
}
};
Jacuba.Editor.Spelling.prototype.ignoreAll=function(){
var span=this.span;
if(!span){
return;
}
var _299=this.editor.getSpansForWord(this.span.word);
for(var i=0;i<_299.length;i++){
_299[i].className="ignored";
}
this.setSpan(null);
if(!this.traverse||!this.moveToIncorrect()){
this.close();
}
};
Jacuba.Editor.Spelling.prototype.add=function(){
if(!this.word){
return;
}
Jacuba.addMyWord(this.word);
};
Jacuba.Editor.Spelling.prototype.close=function(){
this.editor.spelling=null;
this.detach();
};
if(window["jacuba_favelet"]||window["jacuba_loaded"]){
var startup=true;
var favelet=Jacuba.Favelet.lastInvoked();
if(!favelet||favelet.isTooOld()){
startup=false;
var gojacuba=confirm(Jacuba.TEXT.required_favelet_message);
if(gojacuba){
if(!window.open(Jacuba.HOME_PAGE)){
window.location=Jacuba.HOME_PAGE;
}
}
}else{
if(favelet.isOld()){
var gojacuba=confirm(Jacuba.TEXT.newer_favelet_message);
if(gojacuba){
if(!window.open(Jacuba.HOME_PAGE)){
window.location=Jacuba.HOME_PAGE;
}
}
}
}
if(startup){
Jacuba.startup();
Jacuba.applyTo("element: TEXTAREA");
}
}else{
Jacuba.Event.addListener(window,"load",Jacuba.HFN_LOAD);
}

above is normally called like this

head


<script type="text/javascript" src="http://www.jacuba.com/service/checker/-/-/" defer="defer"></script>

body

<body onload="if (window.Jacuba) Jacuba.applyTo('element: TEXTAREA')">

The best way to get around 'running out' of body onload space is to handle it using a custom function; an even better way is picking some sort of add event handler policy (using custom functions) and adhering to it..

A sneaky cheat way is to add extra empty body sections after your main body section and put onload events in them.. that may not work on XHTML browsers... but I don't think there could be a rule against it in the XHTML schema ^_-

The reason alot of things want to be in body onload is because body onload means 'do this when the page has finished loading'. that's a good thing from two perspectives.
- firstly, it eliminates the risk of javascript DOM methods failing and giving cryptic errors because elements don't exist yet.
- secondly, it means that the page can be fully loaded (and viewable by a user) before a potentially lengthly javascript process is invoked.

if you don't want the page to be fully loaded before doing something; you could use body onbeforeload="". but that might screw with javascript + HTML DOM interaction on some browsers. if you're careful, you can use inline javascript;
but there's a number of script/object ordering rules you should follow...

[B]Order 1[/B]
<html><body>
<div id="test">
<script>
document.getElementById("test").innerHTML = "hello";
</script>
</div>
</body></html>
[B]Works OK (opera and firefox). HOWEVER, I'm not sure if all of the properties of the DIV should or could be available when the script executes. So, not 100% safe.[/B]
[B]Order 2[/B]
<html><body>
<div id="test">?</div>
<script>
document.getElementById("test").innerHTML = "hello";
</script>
</body></html>
[B]Works OK (opera and firefox), and is more correct than order 1. [/B]
[B]Order 3[/B]
<html><body>
<script>
document.getElementById("test").innerHTML = "hello";
</script>
<div id="test">?</div>
[B]Doesn't work (in either opera or firefox), and shouldn't work. The 'test' div doesn't exist yet.[/B]

So basically, if you put your body onload stuff into a script tag at the very bottom of your page (within the body section but after all of the content in the body section); it shouldn't have any problems.

Matt, do you remember the tag you helped me with before?

http://www.daniweb.com/techtalkforums/thread67900.html

Well I though maybe I could spin something similar, to use an onclick event to call it instead. I came up with this, and to my great surprise, it actually worked in a testbed.

for some reason though it wont work when I add it to my post page.
Any idea why? P.s Had the js in the head, also tried it in body with the rest.

<script type="text/javascript" src="http://www.jacuba.com/service/checker/-/-/" defer="defer"></script>


<script type="text/javascript">
function Jacuba.applyTo('element: TEXTAREA')();{
  }
</script>

<input type="button" onclick="Jacuba.applyTo('element: TEXTAREA')();" value="Spellcheck"/>

<textarea></textarea>

worked here

http://www.jmarshall.com/easy/html/testbed.html

OK I worked this out I only needed this bit

<input type="button" onclick="Jacuba.applyTo('element: TEXTAREA')();" value="Spellcheck"/>

so I have this working in my full reply templet, but strangly it refuses to work in fast reply. no real difference in the two templets except the fast reply textarea has an Id attribute. could this be it? Should I try

<input type="button" onclick="Jacuba.applyTo('id: commentBox')();" value="Spellcheck"/>

?

This article has been dead for over six months. Start a new discussion instead.