Page 1 2 3
PART 2
Changes to NetSpell Files
I’m going to need to make a couple of changes to spell.js and SpellChecker.aspx that we just copied into the root of our DotNetNuke install. Make sure you apply these changes to the files in the DotNetNuke and not the original in the NetSpell folder.
Open spell.js, find the function below, this should be about line 78.
function checkSpellingById(id)
{
checkElements = new Array();
checkElements[checkElements.length] = id;
openSpellChecker();
}
I’m going to change the function to the one below, in effect I’ve added the FTBFocus(); line to the method.
function checkSpellingById(id)
{
checkElements = new Array();
checkElements[checkElements.length] = id;
FTBFocus();
openSpellChecker();
}
Right you can read this paragraph to understand why I’m doing this or you can skip on.
When we click the check spelling button this method checkSpellingById is called, in turn this will call my method called FTBFocus. I need FTBFocus to over come a strange issue I noticed, if I spell check and the cursor is not in the FTB control then when we return from the checker if I were to hit Update although the words looked changed the data stored in the database doesn’t reflect the corrected works.
These two changes to spell.js below will allow the script to work with a FireFox browser. Find the function called getText at Line 13. It will look like this below,
function getText(index)
{
var oElement = document.getElementById(checkElements[index]);
var sText = "";
switch (oElement.tagName)
{
case "INPUT" :
case "TEXTAREA" :
sText = oElement.value;
break;
case "DIV" :
case "SPAN" :
case "BODY" :
sText = oElement.innerHTML;
break;
case "IFRAME" :
var oFrame = eval(oElement.id);
sText = oFrame.document.body.innerHTML;
}
return sText;
}
We need to change this to the following.
function getText(index)
{
var oElement = document.getElementById(checkElements[index]);
var sText = "";
switch (oElement.tagName)
{
case "INPUT" :
case "TEXTAREA" :
sText = oElement.value;
break;
case "DIV" :
case "SPAN" :
case "BODY" :
sText = oElement.innerHTML;
break;
case "IFRAME" :
if (oElement.contentDocument)
{
sText = oElement.contentDocument.body.innerHTML;
}
else
{
var oFrame = eval(oElement.id);
sText = oFrame.document.body.innerHTML;
}
break;
}
return sText;
}
Next we need to change the setText function. Line 37 which will look like this
function setText(index, text)
{
var oElement = document.getElementById(checkElements[index]);
switch (oElement.tagName)
{
case "INPUT" :
case "TEXTAREA" :
oElement.value = text;
break;
case "DIV" :
case "SPAN" :
oElement.innerHTML = text;
break;
case "IFRAME" :
var oFrame = eval(oElement.id);
oFrame.document.body.innerHTML = text;
break;
}
}
needs to be changed to this.
function setText(index, text)
{
var oElement = document.getElementById(checkElements[index]);
switch (oElement.tagName)
{
case "INPUT" :
case "TEXTAREA" :
oElement.value = text;
break;
case "DIV" :
case "SPAN" :
oElement.innerHTML = text;
break;
case "IFRAME" :
if (oElement.contentDocument)
{
oElement.contentDocument.body.innerHTML = text;
}
else
{
var oFrame =eval(oElement.id);
oFrame.document.body.innerHTML = text;
}
break;
}
}
Right two changes to the SpellChecker.aspx. Find the two lines as below these are at line 248.
<link href="spell.css" type="text/css" rel="stylesheet" />
<script language="JavaScript" src="/Portals/0/spell.js" type="text/javascript">
</script>
We need to rework the references since the FriendlyURL HTTP Module will fail to find these two external files referenced here. So lets just replace them with these two lines of code.
<link href="<%= Page.ResolveUrl("spell.css") %>"
type="text/css" rel="stylesheet" />
<script language="JavaScript" src="/Portals/0/<%= Page.ResolveUrl("spell.js") %>"
type="text/javascript"></script>
I’m going to make a change to the EnableButtons method, I’m going to make sure that the Add button is disabled. In a web application this button will only save the word to a dictionary held in cache, the word will never be persisted to a disk based dictionary. So I’m turning off the feature and here is my EnableButtons method.
void EnableButtons()
{
this.IgnoreButton.Enabled = true;
this.IgnoreAllButton.Enabled = true;
this.AddButton.Enabled = false;
this.ReplaceButton.Enabled = true;
this.ReplaceAllButton.Enabled = true;
this.ReplacementWord.Enabled = true;
this.Suggestions.Enabled = true;
}
<< Previous Page Next Page >>