X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/blobdiff_plain/29453513873e27b37d877a42fa5090bddab5fd02..fc38a626f228cb10e6d5b5bf38594a71680944f4:/js/jslib.js?ds=sidebyside
diff --git a/js/jslib.js b/js/jslib.js
index e58bd95..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;
@@ -102,9 +103,9 @@ qwebirc.util.NBSPCreate = function(text, element) {
qwebirc.util.longtoduration = function(l) {
var seconds = l % 60;
- var minutes = Math.round((l % 3600) / 60);
- var hours = Math.round((l % (3600 * 24)) / 3600);
- var days = Math.round(l / (24*3600));
+ var minutes = Math.floor((l % 3600) / 60);
+ var hours = Math.floor((l % (3600 * 24)) / 3600);
+ var days = Math.floor(l / (24*3600));
return days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds";
}
@@ -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 -1;
+ }
+
+ for(var i=0;i