X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/blobdiff_plain/c1416a8d47a7e82195748220c3edcc4aa6bb9871..fc38a626f228cb10e6d5b5bf38594a71680944f4:/js/jslib.js diff --git a/js/jslib.js b/js/jslib.js index b61038d..589baa9 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; @@ -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) { @@ -238,7 +231,7 @@ qwebirc.util.importJS = function(name, watchFor, onload) { document.getElementsByTagName("head")[0].appendChild(script); } -qwebirc.util.createInput = function(type, parent, name, selected) { +qwebirc.util.createInput = function(type, parent, name, selected, id) { var r; if(Browser.Engine.trident) { if(name) { @@ -246,16 +239,27 @@ qwebirc.util.createInput = function(type, parent, name, selected) { } else { name = ""; } - r = $(document.createElement("")); - } else { - r = new Element("input"); - r.type = type; - if(name) - r.name = name; - - if(selected) - r.checked = true; + if(id) { + id = " id=\"" + escape(id) + "\""; + } else { + id = ""; + } + 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; @@ -293,6 +297,11 @@ qwebirc.util.b64Decode = function(data) { var output = []; var table = qwebirc.util.b64Table; + + /* grossly inefficient... so sue me */ + while(data.length % 4 != 0) + data = data + "="; + for(var i=0;i