X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/blobdiff_plain/a9cbd00d54dfbb0a126a6a85d072fb2cc88577f4..0fc80ad2b9b14a97062e2a7eca6117f09f3234d2:/js/jslib.js
diff --git a/js/jslib.js b/js/jslib.js
index ba9acf0..89f64ec 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";
+ 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 = $(document.createElement(""));
- } else {
- 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;
-}
-
-/* From: www.webtoolkit.info */
-qwebirc.util.b64Table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
-qwebirc.util.b64Encode = function(data) {
- var output = [];
- var table = qwebirc.util.b64Table;
- for(var i=0;i> 2;
- var enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
- var enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
- var enc4 = chr3 & 63;
-
- if(isNaN(chr2)) {
- enc3 = enc4 = 64;
- } else if(isNaN(chr3)) {
- enc4 = 64;
- }
- output.push(table.charAt(enc1) + table.charAt(enc2) + table.charAt(enc3) + table.charAt(enc4));
+ if(!created) {
+ r = new Element("input");
+ r.setAttribute("type", type);
}
- return output.join("");
-}
-
-/* From: www.webtoolkit.info */
-qwebirc.util.b64Decode = function(data) {
- data = data.replace(/[^A-Za-z0-9\+\/\=]/g, "");
-
- var output = [];
- var table = qwebirc.util.b64Table;
-
- /* grossly inefficient... so sue me */
- while(data.length % 4 != 0)
- data = data + "=";
-
- for(var i=0;i> 4);
- var chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
- var chr3 = ((enc3 & 3) << 6) | enc4;
-
- output.push(String.fromCharCode(chr1));
- if (enc3 != 64)
- output.push(String.fromCharCode(chr2));
- if (enc4 != 64)
- output.push(String.fromCharCode(chr3));
+ if(name)
+ r.setAttribute("name", name);
+ if(id)
+ r.setAttribute("id", id);
+ if(selected) {
+ r.setAttribute("checked", "checked");
+ if(type == "radio" && Browser.Engine.trident)
+ r.setAttribute("defaultChecked", "defaultChecked");
}
- return output.join("");
+ parent.appendChild(r);
+ return r;
}
qwebirc.util.composeAnd = function() {
@@ -380,4 +363,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