Revision: 46108
Author:   werdna
Date:     2009-01-23 23:35:26 +0000 (Fri, 23 Jan 2009)

Log Message:
-----------
Focus the code box, and place the cursor at the location of an error, when one 
occurs. Works on FireFox and Safari, but not IE.

Modified Paths:
--------------
    trunk/extensions/AbuseFilter/edit.js

Modified: trunk/extensions/AbuseFilter/edit.js
===================================================================
--- trunk/extensions/AbuseFilter/edit.js        2009-01-23 23:12:27 UTC (rev 
46107)
+++ trunk/extensions/AbuseFilter/edit.js        2009-01-23 23:35:26 UTC (rev 
46108)
@@ -21,6 +21,19 @@
                var error = response.substr(4);
                changeText( el, 'Syntax error: '+error );
                el.syntaxOk = false;
+
+               var charRegex = /at char (\d+)/;
+               if ( charRegex.test( error ) ) {
+                       var charArray = charRegex.exec( error );
+                       var position = charArray[1];
+                       var textArea = document.getElementById( wgFilterBoxName 
);
+
+                       if (textArea.selectionStart && textArea.selectionEnd) {
+                               textArea.selectionStart = position;
+                               textArea.selectionEnd = position;
+                               textArea.focus();
+                       }
+               }
        }
 }
 



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to