MDL-17368 removing unused html area spell checker - we have our own implementation; backported from MOODLE_19_STABLE
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 107 B |
@@ -1,37 +0,0 @@
|
||||
// I18N constants
|
||||
|
||||
// LANG: "en", ENCODING: UTF-8 | ISO-8859-1
|
||||
// Author: Mihai Bazon, <[email protected]>
|
||||
|
||||
// FOR TRANSLATORS:
|
||||
//
|
||||
// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
|
||||
// (at least a valid email address)
|
||||
//
|
||||
// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
|
||||
// (if this is not possible, please include a comment
|
||||
// that states what encoding is necessary.)
|
||||
|
||||
SpellChecker.I18N = {
|
||||
"CONFIRM_LINK_CLICK" : "Please confirm that you want to open this link",
|
||||
"Cancel" : "Cancel",
|
||||
"Dictionary" : "Dictionary",
|
||||
"Finished list of mispelled words" : "Finished list of mispelled words",
|
||||
"I will open it in a new page." : "I will open it in a new page.",
|
||||
"Ignore all" : "Ignore all",
|
||||
"Ignore" : "Ignore",
|
||||
"NO_ERRORS" : "No mispelled words found with the selected dictionary.",
|
||||
"NO_ERRORS_CLOSING" : "Spell check complete, didn't find any mispelled words. Closing now...",
|
||||
"OK" : "OK",
|
||||
"Original word" : "Original word",
|
||||
"Please wait. Calling spell checker." : "Please wait. Calling spell checker.",
|
||||
"Please wait: changing dictionary to" : "Please wait: changing dictionary to",
|
||||
"QUIT_CONFIRMATION" : "This will drop changes and quit spell checker. Please confirm.",
|
||||
"Re-check" : "Re-check",
|
||||
"Replace all" : "Replace all",
|
||||
"Replace with" : "Replace with",
|
||||
"Replace" : "Replace",
|
||||
"SC-spell-check" : "Spell-check",
|
||||
"Suggestions" : "Suggestions",
|
||||
"pliz weit ;-)" : "pliz weit ;-)"
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
// I18N constants
|
||||
|
||||
// LANG: "ro", ENCODING: UTF-8
|
||||
// Author: Mihai Bazon, <[email protected]>
|
||||
|
||||
// FOR TRANSLATORS:
|
||||
//
|
||||
// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
|
||||
// (at least a valid email address)
|
||||
//
|
||||
// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
|
||||
// (if this is not possible, please include a comment
|
||||
// that states what encoding is necessary.)
|
||||
|
||||
SpellChecker.I18N = {
|
||||
"CONFIRM_LINK_CLICK" : "Vă rog confirmaţi că vreţi să deschideţi acest link",
|
||||
"Cancel" : "Anulează",
|
||||
"Dictionary" : "Dicţionar",
|
||||
"Finished list of mispelled words" : "Am terminat lista de cuvinte greşite",
|
||||
"I will open it in a new page." : "O voi deschide într-o altă fereastră.",
|
||||
"Ignore all" : "Ignoră toate",
|
||||
"Ignore" : "Ignoră",
|
||||
"NO_ERRORS" : "Nu am găsit nici un cuvânt greşit cu acest dicţionar.",
|
||||
"NO_ERRORS_CLOSING" : "Am terminat, nu am detectat nici o greşeală. Acum închid fereastra...",
|
||||
"OK" : "OK",
|
||||
"Original word" : "Cuvântul original",
|
||||
"Please wait. Calling spell checker." : "Vă rog aşteptaţi. Apelez spell-checker-ul.",
|
||||
"Please wait: changing dictionary to" : "Vă rog aşteptaţi. Schimb dicţionarul cu",
|
||||
"QUIT_CONFIRMATION" : "Doriţi să renunţaţi la modificări şi să închid spell-checker-ul?",
|
||||
"Re-check" : "Scanează",
|
||||
"Replace all" : "Înlocuieşte toate",
|
||||
"Replace with" : "Înlocuieşte cu",
|
||||
"Replace" : "Înlocuieşte",
|
||||
"SC-spell-check" : "Detectează greşeli",
|
||||
"Suggestions" : "Sugestii",
|
||||
"pliz weit ;-)" : "va rog ashteptatzi ;-)"
|
||||
};
|
||||
@@ -1,115 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>HTMLArea Spell Checker</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>HTMLArea Spell Checker</h1>
|
||||
|
||||
<p>The HTMLArea Spell Checker subsystem consists of the following
|
||||
files:</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>spell-checker.js — the spell checker plugin interface for
|
||||
HTMLArea</li>
|
||||
|
||||
<li>spell-checker-ui.html — the HTML code for the user
|
||||
interface</li>
|
||||
|
||||
<li>spell-checker-ui.js — functionality of the user
|
||||
interface</li>
|
||||
|
||||
<li>spell-checker-logic.cgi — Perl CGI script that checks a text
|
||||
given through POST for spelling errors</li>
|
||||
|
||||
<li>spell-checker-style.css — style for mispelled words</li>
|
||||
|
||||
<li>lang/en.js — main language file (English).</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<h2>Process overview</h2>
|
||||
|
||||
<p>
|
||||
When an end-user clicks the "spell-check" button in the HTMLArea
|
||||
editor, a new window is opened with the URL of "spell-check-ui.html".
|
||||
This window initializes itself with the text found in the editor (uses
|
||||
<tt>window.opener.SpellChecker.editor</tt> global variable) and it
|
||||
submits the text to the server-side script "spell-check-logic.cgi".
|
||||
The target of the FORM is an inline frame which is used both to
|
||||
display the text and correcting.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Further, spell-check-logic.cgi calls Aspell for each portion of plain
|
||||
text found in the given HTML. It rebuilds an HTML file that contains
|
||||
clear marks of which words are incorrect, along with suggestions for
|
||||
each of them. This file is then loaded in the inline frame. Upon
|
||||
loading, a JavaScript function from "spell-check-ui.js" is called.
|
||||
This function will retrieve all mispelled words from the HTML of the
|
||||
iframe and will setup the user interface so that it allows correction.
|
||||
</p>
|
||||
|
||||
<h2>The server-side script (spell-check-logic.cgi)</h2>
|
||||
|
||||
<p>
|
||||
<strong>Unicode safety</strong> — the program <em>is</em>
|
||||
Unicode safe. HTML entities are expanded into their corresponding
|
||||
Unicode characters. These characters will be matched as part of the
|
||||
word passed to Aspell. All texts passed to Aspell are in Unicode
|
||||
(when appropriate). However, Aspell seems to not support Unicode
|
||||
yet (<a
|
||||
href="http://mail.gnu.org/archive/html/aspell-user/2000-11/msg00007.html">thread concerning Aspell and Unicode</a>).
|
||||
This mean that words containing Unicode
|
||||
characters that are not in 0..255 are likely to be reported as "mispelled" by Aspell.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
I digged the Net for a couple of hours today and I can't seem to find
|
||||
any open-source spell checker that has Unicode support. For this
|
||||
reason we keep using Aspell, because it also seems to have the
|
||||
best suggestions engine. Unicode support will eventually be
|
||||
implemented in Aspell. <a href="mailto:[email protected]">Email
|
||||
Kevin Atkinson</a> (Aspell author and maintainer) about this ;-)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The Perl Unicode manual (man perluniintro) states:
|
||||
</p>
|
||||
|
||||
<blockquote>
|
||||
<em>
|
||||
Starting from Perl 5.6.0, Perl has had the capacity to handle Unicode
|
||||
natively. Perl 5.8.0, however, is the first recommended release for
|
||||
serious Unicode work. The maintenance release 5.6.1 fixed many of the
|
||||
problems of the initial Unicode implementation, but for example regular
|
||||
expressions still do not work with Unicode in 5.6.1.
|
||||
</em>
|
||||
</blockquote>
|
||||
|
||||
<p>In other words, do <em>not</em> assume that this script is
|
||||
Unicode-safe on Perl interpreters older than 5.8.0.</p>
|
||||
|
||||
<p>The following Perl modules are required:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="http://search.cpan.org/search?query=Text%3A%3AAspell&mode=all" target="_blank">Text::Aspell</a></li>
|
||||
<li><a href="http://search.cpan.org/search?query=HTML%3A%3AParser&mode=all" target="_blank">HTML::Parser</a></li>
|
||||
<li><a href="http://search.cpan.org/search?query=HTML%3A%3AEntities&mode=all" target="_blank">HTML::Entities</a></li>
|
||||
<li><a href="http://search.cpan.org/search?query=CGI&mode=all" target="_blank">CGI</a></li>
|
||||
</ul>
|
||||
|
||||
<p>Of these, only Text::Aspell might need to be installed manually. The
|
||||
others are likely to be available by default in most Perl distributions.</p>
|
||||
|
||||
<hr />
|
||||
<address><a href="http://students.infoiasi.ro/~mishoo/">Mihai Bazon</a></address>
|
||||
<!-- Created: Thu Jul 17 13:22:27 EEST 2003 -->
|
||||
<!-- hhmts start -->
|
||||
Last modified on Sun Aug 10 12:28:24 2003
|
||||
<!-- hhmts end -->
|
||||
<!-- doc-lang: English -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,155 +1 @@
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
# Spell Checker Plugin for HTMLArea-3.0
|
||||
# Implementation by Mihai Bazon. Sponsored by www.americanbible.org
|
||||
#
|
||||
# htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc.
|
||||
# This notice MUST stay intact for use (see license.txt).
|
||||
#
|
||||
# A free WYSIWYG editor replacement for <textarea> fields.
|
||||
# For full source code and docs, visit http://www.interactivetools.com/
|
||||
#
|
||||
# Version 3.0 developed by Mihai Bazon for InteractiveTools.
|
||||
# http://students.infoiasi.ro/~mishoo
|
||||
#
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
use utf8;
|
||||
use Encode;
|
||||
use Text::Aspell;
|
||||
use HTML::Parser;
|
||||
use HTML::Entities;
|
||||
use CGI;
|
||||
|
||||
my $debug = 0;
|
||||
|
||||
open (DEBUG, '>:encoding(UTF-8)', '> /tmp/spell-check-debug.log') if $debug;
|
||||
|
||||
# use Data::Dumper; # for debug only
|
||||
|
||||
my $speller = new Text::Aspell;
|
||||
my $cgi = new CGI;
|
||||
|
||||
# FIXME: report a nice error...
|
||||
die "Can't create speller!" unless $speller;
|
||||
|
||||
# add configurable option for this
|
||||
my $dict = $cgi->param('dictionary') || 'en_US';
|
||||
$speller->set_option('lang', $dict);
|
||||
|
||||
# ultra, fast, normal, bad-spellers
|
||||
# bad-spellers seems to cause segmentation fault
|
||||
$speller->set_option('sug-mode', 'ultra');
|
||||
|
||||
my @replacements = ();
|
||||
|
||||
sub text_handler {
|
||||
my ($offset, $length, $text, $is_cdata) = @_;
|
||||
if ($is_cdata or $text =~ /^\s*$/) {
|
||||
return 0;
|
||||
}
|
||||
# print STDERR "*** OFFSET: $offset, LENGTH: $length, $text\n";
|
||||
$text = decode_entities($text);
|
||||
$text =~ s/&#([0-9]+);/chr($1)/eg;
|
||||
$text =~ s/&#x([0-9a-fA-F]+);/chr(hex $1)/eg;
|
||||
my $repl = spellcheck($text);
|
||||
if ($repl) {
|
||||
push(@replacements, [ $offset, $length, $repl ]);
|
||||
}
|
||||
}
|
||||
|
||||
my $p = HTML::Parser->new
|
||||
(api_version => 3,
|
||||
handlers => { start => [ sub {
|
||||
my ($self, $tagname, $attrs) = @_;
|
||||
# print STDERR "\033[1;31m parsing tag: $tagname\033[0m\n";
|
||||
# following we skip words that have already been marked as "fixed".
|
||||
if ($tagname eq "span" and $attrs->{class} =~ /HA-spellcheck-fixed/) {
|
||||
$self->handler(text => undef);
|
||||
}
|
||||
}, "self, tagname, attr"
|
||||
],
|
||||
end => [ sub {
|
||||
my ($self, $tagname) = @_;
|
||||
# print STDERR "\033[1;32m END tag: $tagname\033[0m\n";
|
||||
$self->handler(text => \&text_handler, 'offset, length, dtext, is_cdata');
|
||||
}, "self, tagname"
|
||||
]
|
||||
}
|
||||
);
|
||||
$p->handler(text => \&text_handler, 'offset, length, dtext, is_cdata');
|
||||
$p->case_sensitive(1);
|
||||
my $file_content = $cgi->param('content');
|
||||
|
||||
if ($debug) {
|
||||
open (FOO, '>:encoding(UTF-8)', '/tmp/spell-check-before');
|
||||
print FOO $file_content, "\n";
|
||||
close(FOO);
|
||||
}
|
||||
|
||||
$p->parse($file_content);
|
||||
$p->eof();
|
||||
|
||||
foreach (reverse @replacements) {
|
||||
substr($file_content, $_->[0], $_->[1], $_->[2]);
|
||||
}
|
||||
|
||||
# we output UTF-8
|
||||
binmode(STDOUT, ':encoding(UTF-8)'); # apparently, this sucks.
|
||||
print "Content-type: text/html; charset: utf-8\n\n";
|
||||
print qq^
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" media="all" href="spell-check-style.css" />
|
||||
</head>
|
||||
<body onload="window.parent.finishedSpellChecking();">^;
|
||||
|
||||
print $file_content;
|
||||
if ($cgi->param('init') eq '1') {
|
||||
my @dicts = $speller->dictionary_info();
|
||||
my $dictionaries = '';
|
||||
foreach my $i (@dicts) {
|
||||
$dictionaries .= ',' . $i->{name} unless $i->{jargon};
|
||||
}
|
||||
$dictionaries =~ s/^,//;
|
||||
print qq^
|
||||
<div id="HA-spellcheck-dictionaries"
|
||||
>$dictionaries</div>
|
||||
^;
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
open (FOO, '>:encoding(UTF-8)', '/tmp/spell-check-after');
|
||||
print FOO $file_content, "\n";
|
||||
close(FOO);
|
||||
}
|
||||
|
||||
print '</body></html>';
|
||||
|
||||
# Perl is beautiful.
|
||||
sub spellcheck {
|
||||
my $text = shift;
|
||||
sub check { # called for each word in the text
|
||||
# input is in UTF-8
|
||||
my $U_word = shift;
|
||||
my $word = encode($speller->get_option('encoding'), $U_word);
|
||||
print DEBUG "*$U_word* ----> |$word|\n" if $debug;
|
||||
if ($speller->check($word)) {
|
||||
return $U_word; # we return the word in UTF-8
|
||||
} else {
|
||||
# we should have suggestions; give them back to browser in UTF-8
|
||||
my $suggestions = decode($speller->get_option('encoding'), join(',', $speller->suggest($word)));
|
||||
my $ret = '<span class="HA-spellcheck-error">'.$U_word.'</span><span class="HA-spellcheck-suggestions">'.$suggestions.'</span>';
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
$text =~ s/([[:word:]']+)/check($1)/egs;
|
||||
# $text =~ s/(\w+)/check($1)/egs;
|
||||
|
||||
# the following is definitely what we want to use; too bad it sucks most.
|
||||
# $text =~ s/(\p{IsWord}+)/check($1)/egs;
|
||||
return $text;
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
.HA-spellcheck-error { border-bottom: 2px dotted #f00; cursor: default; }
|
||||
.HA-spellcheck-same { background-color: #ff8; color: #000; }
|
||||
.HA-spellcheck-hover { background-color: #433; color: white; }
|
||||
.HA-spellcheck-fixed { border-bottom: 1px dotted #0b8; }
|
||||
.HA-spellcheck-current { background-color: #7be; color: #000; }
|
||||
.HA-spellcheck-suggestions { display: none; }
|
||||
|
||||
#HA-spellcheck-dictionaries { display: none; }
|
||||
|
||||
a:link, a:visited { color: #55e; }
|
||||
@@ -1,119 +0,0 @@
|
||||
<!--
|
||||
|
||||
Strangely, IE sucks with or without the DOCTYPE switch.
|
||||
I thought it would only suck without it.
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
|
||||
Spell Checker Plugin for HTMLArea-3.0
|
||||
Implementation by Mihai Bazon. Sponsored by www.americanbible.org
|
||||
|
||||
htmlArea v3.0 - Copyright (c) 2003 interactivetools.com, inc.
|
||||
This notice MUST stay intact for use (see license.txt).
|
||||
|
||||
A free WYSIWYG editor replacement for <textarea> fields.
|
||||
For full source code and docs, visit http://www.interactivetools.com/
|
||||
|
||||
Version 3.0 developed by Mihai Bazon for InteractiveTools.
|
||||
http://students.infoiasi.ro/~mishoo
|
||||
|
||||
$Id$
|
||||
|
||||
-->
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<title>Spell Checker</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<script type="text/javascript" src="spell-check-ui.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
html, body { height: 100%; margin: 0px; padding: 0px; background-color: #fff;
|
||||
color: #000; }
|
||||
a:link, a:visited { color: #00f; text-decoration: none; }
|
||||
a:hover { color: #f00; text-decoration: underline; }
|
||||
|
||||
table { background-color: ButtonFace; color: ButtonText;
|
||||
font-family: tahoma,verdana,sans-serif; font-size: 11px; }
|
||||
|
||||
iframe { background-color: #fff; color: #000; }
|
||||
|
||||
.controls { width: 13em; }
|
||||
.controls .sectitle { /* background-color: #736c6c; color: #fff;
|
||||
border-top: 1px solid #000; border-bottom: 1px solid #fff; */
|
||||
text-align: center;
|
||||
font-weight: bold; padding: 2px 4px; }
|
||||
.controls .secbody { margin-bottom: 10px; }
|
||||
|
||||
button, select { font-family: tahoma,verdana,sans-serif; font-size: 11px; }
|
||||
button { width: 6em; padding: 0px; }
|
||||
|
||||
input, select { font-family: fixed,"andale mono",monospace; }
|
||||
|
||||
#v_currentWord { color: #f00; font-weight: bold; font-size: 120%; }
|
||||
#statusbar { padding: 7px 0px 0px 5px; }
|
||||
#status { font-weight: bold; }
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="initDocument()">
|
||||
|
||||
<form style="display: none;" action="spell-check-logic.cgi"
|
||||
method="post" target="framecontent"
|
||||
accept-charset="utf-8"
|
||||
><input type="hidden" name="content" id="f_content"
|
||||
/><input type="hidden" name="dictionary" id="f_dictionary"
|
||||
/><input type="hidden" name="init" id="f_init" value="1"
|
||||
/></form>
|
||||
|
||||
<table style="height: 100%; width: 100%; border-collapse: collapse;" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="2" style="height: 1em; padding: 2px;">
|
||||
<div style="float: right; padding: 2px;"><span>Dictionary</span>
|
||||
<select id="v_dictionaries" style="width: 10em"></select>
|
||||
<button id="b_recheck">Re-check</button>
|
||||
</div>
|
||||
<span id="status">Please wait. Calling spell checker.</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="controls">
|
||||
<div class="sectitle">Original word</div>
|
||||
<div class="secbody" id="v_currentWord" style="text-align: center">pliz weit ;-)</div>
|
||||
<div class="sectitle">Replace with</div>
|
||||
<div class="secbody">
|
||||
<input type="text" id="v_replacement" style="width: 94%; margin-left: 3%;" /><br />
|
||||
<div style="text-align: center; margin-top: 2px;">
|
||||
<button id="b_replace">Replace</button><button
|
||||
id="b_replall">Replace all</button><br /><button
|
||||
id="b_ignore">Ignore</button><button
|
||||
id="b_ignall">Ignore all</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sectitle">Suggestions</div>
|
||||
<div class="secbody">
|
||||
<select size="11" style="width: 94%; margin-left: 3%;" id="v_suggestions"></select>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<iframe src="about:blank" width="100%" height="100%"
|
||||
id="i_framecontent" name="framecontent"></iframe>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="height: 1em;" colspan="2">
|
||||
<div style="padding: 4px 2px 2px 2px; float: right;">
|
||||
<button id="b_ok">OK</button>
|
||||
<button id="b_cancel">Cancel</button>
|
||||
</div>
|
||||
<div id="statusbar"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,334 +0,0 @@
|
||||
// Spell Checker Plugin for HTMLArea-3.0
|
||||
// Implementation by Mihai Bazon. Sponsored by www.americanbible.org
|
||||
//
|
||||
// htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc.
|
||||
// This notice MUST stay intact for use (see license.txt).
|
||||
//
|
||||
// A free WYSIWYG editor replacement for <textarea> fields.
|
||||
// For full source code and docs, visit http://www.interactivetools.com/
|
||||
//
|
||||
// Version 3.0 developed by Mihai Bazon for InteractiveTools.
|
||||
// http://students.infoiasi.ro/~mishoo
|
||||
//
|
||||
// $Id$
|
||||
|
||||
// internationalization file was already loaded in parent ;-)
|
||||
var SpellChecker = window.opener.SpellChecker;
|
||||
var i18n = SpellChecker.I18N;
|
||||
|
||||
var is_ie = window.opener.HTMLArea.is_ie;
|
||||
var editor = SpellChecker.editor;
|
||||
var frame = null;
|
||||
var currentElement = null;
|
||||
var wrongWords = null;
|
||||
var modified = false;
|
||||
var allWords = {};
|
||||
|
||||
function makeCleanDoc(leaveFixed) {
|
||||
// document.getElementById("status").innerHTML = 'Please wait: rendering valid HTML';
|
||||
for (var i in wrongWords) {
|
||||
var el = wrongWords[i];
|
||||
if (!(leaveFixed && /HA-spellcheck-fixed/.test(el.className))) {
|
||||
el.parentNode.insertBefore(el.firstChild, el);
|
||||
el.parentNode.removeChild(el.nextSibling);
|
||||
el.parentNode.removeChild(el);
|
||||
} else {
|
||||
el.className = "HA-spellcheck-fixed";
|
||||
el.parentNode.removeChild(el.nextSibling);
|
||||
}
|
||||
}
|
||||
// we should use innerHTML here, but IE6's implementation fucks up the
|
||||
// HTML to such extent that our poor Perl parser doesn't understand it
|
||||
// anymore.
|
||||
return window.opener.HTMLArea.getHTML(frame.contentWindow.document.body, leaveFixed);
|
||||
};
|
||||
|
||||
function recheckClicked() {
|
||||
document.getElementById("status").innerHTML = i18n["Please wait: changing dictionary to"] + ': "' + document.getElementById("f_dictionary").value + '".';
|
||||
var field = document.getElementById("f_content");
|
||||
field.value = makeCleanDoc(true);
|
||||
field.form.submit();
|
||||
};
|
||||
|
||||
function saveClicked() {
|
||||
if (modified) {
|
||||
editor.setHTML(makeCleanDoc(false));
|
||||
}
|
||||
window.close();
|
||||
return false;
|
||||
};
|
||||
|
||||
function cancelClicked() {
|
||||
var ok = true;
|
||||
if (modified) {
|
||||
ok = confirm(i18n["QUIT_CONFIRMATION"]);
|
||||
}
|
||||
if (ok) {
|
||||
window.close();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
function replaceWord(el) {
|
||||
var replacement = document.getElementById("v_replacement").value;
|
||||
modified = (el.innerHTML != replacement);
|
||||
if (el) {
|
||||
el.className = el.className.replace(/\s*HA-spellcheck-(hover|fixed)\s*/g, " ");
|
||||
}
|
||||
el.className += " HA-spellcheck-fixed";
|
||||
el.__msh_fixed = true;
|
||||
if (!modified) {
|
||||
return false;
|
||||
}
|
||||
el.innerHTML = replacement;
|
||||
};
|
||||
|
||||
function replaceClicked() {
|
||||
replaceWord(currentElement);
|
||||
var start = currentElement.__msh_id;
|
||||
var index = start;
|
||||
do {
|
||||
++index;
|
||||
if (index == wrongWords.length) {
|
||||
index = 0;
|
||||
}
|
||||
} while ((index != start) && wrongWords[index].__msh_fixed);
|
||||
if (index == start) {
|
||||
index = 0;
|
||||
alert(i18n["Finished list of mispelled words"]);
|
||||
}
|
||||
wrongWords[index].onclick();
|
||||
return false;
|
||||
};
|
||||
|
||||
function replaceAllClicked() {
|
||||
var replacement = document.getElementById("v_replacement").value;
|
||||
var ok = true;
|
||||
var spans = allWords[currentElement.__msh_origWord];
|
||||
if (spans.length == 0) {
|
||||
alert("An impossible condition just happened. Call FBI. ;-)");
|
||||
} else if (spans.length == 1) {
|
||||
replaceClicked();
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
var message = "The word \"" + currentElement.__msh_origWord + "\" occurs " + spans.length + " times.\n";
|
||||
if (replacement == currentElement.__msh_origWord) {
|
||||
ok = confirm(message + "Ignore all occurrences?");
|
||||
} else {
|
||||
ok = confirm(message + "Replace all occurrences with \"" + replacement + "\"?");
|
||||
}
|
||||
*/
|
||||
if (ok) {
|
||||
for (var i in spans) {
|
||||
if (spans[i] != currentElement) {
|
||||
replaceWord(spans[i]);
|
||||
}
|
||||
}
|
||||
// replace current element the last, so that we jump to the next word ;-)
|
||||
replaceClicked();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
function ignoreClicked() {
|
||||
document.getElementById("v_replacement").value = currentElement.__msh_origWord;
|
||||
replaceClicked();
|
||||
return false;
|
||||
};
|
||||
|
||||
function ignoreAllClicked() {
|
||||
document.getElementById("v_replacement").value = currentElement.__msh_origWord;
|
||||
replaceAllClicked();
|
||||
return false;
|
||||
};
|
||||
|
||||
function learnClicked() {
|
||||
alert("Not [yet] implemented");
|
||||
return false;
|
||||
};
|
||||
|
||||
function internationalizeWindow() {
|
||||
var types = ["div", "span", "button"];
|
||||
for (var i in types) {
|
||||
var tag = types[i];
|
||||
var els = document.getElementsByTagName(tag);
|
||||
for (var j = els.length; --j >= 0;) {
|
||||
var el = els[j];
|
||||
if (el.childNodes.length == 1 && /\S/.test(el.innerHTML)) {
|
||||
var txt = el.innerHTML;
|
||||
if (typeof i18n[txt] != "undefined") {
|
||||
el.innerHTML = i18n[txt];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function initDocument() {
|
||||
internationalizeWindow();
|
||||
modified = false;
|
||||
frame = document.getElementById("i_framecontent");
|
||||
var field = document.getElementById("f_content");
|
||||
field.value = editor.getHTML();
|
||||
field.form.submit();
|
||||
document.getElementById("f_init").value = "0";
|
||||
|
||||
// assign some global event handlers
|
||||
|
||||
var select = document.getElementById("v_suggestions");
|
||||
select.onchange = function() {
|
||||
document.getElementById("v_replacement").value = this.value;
|
||||
};
|
||||
if (is_ie) {
|
||||
select.attachEvent("ondblclick", replaceClicked);
|
||||
} else {
|
||||
select.addEventListener("dblclick", replaceClicked, true);
|
||||
}
|
||||
|
||||
document.getElementById("b_replace").onclick = replaceClicked;
|
||||
// document.getElementById("b_learn").onclick = learnClicked;
|
||||
document.getElementById("b_replall").onclick = replaceAllClicked;
|
||||
document.getElementById("b_ignore").onclick = ignoreClicked;
|
||||
document.getElementById("b_ignall").onclick = ignoreAllClicked;
|
||||
document.getElementById("b_recheck").onclick = recheckClicked;
|
||||
|
||||
document.getElementById("b_ok").onclick = saveClicked;
|
||||
document.getElementById("b_cancel").onclick = cancelClicked;
|
||||
|
||||
select = document.getElementById("v_dictionaries");
|
||||
select.onchange = function() {
|
||||
document.getElementById("f_dictionary").value = this.value;
|
||||
};
|
||||
};
|
||||
|
||||
function wordClicked() {
|
||||
if (currentElement) {
|
||||
var a = allWords[currentElement.__msh_origWord];
|
||||
currentElement.className = currentElement.className.replace(/\s*HA-spellcheck-current\s*/g, " ");
|
||||
for (var i in a) {
|
||||
var el = a[i];
|
||||
if (el != currentElement) {
|
||||
el.className = el.className.replace(/\s*HA-spellcheck-same\s*/g, " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
currentElement = this;
|
||||
this.className += " HA-spellcheck-current";
|
||||
var a = allWords[currentElement.__msh_origWord];
|
||||
for (var i in a) {
|
||||
var el = a[i];
|
||||
if (el != currentElement) {
|
||||
el.className += " HA-spellcheck-same";
|
||||
}
|
||||
}
|
||||
document.getElementById("b_replall").disabled = (a.length <= 1);
|
||||
document.getElementById("b_ignall").disabled = (a.length <= 1);
|
||||
var txt;
|
||||
if (a.length == 1) {
|
||||
txt = "one occurrence";
|
||||
} else if (a.length == 2) {
|
||||
txt = "two occurrences";
|
||||
} else {
|
||||
txt = a.length + " occurrences";
|
||||
}
|
||||
document.getElementById("statusbar").innerHTML = "Found " + txt +
|
||||
' for word "<b>' + currentElement.__msh_origWord + '</b>"';
|
||||
var select = document.getElementById("v_suggestions");
|
||||
for (var i = select.length; --i >= 0;) {
|
||||
select.remove(i);
|
||||
}
|
||||
var suggestions;
|
||||
suggestions = this.nextSibling.firstChild.data.split(/,/);
|
||||
for (var i = 0; i < suggestions.length; ++i) {
|
||||
var txt = suggestions[i];
|
||||
var option = document.createElement("option");
|
||||
option.value = txt;
|
||||
option.appendChild(document.createTextNode(txt));
|
||||
select.appendChild(option);
|
||||
}
|
||||
document.getElementById("v_currentWord").innerHTML = this.__msh_origWord;
|
||||
if (suggestions.length > 0) {
|
||||
select.selectedIndex = 0;
|
||||
select.onchange();
|
||||
} else {
|
||||
document.getElementById("v_replacement").value = this.innerHTML;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
function wordMouseOver() {
|
||||
this.className += " HA-spellcheck-hover";
|
||||
};
|
||||
|
||||
function wordMouseOut() {
|
||||
this.className = this.className.replace(/\s*HA-spellcheck-hover\s*/g, " ");
|
||||
};
|
||||
|
||||
function finishedSpellChecking() {
|
||||
// initialization of global variables
|
||||
currentElement = null;
|
||||
wrongWords = null;
|
||||
allWords = {};
|
||||
|
||||
document.getElementById("status").innerHTML = "HTMLArea Spell Checker (<a href='readme-tech.html' target='_blank' title='Technical information'>info</a>)";
|
||||
var doc = frame.contentWindow.document;
|
||||
var spans = doc.getElementsByTagName("span");
|
||||
var sps = [];
|
||||
var id = 0;
|
||||
for (var i = 0; i < spans.length; ++i) {
|
||||
var el = spans[i];
|
||||
if (/HA-spellcheck-error/.test(el.className)) {
|
||||
sps.push(el);
|
||||
el.onclick = wordClicked;
|
||||
el.onmouseover = wordMouseOver;
|
||||
el.onmouseout = wordMouseOut;
|
||||
el.__msh_id = id++;
|
||||
var txt = (el.__msh_origWord = el.firstChild.data);
|
||||
el.__msh_fixed = false;
|
||||
if (typeof allWords[txt] == "undefined") {
|
||||
allWords[txt] = [el];
|
||||
} else {
|
||||
allWords[txt].push(el);
|
||||
}
|
||||
}
|
||||
}
|
||||
wrongWords = sps;
|
||||
if (sps.length == 0) {
|
||||
if (!modified) {
|
||||
alert(i18n["NO_ERRORS_CLOSING"]);
|
||||
window.close();
|
||||
} else {
|
||||
alert(i18n["NO_ERRORS"]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
(currentElement = sps[0]).onclick();
|
||||
var as = doc.getElementsByTagName("a");
|
||||
for (var i = as.length; --i >= 0;) {
|
||||
var a = as[i];
|
||||
a.onclick = function() {
|
||||
if (confirm(i18n["CONFIRM_LINK_CLICK"] + ":\n" +
|
||||
this.href + "\n" + i18n["I will open it in a new page."])) {
|
||||
window.open(this.href);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
var dicts = doc.getElementById("HA-spellcheck-dictionaries");
|
||||
if (dicts) {
|
||||
dicts.parentNode.removeChild(dicts);
|
||||
dicts = dicts.innerHTML.split(/,/);
|
||||
var select = document.getElementById("v_dictionaries");
|
||||
for (var i = select.length; --i >= 0;) {
|
||||
select.remove(i);
|
||||
}
|
||||
for (var i = 0; i < dicts.length; ++i) {
|
||||
var txt = dicts[i];
|
||||
var option = document.createElement("option");
|
||||
option.value = txt;
|
||||
option.appendChild(document.createTextNode(txt));
|
||||
select.appendChild(option);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,72 +0,0 @@
|
||||
// Spell Checker Plugin for HTMLArea-3.0
|
||||
// Implementation by Mihai Bazon. Sponsored by www.americanbible.org
|
||||
//
|
||||
// htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc.
|
||||
// This notice MUST stay intact for use (see license.txt).
|
||||
//
|
||||
// A free WYSIWYG editor replacement for <textarea> fields.
|
||||
// For full source code and docs, visit http://www.interactivetools.com/
|
||||
//
|
||||
// Version 3.0 developed by Mihai Bazon for InteractiveTools.
|
||||
// http://students.infoiasi.ro/~mishoo
|
||||
//
|
||||
// $Id$
|
||||
|
||||
function SpellChecker(editor) {
|
||||
this.editor = editor;
|
||||
|
||||
var cfg = editor.config;
|
||||
var tt = SpellChecker.I18N;
|
||||
var bl = SpellChecker.btnList;
|
||||
var self = this;
|
||||
|
||||
// register the toolbar buttons provided by this plugin
|
||||
var toolbar = [];
|
||||
for (var i in bl) {
|
||||
var btn = bl[i];
|
||||
if (!btn) {
|
||||
toolbar.push("separator");
|
||||
} else {
|
||||
var id = "SC-" + btn[0];
|
||||
cfg.registerButton(id, tt[id], "plugins/SpellChecker/img/" + btn[0] + ".gif", false,
|
||||
function(editor, id) {
|
||||
// dispatch button press event
|
||||
self.buttonPress(editor, id);
|
||||
}, btn[1]);
|
||||
toolbar.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in toolbar) {
|
||||
cfg.toolbar[0].push(toolbar[i]);
|
||||
}
|
||||
};
|
||||
|
||||
SpellChecker.btnList = [
|
||||
null, // separator
|
||||
["spell-check"]
|
||||
];
|
||||
|
||||
SpellChecker.prototype.buttonPress = function(editor, id) {
|
||||
switch (id) {
|
||||
case "SC-spell-check":
|
||||
SpellChecker.editor = editor;
|
||||
SpellChecker.init = true;
|
||||
var uiurl = editor.config.editorURL + "plugins/SpellChecker/spell-check-ui.html";
|
||||
var win;
|
||||
if (HTMLArea.is_ie) {
|
||||
win = window.open(uiurl, "SC_spell_checker",
|
||||
"toolbar=no,location=no,directories=no,status=no,menubar=no," +
|
||||
"scrollbars=no,resizable=yes,width=600,height=400");
|
||||
} else {
|
||||
win = window.open(uiurl, "SC_spell_checker",
|
||||
"toolbar=no,menubar=no,personalbar=no,width=600,height=400," +
|
||||
"scrollbars=no,resizable=yes");
|
||||
}
|
||||
win.focus();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// this needs to be global, it's accessed from spell-check-ui.html
|
||||
SpellChecker.editor = null;
|
||||
Reference in New Issue
Block a user