X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/blobdiff_plain/91743bbe8dc5e7a31efd52d1e7d309aca8c492b6..2126d43f70fbd806109bb80d7e133d75fac1c6c2:/js/jslib.js
diff --git a/js/jslib.js b/js/jslib.js
index 52e3550..1094ff2 100644
--- a/js/jslib.js
+++ b/js/jslib.js
@@ -223,6 +223,10 @@ String.prototype.startsWith = function(what) {
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() {
@@ -258,35 +262,48 @@ qwebirc.util.importJS = function(name, watchFor, onload) {
}
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(""));
- } 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;
}
@@ -403,7 +420,22 @@ qwebirc.util.deviceHasKeyboard = function() {
qwebirc.util.generateID_ID = 0;
qwebirc.util.generateID = function() {
return "qqa-" + qwebirc.util.generateID_ID++;
-}
+};
+
+qwebirc.util.arrayCmp = function(a, b) {
+ for(var p=0;p