summaryrefslogtreecommitdiff
path: root/lib/scripts
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-06-09 18:19:58 +0200
committerandi <andi@splitbrain.org>2005-06-09 18:19:58 +0200
commit109b12a10cb9d800ed5952d1dd0d6c676872051f (patch)
treeba318b56a195998f48ad42c8f28388c16c92c9eb /lib/scripts
parentf6d08865755f76c19882dd79a2a5e441c7a835a7 (diff)
downloadrpg-109b12a10cb9d800ed5952d1dd0d6c676872051f.tar.gz
rpg-109b12a10cb9d800ed5952d1dd0d6c676872051f.tar.bz2
proper quoting of single quotes in spellcheck
darcs-hash:20050609161958-9977f-3758f980d3e4f452b7792c70fb3caba2f05cfa84.gz
Diffstat (limited to 'lib/scripts')
-rw-r--r--lib/scripts/spellcheck.js93
1 files changed, 51 insertions, 42 deletions
diff --git a/lib/scripts/spellcheck.js b/lib/scripts/spellcheck.js
index feeeb0967..06ba49c0d 100644
--- a/lib/scripts/spellcheck.js
+++ b/lib/scripts/spellcheck.js
@@ -80,6 +80,14 @@ function findPosY(object){
return curtop;
} //end findPosY function
+/**
+ * quotes single quotes
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function qquote(str){
+ return str.split('\'').join('\\\'');
+}
/**
* AJAX Spellchecker Class
@@ -201,11 +209,53 @@ function ajax_spell_class(){
*/
this.correct = function (id, word){
var obj = document.getElementById('spell_error'+id);
- obj.innerHTML = decodeURI(word);
+ obj.innerHTML = decodeURIComponent(word);
obj.style.color = "#005500";
this.suggestObj.style.display = "none";
}
+ /**
+ * Displays the suggestions for a misspelled word
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @author Garrison Locke <http://www.broken-notebook.com>
+ */
+ this.suggest = function(){
+ var args = this.suggest.arguments;
+ if(!args[0]) return;
+ var id = args[0];
+
+ // set position of the popup
+ this.suggestObj.style.display = "none";
+ var x = findPosX('spell_error'+id);
+ var y = findPosY('spell_error'+id);
+
+ // handle scrolling
+ if(is_opera){
+ var scrollPos = 0; //FIXME how to do this without browser sniffing?
+ }else{
+ var scrollPos = this.showboxObj.scrollTop;
+ }
+
+ this.suggestObj.style.left = x+'px';
+ this.suggestObj.style.top = (y+16-scrollPos)+'px';
+
+ // handle suggestions
+ var text = '';
+ if(args.length == 1){
+ text += this.txtNoSug;
+ }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>';
+ }
+ }
+
+ this.suggestObj.innerHTML = text;
+ this.suggestObj.style.display = "block";
+ }
// --- Callbacks ---
@@ -290,47 +340,6 @@ function ajax_spell_class(){
}
}
- /**
- * Displays the suggestions for a misspelled word
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @author Garrison Locke <http://www.broken-notebook.com>
- */
- this.suggest = function(){
- var args = this.suggest.arguments;
- if(!args[0]) return;
- var id = args[0];
-
- // set position of the popup
- this.suggestObj.style.display = "none";
- var x = findPosX('spell_error'+id);
- var y = findPosY('spell_error'+id);
-
- // handle scrolling
- if(is_opera){
- var scrollPos = 0; //FIXME how to do this without browser sniffing?
- }else{
- var scrollPos = this.showboxObj.scrollTop;
- }
-
- this.suggestObj.style.left = x+'px';
- this.suggestObj.style.top = (y+16-scrollPos)+'px';
-
- // handle suggestions
- var text = '';
- if(args.length == 1){
- text += this.txtNoSug;
- }else{
- for(var i=1; i<args.length; i++){
- text += '<a href="javascript:ajax_spell.correct('+id+',\''+encodeURIComponent(args[i])+'\')">';
- text += args[i];
- text += '</a><br>';
- }
- }
-
- this.suggestObj.innerHTML = text;
- this.suggestObj.style.display = "block";
- }
}
// create the global object