commit
b2a3bb7703
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 553 B |
Before Width: | Height: | Size: 553 B After Width: | Height: | Size: 1.0 KiB |
@ -1,179 +1,179 @@ |
||||
/* |
||||
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
||||
* Copyright (C) 2003-2009 Frederico Caldeira Knabben |
||||
* |
||||
* == BEGIN LICENSE == |
||||
* |
||||
* Licensed under the terms of any of the following licenses at your |
||||
* choice: |
||||
* |
||||
* - GNU General Public License Version 2 or later (the "GPL") |
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
* |
||||
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* |
||||
* - Mozilla Public License Version 1.1 or later (the "MPL") |
||||
* http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
* |
||||
* == END LICENSE == |
||||
* |
||||
* Create the FCKeditorAPI object that is available as a global object in |
||||
* the page where the editor is placed in. |
||||
*/ |
||||
|
||||
var FCKeditorAPI ; |
||||
|
||||
function InitializeAPI() |
||||
{ |
||||
var oParentWindow = window.parent ; |
||||
|
||||
if ( !( FCKeditorAPI = oParentWindow.FCKeditorAPI ) ) |
||||
{ |
||||
// Make the FCKeditorAPI object available in the parent window. Use
|
||||
// eval so this core runs in the parent's scope and so it will still be
|
||||
// available if the editor instance is removed ("Can't execute code
|
||||
// from a freed script" error).
|
||||
|
||||
// Note: we check the existence of oEditor.GetParentForm because some external
|
||||
// code (like JSON) can extend the Object prototype and we get then extra oEditor
|
||||
// objects that aren't really FCKeditor instances.
|
||||
var sScript = |
||||
/* |
||||
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
||||
* Copyright (C) 2003-2009 Frederico Caldeira Knabben |
||||
* |
||||
* == BEGIN LICENSE == |
||||
* |
||||
* Licensed under the terms of any of the following licenses at your |
||||
* choice: |
||||
* |
||||
* - GNU General Public License Version 2 or later (the "GPL") |
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
* |
||||
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* |
||||
* - Mozilla Public License Version 1.1 or later (the "MPL") |
||||
* http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
* |
||||
* == END LICENSE == |
||||
* |
||||
* Create the FCKeditorAPI object that is available as a global object in |
||||
* the page where the editor is placed in. |
||||
*/ |
||||
|
||||
var FCKeditorAPI ; |
||||
|
||||
function InitializeAPI() |
||||
{ |
||||
var oParentWindow = window.parent ; |
||||
|
||||
if ( !( FCKeditorAPI = oParentWindow.FCKeditorAPI ) ) |
||||
{ |
||||
// Make the FCKeditorAPI object available in the parent window. Use
|
||||
// eval so this core runs in the parent's scope and so it will still be
|
||||
// available if the editor instance is removed ("Can't execute code
|
||||
// from a freed script" error).
|
||||
|
||||
// Note: we check the existence of oEditor.GetParentForm because some external
|
||||
// code (like JSON) can extend the Object prototype and we get then extra oEditor
|
||||
// objects that aren't really FCKeditor instances.
|
||||
var sScript = |
||||
'window.FCKeditorAPI = {' + |
||||
'Version : "2.6.4.1",' + |
||||
'VersionBuild : "23195",' + |
||||
'Instances : window.FCKeditorAPI && window.FCKeditorAPI.Instances || {},' + |
||||
|
||||
'GetInstance : function( name )' + |
||||
'{' + |
||||
'return this.Instances[ name ];' + |
||||
'},' + |
||||
|
||||
'_FormSubmit : function()' + |
||||
'{' + |
||||
'for ( var name in FCKeditorAPI.Instances )' + |
||||
'{' + |
||||
'var oEditor = FCKeditorAPI.Instances[ name ] ;' + |
||||
'if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )' + |
||||
'oEditor.UpdateLinkedField() ;' + |
||||
'}' + |
||||
'this._FCKOriginalSubmit() ;' + |
||||
'},' + |
||||
|
||||
'_FunctionQueue : window.FCKeditorAPI && window.FCKeditorAPI._FunctionQueue || {' + |
||||
'Functions : new Array(),' + |
||||
'IsRunning : false,' + |
||||
|
||||
'Add : function( f )' + |
||||
'{' + |
||||
'this.Functions.push( f );' + |
||||
'if ( !this.IsRunning )' + |
||||
'this.StartNext();' + |
||||
'},' + |
||||
|
||||
'StartNext : function()' + |
||||
'{' + |
||||
'var aQueue = this.Functions ;' + |
||||
'if ( aQueue.length > 0 )' + |
||||
'{' + |
||||
'this.IsRunning = true;' + |
||||
'aQueue[0].call();' + |
||||
'}' + |
||||
'else ' + |
||||
'this.IsRunning = false;' + |
||||
'},' + |
||||
|
||||
'Remove : function( f )' + |
||||
'{' + |
||||
'var aQueue = this.Functions;' + |
||||
'var i = 0, fFunc;' + |
||||
'while( (fFunc = aQueue[ i ]) )' + |
||||
'{' + |
||||
'if ( fFunc == f )' + |
||||
'aQueue.splice( i,1 );' + |
||||
'i++ ;' + |
||||
'}' + |
||||
'this.StartNext();' + |
||||
'}' + |
||||
'}' + |
||||
'}' ; |
||||
|
||||
// In IE, the "eval" function is not always available (it works with
|
||||
// the JavaScript samples, but not with the ASP ones, for example).
|
||||
// So, let's use the execScript instead.
|
||||
if ( oParentWindow.execScript ) |
||||
oParentWindow.execScript( sScript, 'JavaScript' ) ; |
||||
else |
||||
{ |
||||
if ( FCKBrowserInfo.IsGecko10 ) |
||||
{ |
||||
// FF 1.0.4 gives an error with the request bellow. The
|
||||
// following seams to work well.
|
||||
eval.call( oParentWindow, sScript ) ; |
||||
} |
||||
else if( FCKBrowserInfo.IsAIR ) |
||||
{ |
||||
FCKAdobeAIR.FCKeditorAPI_Evaluate( oParentWindow, sScript ) ; |
||||
} |
||||
else if ( FCKBrowserInfo.IsSafari ) |
||||
{ |
||||
// oParentWindow.eval in Safari executes in the calling window
|
||||
// environment, instead of the parent one. The following should
|
||||
// make it work.
|
||||
var oParentDocument = oParentWindow.document ; |
||||
var eScript = oParentDocument.createElement('script') ; |
||||
eScript.appendChild( oParentDocument.createTextNode( sScript ) ) ; |
||||
oParentDocument.documentElement.appendChild( eScript ) ; |
||||
} |
||||
else |
||||
oParentWindow.eval( sScript ) ; |
||||
} |
||||
|
||||
FCKeditorAPI = oParentWindow.FCKeditorAPI ; |
||||
|
||||
// The __Instances properly has been changed to the public Instances,
|
||||
// but we should still have the "deprecated" version of it.
|
||||
FCKeditorAPI.__Instances = FCKeditorAPI.Instances ; |
||||
} |
||||
|
||||
// Add the current instance to the FCKeditorAPI's instances collection.
|
||||
FCKeditorAPI.Instances[ FCK.Name ] = FCK ; |
||||
} |
||||
|
||||
// Attach to the form onsubmit event and to the form.submit().
|
||||
function _AttachFormSubmitToAPI() |
||||
{ |
||||
// Get the linked field form.
|
||||
var oForm = FCK.GetParentForm() ; |
||||
|
||||
if ( oForm ) |
||||
{ |
||||
// Attach to the onsubmit event.
|
||||
FCKTools.AddEventListener( oForm, 'submit', FCK.UpdateLinkedField ) ; |
||||
|
||||
// IE sees oForm.submit function as an 'object'.
|
||||
if ( !oForm._FCKOriginalSubmit && ( typeof( oForm.submit ) == 'function' || ( !oForm.submit.tagName && !oForm.submit.length ) ) ) |
||||
{ |
||||
// Save the original submit.
|
||||
oForm._FCKOriginalSubmit = oForm.submit ; |
||||
|
||||
// Create our replacement for the submit.
|
||||
oForm.submit = FCKeditorAPI._FormSubmit ; |
||||
} |
||||
} |
||||
} |
||||
|
||||
function FCKeditorAPI_Cleanup() |
||||
{ |
||||
if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat |
||||
&& !window.FCKUnloadFlag ) |
||||
return ; |
||||
delete FCKeditorAPI.Instances[ FCK.Name ] ; |
||||
} |
||||
function FCKeditorAPI_ConfirmCleanup() |
||||
{ |
||||
if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat ) |
||||
window.FCKUnloadFlag = true ; |
||||
} |
||||
FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ; |
||||
FCKTools.AddEventListener( window, 'beforeunload', FCKeditorAPI_ConfirmCleanup) ; |
||||
'Version : "2.6.4.1",' + |
||||
'VersionBuild : "23405",' + |
||||
'Instances : window.FCKeditorAPI && window.FCKeditorAPI.Instances || {},' + |
||||
|
||||
'GetInstance : function( name )' + |
||||
'{' + |
||||
'return this.Instances[ name ];' + |
||||
'},' + |
||||
|
||||
'_FormSubmit : function()' + |
||||
'{' + |
||||
'for ( var name in FCKeditorAPI.Instances )' + |
||||
'{' + |
||||
'var oEditor = FCKeditorAPI.Instances[ name ] ;' + |
||||
'if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )' + |
||||
'oEditor.UpdateLinkedField() ;' + |
||||
'}' + |
||||
'this._FCKOriginalSubmit() ;' + |
||||
'},' + |
||||
|
||||
'_FunctionQueue : window.FCKeditorAPI && window.FCKeditorAPI._FunctionQueue || {' + |
||||
'Functions : new Array(),' + |
||||
'IsRunning : false,' + |
||||
|
||||
'Add : function( f )' + |
||||
'{' + |
||||
'this.Functions.push( f );' + |
||||
'if ( !this.IsRunning )' + |
||||
'this.StartNext();' + |
||||
'},' + |
||||
|
||||
'StartNext : function()' + |
||||
'{' + |
||||
'var aQueue = this.Functions ;' + |
||||
'if ( aQueue.length > 0 )' + |
||||
'{' + |
||||
'this.IsRunning = true;' + |
||||
'aQueue[0].call();' + |
||||
'}' + |
||||
'else ' + |
||||
'this.IsRunning = false;' + |
||||
'},' + |
||||
|
||||
'Remove : function( f )' + |
||||
'{' + |
||||
'var aQueue = this.Functions;' + |
||||
'var i = 0, fFunc;' + |
||||
'while( (fFunc = aQueue[ i ]) )' + |
||||
'{' + |
||||
'if ( fFunc == f )' + |
||||
'aQueue.splice( i,1 );' + |
||||
'i++ ;' + |
||||
'}' + |
||||
'this.StartNext();' + |
||||
'}' + |
||||
'}' + |
||||
'}' ; |
||||
|
||||
// In IE, the "eval" function is not always available (it works with
|
||||
// the JavaScript samples, but not with the ASP ones, for example).
|
||||
// So, let's use the execScript instead.
|
||||
if ( oParentWindow.execScript ) |
||||
oParentWindow.execScript( sScript, 'JavaScript' ) ; |
||||
else |
||||
{ |
||||
if ( FCKBrowserInfo.IsGecko10 ) |
||||
{ |
||||
// FF 1.0.4 gives an error with the request bellow. The
|
||||
// following seams to work well.
|
||||
eval.call( oParentWindow, sScript ) ; |
||||
} |
||||
else if( FCKBrowserInfo.IsAIR ) |
||||
{ |
||||
FCKAdobeAIR.FCKeditorAPI_Evaluate( oParentWindow, sScript ) ; |
||||
} |
||||
else if ( FCKBrowserInfo.IsSafari ) |
||||
{ |
||||
// oParentWindow.eval in Safari executes in the calling window
|
||||
// environment, instead of the parent one. The following should
|
||||
// make it work.
|
||||
var oParentDocument = oParentWindow.document ; |
||||
var eScript = oParentDocument.createElement('script') ; |
||||
eScript.appendChild( oParentDocument.createTextNode( sScript ) ) ; |
||||
oParentDocument.documentElement.appendChild( eScript ) ; |
||||
} |
||||
else |
||||
oParentWindow.eval( sScript ) ; |
||||
} |
||||
|
||||
FCKeditorAPI = oParentWindow.FCKeditorAPI ; |
||||
|
||||
// The __Instances properly has been changed to the public Instances,
|
||||
// but we should still have the "deprecated" version of it.
|
||||
FCKeditorAPI.__Instances = FCKeditorAPI.Instances ; |
||||
} |
||||
|
||||
// Add the current instance to the FCKeditorAPI's instances collection.
|
||||
FCKeditorAPI.Instances[ FCK.Name ] = FCK ; |
||||
} |
||||
|
||||
// Attach to the form onsubmit event and to the form.submit().
|
||||
function _AttachFormSubmitToAPI() |
||||
{ |
||||
// Get the linked field form.
|
||||
var oForm = FCK.GetParentForm() ; |
||||
|
||||
if ( oForm ) |
||||
{ |
||||
// Attach to the onsubmit event.
|
||||
FCKTools.AddEventListener( oForm, 'submit', FCK.UpdateLinkedField ) ; |
||||
|
||||
// IE sees oForm.submit function as an 'object'.
|
||||
if ( !oForm._FCKOriginalSubmit && ( typeof( oForm.submit ) == 'function' || ( !oForm.submit.tagName && !oForm.submit.length ) ) ) |
||||
{ |
||||
// Save the original submit.
|
||||
oForm._FCKOriginalSubmit = oForm.submit ; |
||||
|
||||
// Create our replacement for the submit.
|
||||
oForm.submit = FCKeditorAPI._FormSubmit ; |
||||
} |
||||
} |
||||
} |
||||
|
||||
function FCKeditorAPI_Cleanup() |
||||
{ |
||||
if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat |
||||
&& !window.FCKUnloadFlag ) |
||||
return ; |
||||
delete FCKeditorAPI.Instances[ FCK.Name ] ; |
||||
} |
||||
function FCKeditorAPI_ConfirmCleanup() |
||||
{ |
||||
if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat ) |
||||
window.FCKUnloadFlag = true ; |
||||
} |
||||
FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ; |
||||
FCKTools.AddEventListener( window, 'beforeunload', FCKeditorAPI_ConfirmCleanup) ; |
||||
|
@ -1,148 +0,0 @@ |
||||
<cfsetting enablecfoutputonly="true"> |
||||
<!--- |
||||
This code uses a CF User Defined Function and should work in CF version 5.0 |
||||
and up without alteration. |
||||
|
||||
Also if you are hosting your site at an ISP, you will have to check with them |
||||
to see if the use of <CFEXECUTE> is allowed. In most cases ISP will not allow |
||||
the use of that tag for security reasons. Clients would be able to access each |
||||
others files in certain cases. |
||||
---> |
||||
|
||||
<!--- The following variables values must reflect your installation. ---> |
||||
<cfset aspell_dir = "C:\Program Files\Aspell\bin"> |
||||
<cfset lang = "en_US"> |
||||
<cfset aspell_opts = "-a --lang=#lang# --encoding=utf-8 -H --rem-sgml-check=alt"> |
||||
<cfset tempfile_in = GetTempFile(GetTempDirectory(), "spell_")> |
||||
<cfset tempfile_out = GetTempFile(GetTempDirectory(), "spell_")> |
||||
<cfset spellercss = "../spellerStyle.css"> |
||||
<cfset word_win_src = "../wordWindow.js"> |
||||
|
||||
<cfset form.checktext = form["textinputs[]"]> |
||||
|
||||
<!--- make no difference between URL and FORM scopes ---> |
||||
<cfparam name="url.checktext" default=""> |
||||
<cfparam name="form.checktext" default="#url.checktext#"> |
||||
|
||||
<!--- Takes care of those pesky smart quotes from MS apps, replaces them with regular quotes ---> |
||||
<cfset submitted_text = ReplaceList(form.checktext,"%u201C,%u201D","%22,%22")> |
||||
|
||||
<!--- submitted_text now is ready for processing ---> |
||||
|
||||
<!--- use carat on each line to escape possible aspell commands ---> |
||||
<cfset text = ""> |
||||
<cfset CRLF = Chr(13) & Chr(10)> |
||||
|
||||
<cfloop list="#submitted_text#" index="field" delimiters=","> |
||||
<cfset text = text & "%" & CRLF |
||||
& "^A" & CRLF |
||||
& "!" & CRLF> |
||||
<!--- Strip all tags for the text. (by FredCK - #339 / #681) ---> |
||||
<cfset field = REReplace(URLDecode(field), "<[^>]+>", " ", "all")> |
||||
<cfloop list="#field#" index="line" delimiters="#CRLF#"> |
||||
<cfset text = ListAppend(text, "^" & Trim(JSStringFormat(line)), CRLF)> |
||||
</cfloop> |
||||
</cfloop> |
||||
|
||||
<!--- create temp file from the submitted text, this will be passed to aspell to be check for misspelled words ---> |
||||
<cffile action="write" file="#tempfile_in#" output="#text#" charset="utf-8"> |
||||
|
||||
<!--- execute aspell in an UTF-8 console and redirect output to a file. UTF-8 encoding is lost if done differently ---> |
||||
<cfexecute name="cmd.exe" arguments='/c type "#tempfile_in#" | "#aspell_dir#\aspell.exe" #aspell_opts# > "#tempfile_out#"' timeout="100"/> |
||||
|
||||
<!--- read output file for further processing ---> |
||||
<cffile action="read" file="#tempfile_out#" variable="food" charset="utf-8"> |
||||
|
||||
<!--- remove temp files ---> |
||||
<cffile action="delete" file="#tempfile_in#"> |
||||
<cffile action="delete" file="#tempfile_out#"> |
||||
|
||||
<cfset texts = StructNew()> |
||||
<cfset texts.textinputs = ""> |
||||
<cfset texts.words = ""> |
||||
<cfset texts.abort = ""> |
||||
|
||||
<!--- Generate Text Inputs ---> |
||||
<cfset i = 0> |
||||
<cfloop list="#submitted_text#" index="textinput"> |
||||
<cfset texts.textinputs = ListAppend(texts.textinputs, 'textinputs[#i#] = decodeURIComponent("#textinput#");', CRLF)> |
||||
<cfset i = i + 1> |
||||
</cfloop> |
||||
|
||||
<!--- Generate Words Lists ---> |
||||
<cfset word_cnt = 0> |
||||
<cfset input_cnt = -1> |
||||
<cfloop list="#food#" index="aspell_line" delimiters="#CRLF#"> |
||||
<cfset leftChar = Left(aspell_line, 1)> |
||||
<cfif leftChar eq "*"> |
||||
<cfset input_cnt = input_cnt + 1> |
||||
<cfset word_cnt = 0> |
||||
<cfset texts.words = ListAppend(texts.words, "words[#input_cnt#] = [];", CRLF)> |
||||
<cfset texts.words = ListAppend(texts.words, "suggs[#input_cnt#] = [];", CRLF)> |
||||
<cfelse> |
||||
<cfif leftChar eq "&" or leftChar eq "##"> |
||||
<!--- word that misspelled ---> |
||||
<cfset bad_word = Trim(ListGetAt(aspell_line, 2, " "))> |
||||
<cfset bad_word = Replace(bad_word, "'", "\'", "ALL")> |
||||
<!--- sugestions ---> |
||||
<cfset sug_list = Trim(ListRest(aspell_line, ":"))> |
||||
<cfset sug_list = ListQualify(Replace(sug_list, "'", "\'", "ALL"), "'")> |
||||
<!--- javascript ---> |
||||
<cfset texts.words = ListAppend(texts.words, "words[#input_cnt#][#word_cnt#] = '#bad_word#';", CRLF)> |
||||
<cfset texts.words = ListAppend(texts.words, "suggs[#input_cnt#][#word_cnt#] = [#sug_list#];", CRLF)> |
||||
<cfset word_cnt = word_cnt + 1> |
||||
</cfif> |
||||
</cfif> |
||||
</cfloop> |
||||
|
||||
<cfif texts.words eq ""> |
||||
<cfset texts.abort = "alert('Spell check complete.\n\nNo misspellings found.'); top.window.close();"> |
||||
</cfif> |
||||
|
||||
<cfcontent type="text/html; charset=utf-8"> |
||||
|
||||
<cfoutput><html> |
||||
<head> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
||||
<link rel="stylesheet" type="text/css" href="#spellercss#" /> |
||||
<script language="javascript" src="#word_win_src#"></script> |
||||
<script language="javascript"> |
||||
var suggs = new Array(); |
||||
var words = new Array(); |
||||
var textinputs = new Array(); |
||||
var error; |
||||
|
||||
#texts.textinputs##CRLF# |
||||
#texts.words# |
||||
#texts.abort# |
||||
|
||||
var wordWindowObj = new wordWindow(); |
||||
wordWindowObj.originalSpellings = words; |
||||
wordWindowObj.suggestions = suggs; |
||||
wordWindowObj.textInputs = textinputs; |
||||
|
||||
function init_spell() { |
||||
// check if any error occured during server-side processing |
||||
if( error ) { |
||||
alert( error ); |
||||
} else { |
||||
// call the init_spell() function in the parent frameset |
||||
if (parent.frames.length) { |
||||
parent.init_spell( wordWindowObj ); |
||||
} else { |
||||
alert('This page was loaded outside of a frameset. It might not display properly'); |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
</head> |
||||
<body onLoad="init_spell();"> |
||||
|
||||
<script type="text/javascript"> |
||||
wordWindowObj.writeBody(); |
||||
</script> |
||||
|
||||
</body> |
||||
</html></cfoutput> |
||||
<cfsetting enablecfoutputonly="false"> |
@ -1,181 +0,0 @@ |
||||
#!/usr/bin/perl |
||||
|
||||
use CGI qw/ :standard /; |
||||
use File::Temp qw/ tempfile tempdir /; |
||||
|
||||
# my $spellercss = '/speller/spellerStyle.css'; # by FredCK |
||||
my $spellercss = '../spellerStyle.css'; # by FredCK |
||||
# my $wordWindowSrc = '/speller/wordWindow.js'; # by FredCK |
||||
my $wordWindowSrc = '../wordWindow.js'; # by FredCK |
||||
my @textinputs = param( 'textinputs[]' ); # array |
||||
# my $aspell_cmd = 'aspell'; # by FredCK (for Linux) |
||||
my $aspell_cmd = '"C:\Program Files\Aspell\bin\aspell.exe"'; # by FredCK (for Windows) |
||||
my $lang = 'en_US'; |
||||
# my $aspell_opts = "-a --lang=$lang --encoding=utf-8"; # by FredCK |
||||
my $aspell_opts = "-a --lang=$lang --encoding=utf-8 -H --rem-sgml-check=alt"; # by FredCK |
||||
my $input_separator = "A"; |
||||
|
||||
# set the 'wordtext' JavaScript variable to the submitted text. |
||||
sub printTextVar { |
||||
for( my $i = 0; $i <= $#textinputs; $i++ ) { |
||||
print "textinputs[$i] = decodeURIComponent('" . escapeQuote( $textinputs[$i] ) . "')\n"; |
||||
} |
||||
} |
||||
|
||||
sub printTextIdxDecl { |
||||
my $idx = shift; |
||||
print "words[$idx] = [];\n"; |
||||
print "suggs[$idx] = [];\n"; |
||||
} |
||||
|
||||
sub printWordsElem { |
||||
my( $textIdx, $wordIdx, $word ) = @_; |
||||
print "words[$textIdx][$wordIdx] = '" . escapeQuote( $word ) . "';\n"; |
||||
} |
||||
|
||||
sub printSuggsElem { |
||||
my( $textIdx, $wordIdx, @suggs ) = @_; |
||||
print "suggs[$textIdx][$wordIdx] = ["; |
||||
for my $i ( 0..$#suggs ) { |
||||
print "'" . escapeQuote( $suggs[$i] ) . "'"; |
||||
if( $i < $#suggs ) { |
||||
print ", "; |
||||
} |
||||
} |
||||
print "];\n"; |
||||
} |
||||
|
||||
sub printCheckerResults { |
||||
my $textInputIdx = -1; |
||||
my $wordIdx = 0; |
||||
my $unhandledText; |
||||
# create temp file |
||||
my $dir = tempdir( CLEANUP => 1 ); |
||||
my( $fh, $tmpfilename ) = tempfile( DIR => $dir ); |
||||
|
||||
# temp file was created properly? |
||||
|
||||
# open temp file, add the submitted text. |
||||
for( my $i = 0; $i <= $#textinputs; $i++ ) { |
||||
$text = url_decode( $textinputs[$i] ); |
||||
# Strip all tags for the text. (by FredCK - #339 / #681) |
||||
$text =~ s/<[^>]+>/ /g; |
||||
@lines = split( /\n/, $text ); |
||||
print $fh "\%\n"; # exit terse mode |
||||
print $fh "^$input_separator\n"; |
||||
print $fh "!\n"; # enter terse mode |
||||
for my $line ( @lines ) { |
||||
# use carat on each line to escape possible aspell commands |
||||
print $fh "^$line\n"; |
||||
} |
||||
|
||||
} |
||||
# exec aspell command |
||||
my $cmd = "$aspell_cmd $aspell_opts < $tmpfilename 2>&1"; |
||||
open ASPELL, "$cmd |" or handleError( "Could not execute `$cmd`\\n$!" ) and return; |
||||
# parse each line of aspell return |
||||
for my $ret ( <ASPELL> ) { |
||||
chomp( $ret ); |
||||
# if '&', then not in dictionary but has suggestions |
||||
# if '#', then not in dictionary and no suggestions |
||||
# if '*', then it is a delimiter between text inputs |
||||
if( $ret =~ /^\*/ ) { |
||||
$textInputIdx++; |
||||
printTextIdxDecl( $textInputIdx ); |
||||
$wordIdx = 0; |
||||
|
||||
} elsif( $ret =~ /^(&|#)/ ) { |
||||
my @tokens = split( " ", $ret, 5 ); |
||||
printWordsElem( $textInputIdx, $wordIdx, $tokens[1] ); |
||||
my @suggs = (); |
||||
if( $tokens[4] ) { |
||||
@suggs = split( ", ", $tokens[4] ); |
||||
} |
||||
printSuggsElem( $textInputIdx, $wordIdx, @suggs ); |
||||
$wordIdx++; |
||||
} else { |
||||
$unhandledText .= $ret; |
||||
} |
||||
} |
||||
close ASPELL or handleError( "Error executing `$cmd`\\n$unhandledText" ) and return; |
||||
} |
||||
|
||||
sub escapeQuote { |
||||
my $str = shift; |
||||
$str =~ s/'/\\'/g; |
||||
return $str; |
||||
} |
||||
|
||||
sub handleError { |
||||
my $err = shift; |
||||
print "error = '" . escapeQuote( $err ) . "';\n"; |
||||
} |
||||
|
||||
sub url_decode { |
||||
local $_ = @_ ? shift : $_; |
||||
defined or return; |
||||
# change + signs to spaces |
||||
tr/+/ /; |
||||
# change hex escapes to the proper characters |
||||
s/%([a-fA-F0-9]{2})/pack "H2", $1/eg; |
||||
return $_; |
||||
} |
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
||||
# Display HTML |
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
||||
|
||||
print <<EOF; |
||||
Content-type: text/html; charset=utf-8 |
||||
|
||||
<html> |
||||
<head> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
||||
<link rel="stylesheet" type="text/css" href="$spellercss"/> |
||||
<script src="$wordWindowSrc"></script> |
||||
<script type="text/javascript"> |
||||
var suggs = new Array(); |
||||
var words = new Array(); |
||||
var textinputs = new Array(); |
||||
var error; |
||||
EOF |
||||
|
||||
printTextVar(); |
||||
|
||||
printCheckerResults(); |
||||
|
||||
print <<EOF; |
||||
var wordWindowObj = new wordWindow(); |
||||
wordWindowObj.originalSpellings = words; |
||||
wordWindowObj.suggestions = suggs; |
||||
wordWindowObj.textInputs = textinputs; |
||||
|
||||
|
||||
function init_spell() { |
||||
// check if any error occured during server-side processing |
||||
if( error ) { |
||||
alert( error ); |
||||
} else { |
||||
// call the init_spell() function in the parent frameset |
||||
if (parent.frames.length) { |
||||
parent.init_spell( wordWindowObj ); |
||||
} else { |
||||
error = "This page was loaded outside of a frameset. "; |
||||
error += "It might not display properly"; |
||||
alert( error ); |
||||
} |
||||
} |
||||
} |
||||
|
||||
</script> |
||||
|
||||
</head> |
||||
<body onLoad="init_spell();"> |
||||
|
||||
<script type="text/javascript"> |
||||
wordWindowObj.writeBody(); |
||||
</script> |
||||
|
||||
</body> |
||||
</html> |
||||
EOF |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue