Awhile back I posted a simple CFMX on Linux spellchecker. 
I'm nearing completion on the custom tag and thought that this might be an 
appropriate dumping point. 
The custom tag is ~120 lines with 50 dedicated to comments. There are other 
files required for spelling suggestions (using google mini) and 
datarequestor.js for XMLrequests and serialization. It's not pretty and it has 
low self-esteem. So, please criticize it kindly. :) Anyways, here goes. 
mf


<!--- 
Custom Tag 
    Name :      spell
    Location:   /CustomTags/spell.cfm
    Created:    17 November 2006
    Creator:    Mark Fennell
    Purpose:    SpellChecking form fields in CFMX on Linux
    ToDo:       Currently only supports ONE field per page; attributes for 
location of dependencies;
    
    Attributes:
        stage       required    stage=1 draws a contenteditable div that feeds 
your form field
                                stage=2 draws the spelling form and the 
targeted iframe for subversive stuff
                                stage=3 draws the submit button w/ the js 
needed to stuff your form 
                                        field with the corrected spelling
        fieldName   optional    Required if stage=1 this will the name of the 
form field that is submitted to your action page                                
        formName    optional    Required if stage=1 this is the name of the 
form that the form field 
                                belongs to and that will ultimately be submitted
        buttonText  optional    Required if stage=3 this is the name of the 
form submit button

    Directions for use:
        This tag MUST be called three times; once as stage=1, once as stage=2 
and as stage=3. 
        They do NOT have to be called in order.
        
        Stage=1 <cf_spell stage="1" formName="myForm">
        Stage=2 <cf_spell stage="2">
        Stage=3 <cf_spell stage="3" formName="myForm" buttonText="submit" 
fieldName="comments">
        
        Stage 1 and 3 will plop the text box and button where they are called 
so location is important to you. 
        Stage 2 is all hidden so it's location doesn't matter as much.
        
    Sample Calling Document:
            <cfform action="demo.cfm" method="POST" name="myForm" id="myForm">
            <cf_spell stage="1" formName="myForm" fieldname="comments">
            <cf_spell stage="3" formName="myForm" buttonText="submit" 
fieldname="comments">
            </cfform>
            <cf_spell stage="2">

        This tag relies on bunches of other stuff gian.cfm and datarequestor.js 
and sample.txt. 
        datarequestor.js is from http://mikewest.org/ takes care of some 
XMLHTTPRequest and Serialization stuff
        gian.cfm is the google mini-based spelling suggester
        sample.txt is where we store the text being checked.

    Sample gian.cfm:
        <cfhttp 
url="http://google-mini/search?site=IAN&client=IAN&output=xml_no_dtd&ie=&oe=&lr=&skin=&q=#x#";
 method="GET" resolveurl="yes" multipart="yes">
        <cfoutput>
        <cfset res="#XMLParse(cfhttp.filecontent)#">
        <cftry>
        <cfset ret = "#toString(res.GSP.Spelling.Suggestion.XmlAttributes.q)#">
        <cfcatch><cfset ret="No suggestions available."></cfcatch>
        </cftry>
        #ret#
        </cfoutput>
        
 --->


<cfif isDefined("attributes.stage") and attributes.stage eq "2">
        <iframe name="spellFrame" id="spellFrame" width="0" height="0" 
marginwidth="0" marginheight="0" scrolling="no" frameborder="0"></iframe>
        <form action="/ian/CustomTags/spell.cfm" name="spellForm" 
id="spellForm" target="spellFrame"><input type="hidden" name="spell" 
value=""></form>
<cfelseif  isDefined("attributes.stage") and attributes.stage eq "3">
        <cfoutput>
            <input class="butt" type="button" value="#attributes.buttonText#" 
                
onClick="document.#attributes.formName#.#attributes.fieldName#.value=document.getElementById('bigText').innerHTML;
 document.#attributes.formName#.submit();">
        </cfoutput>
<cfelseif  isDefined("attributes.stage") and attributes.stage eq "1">
        <cfoutput><input type="hidden" name="#attributes.fieldName#" 
value=""></cfoutput>
        <div id="bigText" contenteditable="true" style="border: 1px solid 
silver; height: 250px; width: 420px;">Type your text here.</div>
        <input type="button" name="spellcheck" value="spellcheck" 
onClick="init_check()">
        
        <script language="JavaScript" src="/ian/js/datarequestor.js"></script>
        <style type="text/css">
        .wrong { color: red; text-decoration: underline; cursor: pointer;}
        </style>
        
        <script language="JavaScript" type="text/javascript">
            var req = new DataRequestor();
        function init_check() {
            var myStr=document.getElementById('bigText').innerHTML;
                document.spellForm.spell.value=myStr;
                document.spellForm.submit();
                alert("Spell Check Complete\r\nClick RED words for 
suggestions.\r\nNot all items have suggestions.");
                }
                
        function check(x) {
        req.getURL("/ian/CustomTags/gian.cfm?x="+x);
        req.onload = function (d) {
                                changeTo(x,d);
                            }
        }
        function changeTo(x,d)
        {
            if(d=="No suggestions available. ")
            { alert(d); }
            else
                { var t = confirm("Change "+x+" to "+d+"?"); } 
            if(d!= "No suggestions available. " && t)
                { 
                    var c = new RegExp("<a[^>]+>"+x+"</a>","gi");
                    
document.getElementById('bigText').innerHTML=document.getElementById('bigText').innerHTML.replace(c,d);
                }
            else if(d!="No suggestions available. ") { alert("No change 
made."); }
        }
        </script>
<cfelseif isDefined("spell")>
        <cftry>
        <cffile action="DELETE" file="/www/html/ian/mf/spellCheck/sample.txt">
        <cfcatch></cfcatch>
        </cftry>
        <cffile action="WRITE" file="/www/html/ian/mf/spellCheck/sample.txt" 
output="#REreplace(spell,'<[^>]*>','','ALL')#" attributes="Normal" mode="777" 
addnewline="Yes">
        <cffile action="READ" file="/www/html/ian/mf/spellCheck/sample.txt" 
variable="v_txt">
        <cfexecute name="/usr/bin/spell" 
arguments="/www/html/ian/mf/spellCheck/sample.txt" variable="v_spell" 
timeOut="30"></cfexecute>
        <cfoutput>
        <cfloop index="ret" list="#v_spell#" delimiters="#chr(10)#">
        <cfif ret neq "">
        <cfset v_txt=replace(v_txt," "&ret," <a class=wrong 
onclick=check('#ret#');>#ret#</a>",'ALL')>
        </cfif>
        </cfloop>
        <script>
        parent.document.getElementById('bigText').innerHTML= 
'#replace(jsstringformat(v_txt),'\r\n','<P>','ALL')#' ;
        </script>
        #jsstringformat(spell)#
        </cfoutput>
</cfif>
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Friday, November 17, 2006 1:52 PM
To: discussion@acfug.org
Subject: [ACFUG Discuss] Spell Checker for FCKeditor


What are people using as a spell checker in FCKeditor?  I need a server
side solution, and it seems FCKeditor prefers SpellerPages.
We are running CF on Windows 2003 with IIS 6.
If I were to use SpellerPages' aspell, do I need to install PHP on my
ColdFusion sever?


Thanks!

ed
----------------------------------------------------------------------
Ed Szwedo

Web Development Team Lead
CSC
E-mail: [EMAIL PROTECTED]
919-541-3955  (Voice)
919-541-3719  (Fax)



-------------------------------------------------------------
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------





-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------



Reply via email to