return newitems;
}
-
/* returns the arguments */
qwebirc.util.parseURI = function(uri) {
- var result = {}
+ var result = new QHash();
var start = uri.indexOf('?');
if(start == -1)
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",
return this.substring(0, what.length) == what;
}
+String.prototype.endsWith = function(what) {
+ return this.substring(this.length - what.length, this.length) == what;
+};
+
/* NOT cryptographically secure! */
qwebirc.util.randHexString = function(numBytes) {
var getByte = function() {
}
qwebirc.util.createInput = function(type, parent, name, selected, id) {
+ var created = false;
var r;
- if(Browser.Engine.trident) {
- if(name) {
- name = " name=\"" + escape(name) + "\"";
- } else {
- name = "";
- }
- if(id) {
- id = " id=\"" + escape(id) + "\"";
+ if (name)
+ name = "__input" + name;
+
+ if (Browser.Engine.trident) {
+ var name2;
+ if (name) {
+ name2 = " name=\"" + escape(name) + "\"";
} else {
- id = "";
+ name2 = "";
}
try {
- return $(document.createElement("<input type=\"" + type + "\"" + name + id + " " + (selected?" checked":"") + "/>"));
- } catch(e) {
+ var h = "<input type=\"" + type + "\"" + name2 + "/>";
+ 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;
}
qwebirc.util.generateID_ID = 0;
qwebirc.util.generateID = function() {
return "qqa-" + qwebirc.util.generateID_ID++;
-}
\ No newline at end of file
+}
+
+qwebirc.util.__log = function(x) {
+ if(QWEBIRC_DEBUG) {
+ if(typeof console == "undefined") {
+ alert("log: " + x);
+ } else {
+ console.log(x);
+ }
+ }
+};
+
+qwebirc.util.logger = {
+ log: function(x) { qwebirc.util.__log("L " + x) },
+ info: function(x) { qwebirc.util.__log("I " + x) },
+ error: function(x) { qwebirc.util.__log("E " + x) },
+ warn: function(x) { qwebirc.util.__log("W " + x) }
+};
+
+qwebirc.util.log = qwebirc.util.logger.log;