summaryrefslogtreecommitdiff
path: root/lib/scripts/spellcheck.js
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-06-10 01:36:43 +0200
committerandi <andi@splitbrain.org>2005-06-10 01:36:43 +0200
commit9af6e647b56056230f069dbb99935ae7402210fd (patch)
treed49b68bc616b5938a89e30a3c03867c941d450df /lib/scripts/spellcheck.js
parentd8681a9e775f904d35aa033a84ef569e1df09ac1 (diff)
downloadrpg-9af6e647b56056230f069dbb99935ae7402210fd.tar.gz
rpg-9af6e647b56056230f069dbb99935ae7402210fd.tar.bz2
Added option to manually change a misspelled word
darcs-hash:20050609233643-9977f-11492f9b23b5e553ad6322bcd046ff32d64c37c1.gz
Diffstat (limited to 'lib/scripts/spellcheck.js')
-rw-r--r--lib/scripts/spellcheck.js25
1 files changed, 22 insertions, 3 deletions
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;
@@ -215,6 +217,19 @@ function ajax_spell_class(){
}
/**
+ * 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
*
* @author Andreas Gohr <andi@splitbrain.org>
@@ -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";