User:Connel MacKenzie/spellcheck.js

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

/*
To turn on this spellcheck button, edit your [[Special:Mypage/monobook.js]] and add the following line (make sure it doesn't line break):

 document.write('<script type="text/javascript" src="/w/index.php?title=User:Connel_MacKenzie/spellcheck.js&action=raw&ctype=text/javascript"><\/script>');

When you save it, make sure you CTRL-SH-R or WIN-CTRL-SH-R or Mac-Sh-R or whatever.  Or restart your browser.  If your browser has a javascript console, open it up and look for errors if you aren't getting the "check" icon on the toolbar on edit pages.

If you don't use the monobook skin, then you shouldn't edit on Wikimedia.  Too many things are simply missing, otherwise.
*/

function checkIt() {
    //yes, I know this part is monobook-specific.  Read warnings above.
        if (document.editform) {
                var txtarea = document.editform.wpTextbox1;
        } else {
                // some alternate form? take the first one we can find
                var areas = document.getElementsByTagName('textarea');
                var txtarea = areas[0];
        }
        PromptWin = window.open("about:blank", "CheckSpelling", "width=680,location=yes,menubar=yes,toolbar=yes,resizable,scrollbars");
        PromptWin.document.open();
        PromptWin.document.write("<html><title>Spelling</title>");
        PromptWin.document.write('<body onload="document.spellcheckform.submit.click();">');
        PromptWin.document.write('<p>Preparing to check for incorrecly spelled words...<hr>\n');
        PromptWin.document.write('<form action="http://toolserver.org/~cmackenzie/spellcheck.php" method="GET" id="spellcheckform" name="spellcheckform">');
        PromptWin.document.write('<textarea name="text" cols=60 rows=20>');
        var textAreaLength = txtarea.value.length;
        var textAreaStart = 0;
        if (textAreaLength > 4096) textAreaStart = textAreaLength - 4096;
        PromptWin.document.write(txtarea.value.substring(textAreaStart, textAreaLength));
        PromptWin.document.write('</textarea><br />');
        PromptWin.document.write('<INPUT TYPE="submit" VALUE="Submit" id="submit" name="submit">');
        PromptWin.document.write('</form></body></html>');
        PromptWin.document.close();
        //PromptWin.document.spellcheckform.submit.click();
 }

function addSpellCheckButton() {
 diffButton = document.getElementById('wpDiff');
 if (diffButton) {
   var spellButton = document.createElement('input');
       spellButton.type='submit';
       spellButton.tabindex=7.5 ;
       spellButton.value="Check spelling";
       spellButton.accesskey="g"; //get spell check?
       spellButton.title="Check the spelling (EXPERIMENTAL) of this entry using 'spell' command on toolserver";
       spellButton.onclick = function() {
             checkIt();
             return false;
         }
       diffButton.parentNode.insertBefore( spellButton, diffButton.nextSibling);
    }
 tooly = document.getElementById('toolbar');
 if ( (!tooly) ) return;
 return;
 var buttonSP = document.createElement("img");
        buttonSP.width = 23;
        buttonSP.height = 22;
        buttonSP.src = 'http://upload.wikimedia.org/wikipedia/commons/9/9d/Button_fait.png';
        buttonSP.border = 0;
        buttonSP.alt = 'Spellcheck';
        buttonSP.title = 'Spellcheck';
        buttonSP.style.cursor = "pointer";
        buttonSP.onclick = function() {
                checkIt();
                return false;
        }
  tooly.appendChild(buttonSP);
}

addOnloadHook( addSpellCheckButton );