summaryrefslogtreecommitdiff
path: root/lib/scripts/spellcheck.js
diff options
context:
space:
mode:
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";