From 9af6e647b56056230f069dbb99935ae7402210fd Mon Sep 17 00:00:00 2001
From: andi <andi@splitbrain.org>
Date: Fri, 10 Jun 2005 01:36:43 +0200
Subject: [PATCH] Added option to manually change a misspelled word

darcs-hash:20050609233643-9977f-11492f9b23b5e553ad6322bcd046ff32d64c37c1.gz
---
 inc/html.php              |  2 +-
 inc/lang/de/lang.php      | 11 ++++++-----
 inc/lang/en/lang.php      | 11 ++++++-----
 lib/scripts/spellcheck.js | 25 ++++++++++++++++++++++---
 4 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/inc/html.php b/inc/html.php
index 48881b85b..a9135e155 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -914,7 +914,7 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
 
             //initialize spellchecker
             <?if($conf['spellchecker']){?>
-              ajax_spell.init('<?=$lang['spell_start']?>','<?=$lang['spell_stop']?>','<?=$lang['spell_wait']?>','<?=$lang['spell_noerr']?>','<?=$lang['spell_nosug']?>');
+              ajax_spell.init('<?=$lang['spell_start']?>','<?=$lang['spell_stop']?>','<?=$lang['spell_wait']?>','<?=$lang['spell_noerr']?>','<?=$lang['spell_nosug']?>','<?=$lang['spell_change']?>');
             <?}?>
 
             document.editform.wikitext.focus();
diff --git a/inc/lang/de/lang.php b/inc/lang/de/lang.php
index 325e46044..df7e71e7c 100644
--- a/inc/lang/de/lang.php
+++ b/inc/lang/de/lang.php
@@ -130,10 +130,11 @@ $lang['acl_perm8']  = 'Hochladen';
 $lang['acl_perm16'] = 'Entfernen';
 $lang['acl_new']    = 'Eintrag hinzufügen';
 
-$lang['spell_start']= 'Rechtschreibung prüfen';
-$lang['spell_stop'] = 'Bearbeiten fortsetzen';
-$lang['spell_wait'] = 'Bitte warten...';
-$lang['spell_noerr']= 'Keine Fehler gefunden';
-$lang['spell_nosug']= 'Keine Vorschläge';
+$lang['spell_start'] = 'Rechtschreibung prüfen';
+$lang['spell_stop']  = 'Bearbeiten fortsetzen';
+$lang['spell_wait']  = 'Bitte warten...';
+$lang['spell_noerr'] = 'Keine Fehler gefunden';
+$lang['spell_nosug'] = 'Keine Vorschläge';
+$lang['spell_change']= 'Ändern';
 
 //Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index 385e5a7e0..e0219feea 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -129,10 +129,11 @@ $lang['acl_perm8']  = 'Upload';
 $lang['acl_perm16'] = 'Delete';
 $lang['acl_new']    = 'Add new Entry';
 
-$lang['spell_start']= 'Check Spelling';
-$lang['spell_stop'] = 'Resume Editing';
-$lang['spell_wait'] = 'Please wait...';
-$lang['spell_noerr']= 'No Mistakes found';
-$lang['spell_nosug']= 'No Suggestions';
+$lang['spell_start'] = 'Check Spelling';
+$lang['spell_stop']  = 'Resume Editing';
+$lang['spell_wait']  = 'Please wait...';
+$lang['spell_noerr'] = 'No Mistakes found';
+$lang['spell_nosug'] = 'No Suggestions';
+$lang['spell_change']= 'Change';
 
 //Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/lib/scripts/spellcheck.js b/lib/scripts/spellcheck.js
index 06ba49c0d..b5fa35e60 100644
--- a/lib/scripts/spellcheck.js
+++ b/lib/scripts/spellcheck.js
@@ -114,6 +114,7 @@ function ajax_spell_class(){
   this.txtRun   = 'Checking...';
   this.txtNoErr = 'No Mistakes';
   this.txtNoSug = 'No Suggestions';
+  this.txtChange= 'Change';
 
 
   /**
@@ -123,7 +124,7 @@ function ajax_spell_class(){
    *
    * @author Andreas Gohr <andi@splitbrain.org>
    */
-  this.init = function(txtStart,txtStop,txtRun,txtNoErr,txtNoSug){
+  this.init = function(txtStart,txtStop,txtRun,txtNoErr,txtNoSug,txtChange){
      // don't run twice
     if (this.inited) return;
     this.inited = true;
@@ -145,6 +146,7 @@ function ajax_spell_class(){
     this.txtRun   = txtRun;
     this.txtNoErr = txtNoErr; 
     this.txtNoSug = txtNoSug;
+    this.txtChange= txtChange;
 
     // register click event
     document.onclick = this.docClick;
@@ -214,6 +216,19 @@ function ajax_spell_class(){
     this.suggestObj.style.display = "none";
   } 
 
+  /**
+   * Opens a prompt to let the user change the word her self
+   * 
+   * @author Andreas Gohr <andi@splitbrain.org>
+   */
+  this.ask = function(id){
+    var word = document.getElementById('spell_error'+id).innerHTML;
+    word = prompt(this.txtChange,word);
+    if(word){
+      this.correct(id,encodeURIComponent(word));
+    }
+  }
+
   /**
    * Displays the suggestions for a misspelled word
    *
@@ -243,15 +258,19 @@ function ajax_spell_class(){
     // handle suggestions
     var text = '';
     if(args.length == 1){
-      text += this.txtNoSug;
+      text += this.txtNoSug+'<br />';
     }else{
       for(var i=1; i<args.length; i++){
         text += '<a href="javascript:ajax_spell.correct('+id+',\''+
                 qquote(encodeURIComponent(args[i]))+'\')">';
         text += args[i];
-        text += '</a><br>';
+        text += '</a><br />';
       }
     }
+    // add option for manual edit
+    text += '<a href="javascript:ajax_spell.ask('+id+')">';
+    text += '['+this.txtChange+']';
+    text += '</a><br />';
 
     this.suggestObj.innerHTML = text;
     this.suggestObj.style.display = "block";
-- 
GitLab