/* 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;
}
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) {
} 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;