]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/jslib.js
Fix idle time display.
[irc/quakenet/qwebirc.git] / js / jslib.js
index a1e88c4629bb0e0b12d42c923da5058b7cd4ce26..dd828df1425c1c4474d907ebf05e26078a102cbe 100644 (file)
@@ -30,7 +30,7 @@ String.prototype.splitMax = function(by, max) {
   return newitems;
 }
 
-function setAtEnd(obj) {
+qwebirc.util.setAtEnd = function(obj) {
   pos = obj.value.length;
   
   if(obj.createTextRange) { 
@@ -44,7 +44,7 @@ function setAtEnd(obj) {
 }
 
 /* returns the arguments */
-function parseURI(uri) {
+qwebirc.util.parseURI = function(uri) {
   var result = {}
 
   var start = uri.indexOf('?');
@@ -65,3 +65,58 @@ function parseURI(uri) {
   
   return result;
 }
+
+qwebirc.util.DaysOfWeek = {
+  0: "Sun",
+  1: "Mon",
+  2: "Tue",
+  3: "Wed",
+  4: "Thu",
+  5: "Fri",
+  6: "Sat"
+};
+
+qwebirc.util.MonthsOfYear = {
+  0: "Jan",
+  1: "Feb",
+  2: "Mar",
+  3: "Apr",
+  4: "May",
+  5: "Jun",
+  6: "Jul",
+  7: "Aug",
+  8: "Sep",
+  9: "Oct",
+  10: "Nov",
+  11: "Dec"
+};
+
+qwebirc.util.NBSPCreate = function(text, element) {
+  var e = text.split("  ");
+  for(var i=0;i<e.length;i++) {
+    var tn = document.createTextNode(e[i]);
+    element.appendChild(tn);
+    
+    if(i != e.length - 1) {
+      var e2 = new Element("span");
+      e2.set("html", "&nbsp;&nbsp;");
+      element.appendChild(e2);
+    }
+  }
+};
+
+qwebirc.util.longtoduration = function(l) {
+  var seconds = l % 60;
+  var minutes = Math.round(l / 60);
+  var hours = Math.round(minutes / 60);
+  var days = Math.round(hours / 24);
+  
+  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
+}