(Answer) (Category) Faq-O-Matic Faq-O-Matic : (Category) Administrators' Guide : (Category) In Development :
Spellchecker on new answers
Here is a patch to add the Wintertree spellcheck applet to FAQOMatic
diff -ur lib/FAQ/OMatic/Part.pm /usr/lib/perl5/site_perl/5.005/FAQ/OMatic/Part.pm
--- lib/FAQ/OMatic/Part.pm      Sun Jun  4 15:27:36 2000
+++ /usr/lib/perl5/site_perl/5.005/FAQ/OMatic/Part.pm   Sun Sep 24 17:47:34 2000
@@ -484,6 +484,7 @@
        
                $rt .= $text."</textarea>\n";
        
+               $rt .= "<br><input type=button value=\"Check Spelling\" onclick=\"checkSpelling();\">\n";
                $rt.="</td>\n";
                $rt.="</tr><tr>\n";
                $rt.="<td align=left valign=top width=\"50%\">\n";
@@ -568,7 +569,60 @@
 #                      'Cancel and return to FAQ');
        $rt.="</td>\n";
        $rt.="</tr></table>\n";
-
+       $rt .= <<FOO;
+   <SCRIPT LANGUAGE="JavaScript">
+function checkSpelling() {
+    if (!navigator.javaEnabled()) {
+        alert("Java must be enabled in your browser to use the spelling checker.");
+        return;
+    }
+
+    // Retrieve the options and user dictionary cookie.
+    var options = document.SpellCheckApplet.getOptions();
+    var cookies = document.cookie;
+    var pos = cookies.indexOf("spellcheck=");
+    var s;
+    if (pos >= 0) {
+        var start = pos + 11;
+        var end = cookies.indexOf(";", start);
+        if (end < 0) {
+            end = cookies.length;
+        }
+        var scCookie = unescape(cookies.substring(start, end));
+        end = scCookie.indexOf(":");
+        if (end < 0) {
+            end = scCookie.length;
+        }
+        s = scCookie.substring(0, end);
+        options = s - 0;
+        document.SpellCheckApplet.setOptions(options);
+        if (end != scCookie.length) {
+            start = end + 1;
+            s = scCookie.substring(start, scCookie.length);
+            document.SpellCheckApplet.setUserDictionary(s);
+        }
+    }
+    document.SpellCheckApplet.text = document.forms[0].elements._newText.value;
+    var status = document.SpellCheckApplet.check();
+    if (status == 1) {
+        document.forms[0].elements._newText.value = document.SpellCheckApplet.text;
+    }
+
+    // Save the options and user dictionary in case the user dictionary changed.
+    var nextYear = new Date();
+    nextYear.setFullYear(nextYear.getFullYear() + 1);
+    options = document.SpellCheckApplet.getOptions();
+    var userDict = document.SpellCheckApplet.getUserDictionary();
+    document.cookie = "spellcheck=" + escape(options.toString() + ":" + userDict) +
+      "; expires=" + nextYear.toGMTString();
+}
+</SCRIPT>
+<APPLET CODE="SpellCheckApplet.class"
+NAME="SpellCheckApplet"
+ARCHIVE="/spell/SpellCheckApplet.jar"
+CODEBASE="/spell"
+WIDTH=347 HEIGHT=74></APPLET>
+FOO
        return $rt;
 }
 
[Append to This Answer]
Previous: (Answer) Change the Faq-O-Matic reference to sourceforge.
Next: (Answer) Are there any projects that use servlets instead of perl for the infrastructure?
This document is: http://www.jonh.net/cgi-bin/faqomatic/fom?file=966
[Search] [Appearance]
This is a Faq-O-Matic 2.718d.
Hosted by SourceForge Logo and jonh.net.