]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/jslib.js
Merge.
[irc/quakenet/qwebirc.git] / js / jslib.js
index ba9acf0e3478d188f1b1f562334dee79e4708552..589baa9e035b5aa10b13c88ed8bae2ec3a2ce2b7 100644 (file)
@@ -17,6 +17,7 @@ qwebirc.util.dictCopy = function(d) {
 
 /* how horribly inefficient */
 String.prototype.replaceAll = function(f, t) {
+  //return new RegExp("/" + RegExp.escape(f) + "/g").replace(f, RegExp.escape(t));
   var i = this.indexOf(f);
   var c = this;
  
@@ -117,15 +118,7 @@ qwebirc.util.pad = function(x) {
 }
 
 RegExp.escape = function(text) {
-  if(!arguments.callee.sRE) {
-    var specials = [
-      '/', '.', '*', '+', '?', '|',
-      '(', ')', '[', ']', '{', '}', '\\'
-    ];
-    arguments.callee.sRE = new RegExp('(\\' + specials.join('|\\') + ')', 'g');
-  }
-  
-  return text.replace(arguments.callee.sRE, '\\$1');
+  return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
 }
 
 qwebirc.ui.insertAt = function(position, parent, element) {
@@ -251,18 +244,22 @@ qwebirc.util.createInput = function(type, parent, name, selected, id) {
     } else {
       id = "";
     }
-    r = $(document.createElement("<input type=\"" + type + "\"" + name + id + " " + (selected?" checked":"") + "/>"));
-  } else {    
-    r = new Element("input");
-    r.type = type;
-    if(name)
-      r.name = name;
-    if(id)
-      r.id = id;
-      
-    if(selected)
-      r.checked = true;
+    try {
+      return $(document.createElement("<input type=\"" + type + "\"" + name + id + " " + (selected?" checked":"") + "/>"));
+    } catch(e) {
+      /* fallthough, trying it the proper way... */
+    }
   }
+  
+  r = new Element("input");
+  r.type = type;
+  if(name)
+    r.name = name;
+  if(id)
+    r.id = id;
+      
+  if(selected)
+    r.checked = true;
     
   parent.appendChild(r);
   return r;