[pmwiki-users] Small headache with a spell check attempt.

Crisses crisses at kinhost.org
Sat Dec 16 07:51:56 CST 2006


On Dec 15, 2006, at 6:58 PM, Seth Cherney wrote:

> I have been trying to integrate a java spell check into pmwiki, as  
> I cannot access pspell/aspell on my hosted server.

Geek note: Java is not JavaScript.  :)  Java is by Sun Corporation,  
and is a very very hefty undertaking.  JavaScript is by Netscape Corp  
I believe, and is meant for browser scripting.  The two came out  
around the same time, and the names are very very confusing.

This is JavaScript.  I started reading and went "Java!  I can't help  
with Java!!" :)  Good thing I kept reading.

> My thought was only to mod PM's spellcheck.php to call the other js  
> (it works on js in the browser as well.  The spell checker I am  
> trying to integrate is VERY easy to integrate (but I am no coder).   
> It is sourceforge.net/projects/jspspellcheck, based on jazzy - and  
> using word lists fo dicts (ie can make any language!).
>
> I was dropping the whole thing into the pub directory, then trying  
> to rewrite the spellcheck.php in the cookbook to point to it.   
> There are a few syntax problems converting the js to php compatible  
> js, and it tries to find the form name, but ther is no form name in  
> pmwiki edit, just for the text area.

Ok -- actually this is probably a make-or-break issue.  When using  
JavaScript to "script the DOM" (document object model or something)  
it really needs to have a "name" on the "object" (in this case the  
browser's text area) to point to.

The getElementById needs a CSS Id on the item you're accessing...   
such as <textarea id="spellCheckme">  id tags are meant to be unique  
identifiers on the page -- used only once.  JavaScript takes  
advantage of that fact, and uses it to target an item on the page.

> bellow is the file I have been trying to work on.  the two lines  
> with !!! are the ones I believe causing probs.  someone with a  
> little time could perhaps download jspspellcheck and give me  some  
> help??  I think it is very easy for someone with background (I am a  
> theologian).

Sorry I don't have time to do that :/

>     This will add a "spell check" button to the GUI button bar, and
>     link in the necessary spell checking scripts.
> #<script src='$PubDirUrl/speller/spellChecker.js'></script>
> #<script type='text/javascript' >
> #function openSpellChecker() {
> #    var textarea1 = document.getElementById('text');
> #    var speller = new spellChecker( textarea1 );
> #    speller.popUpUrl = '$PubDirUrl/speller/spellchecker.html';
> ##    speller.openChecker();
> #}
> #</script>
> */
>
> # If we're not editing, then just exit.
> if ($action != 'edit') return;
> # Configure in the Speller Pages javascript code.
> $HTMLHeaderFmt[] = "
> <script src='$PubDirUrl/jspspellcheck/jspspellcheck/spellcheck- 
> caller.js'></script>
> <script type='text/javascript' >
> function spellCheck(){
>     var elements = new Array(0);
>     !!!    elements = document.getElementById('text');

Unless the id on the box is specifically "text" this will fail.

You can try getElementsByTagName and "textarea"?

elements = document.getElementsByTagName("textarea")
if(elements.length) {
     !!!    startSpellCheck('$PubDirUrl/jspspellcheck/', elements );
}
}
</script>

This is me guessing.  I am a programmer, but I'm NOT a JavaScript  
programmer.

it's either this, or find a way to add the id="text" to the HTML for  
the textarea.

Crisses




More information about the pmwiki-users mailing list