]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - static/js/jslib.js
Add command parsing and lots of other stuff...
[irc/quakenet/qwebirc.git] / static / js / jslib.js
index 5742b034759540adab655118c87e3b5dedcb481d..107dca2e4169584ce039157f2cc6bf6e3ba8d83c 100644 (file)
@@ -53,3 +53,52 @@ String.prototype.replaceAll = function(f, t) {
   }\r
   return c;\r
 }\r
+\r
+/* how horribly inefficient (again) */\r
+String.prototype.splitMax = function(by, max) {\r
+  var items = this.split(by);\r
+  var newitems = items.slice(0, max-1);\r
+\r
+  if(items.length >= max)\r
+    newitems.push(items.slice(max-1).join(by));\r
+  \r
+  return newitems;\r
+}\r
+\r
+alert("a".splitMax(" ", 2));\r
+alert("a b".splitMax(" ", 2));\r
+alert("a b c".splitMax(" ", 2));\r
+alert("a b".splitMax(" ", 3));\r
+alert("a b c".splitMax(" ", 3));\r
+alert("a".splitMax(" ", 4));\r
+alert("a b".splitMax(" ", 4));\r
+alert("a b c".splitMax(" ", 4));\r
+alert("a".splitMax(" ", 1));\r
+alert("a b".splitMax(" ", 1));\r
+alert("a b c".splitMax(" ", 1));\r
+\r
+DaysOfWeek = {\r
+  0: "Sun",\r
+  1: "Mon",\r
+  2: "Tue",\r
+  3: "Wed",\r
+  4: "Thu",\r
+  5: "Fri",\r
+  6: "Sat"\r
+}\r
+\r
+MonthsOfYear = {\r
+  0: "Jan",\r
+  1: "Feb",\r
+  2: "Mar",\r
+  3: "Apr",\r
+  4: "May",\r
+  5: "Jun",\r
+  6: "Jul",\r
+  7: "Aug",\r
+  8: "Sep",\r
+  9: "Oct",\r
+  10: "Nov",\r
+  11: "Dec"\r
+}\r
+\r