X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/blobdiff_plain/a9cbd00d54dfbb0a126a6a85d072fb2cc88577f4..ea29e3d77bb6b6f11545dd02a43883def07ea869:/js/jslib.js diff --git a/js/jslib.js b/js/jslib.js index ba9acf0..67a26ff 100644 --- a/js/jslib.js +++ b/js/jslib.js @@ -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; @@ -40,7 +41,7 @@ String.prototype.splitMax = function(by, max) { /* returns the arguments */ qwebirc.util.parseURI = function(uri) { - var result = {} + var result = new QHash(); var start = uri.indexOf('?'); if(start == -1) @@ -55,11 +56,11 @@ qwebirc.util.parseURI = function(uri) { if(r.length < 2) continue; - result[unescape(r[0])] = unescape(r[1]); + result.put(unescape(r[0]), unescape(r[1])); } return result; -} +}; qwebirc.util.DaysOfWeek = { 0: "Sun", @@ -117,15 +118,33 @@ 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(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); +}; + +RegExp.fromIRCPattern = function(t) { + /* escape everything but ? . and * */ + var t = t.replace(/[-[\]{}()+,\\^$|#\s]/g, "\\$&"); + t = t.split(""); + var out = []; + + /* now process the rest */ + for(var i=0;i")); - } 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("")); + } 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;