return p[d];
}
+qwebirc.util.dictCopy = function(d) {
+ var n = {};
+ for(var k in d)
+ n[k] = d[k];
+
+ return n;
+}
+
/* how horribly inefficient */
String.prototype.replaceAll = function(f, t) {
var i = this.indexOf(f);
qwebirc.util.longtoduration = function(l) {
var seconds = l % 60;
- var minutes = l / 60;
- var hours = minutes / 60;
- var days = hours / 24;
+ var minutes = Math.round((l % 3600) / 60);
+ var hours = Math.round((l % (3600 * 24)) / 3600);
+ var days = Math.round(l / (24*3600));
return days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds";
}
+
+qwebirc.util.pad = function(x) {
+ x = "" + x;
+ if(x.length == 1)
+ return "0" + x;
+ return 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');
+}
\ No newline at end of file