X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/blobdiff_plain/f139851349a1bbc8cba95689699e254bd100bb2e..015ab79ac65cca3c99282e6c735412131f92e4f9:/js/jslib.js diff --git a/js/jslib.js b/js/jslib.js index 589baa9..1094ff2 100644 --- a/js/jslib.js +++ b/js/jslib.js @@ -41,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) @@ -56,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", @@ -119,6 +119,32 @@ qwebirc.util.pad = function(x) { RegExp.escape = function(text) { 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")); - } catch(e) { + var h = ""; + r = $(document.createElement(h)); + if (type == "radio") { + r.addEvent("click", function () { + $(document.body).getElements("input[name=" + name + "]").forEach(function (x) { + x.setAttribute("defaultChecked", x.checked ? "defaultChecked" : ""); + }); + }); + } + created = true; + } catch (e) { /* fallthough, trying it the proper way... */ } } - - r = new Element("input"); - r.type = type; + + if(!created) { + r = new Element("input"); + r.setAttribute("type", type); + } if(name) - r.name = name; + r.setAttribute("name", name); if(id) - r.id = id; - - if(selected) - r.checked = true; - + r.setAttribute("id", id); + if(selected) { + r.setAttribute("checked", "checked"); + if(type == "radio" && Browser.Engine.trident) + r.setAttribute("defaultChecked", "defaultChecked"); + } + parent.appendChild(r); return r; } @@ -377,4 +420,38 @@ qwebirc.util.deviceHasKeyboard = function() { qwebirc.util.generateID_ID = 0; qwebirc.util.generateID = function() { return "qqa-" + qwebirc.util.generateID_ID++; -} \ No newline at end of file +}; + +qwebirc.util.arrayCmp = function(a, b) { + for(var p=0;p