Tabview.getServerTab().addMsg(null, data.server, data.msg, 'motd');\r
},\r
onWhois: function (e, data) {\r
- var d, tab;\r
+ var d, tab, idle_time = '';\r
+\r
+ if (data.end) return;\r
+\r
+ if (typeof data.idle !== 'undefined'){\r
+ idle_time = secondsToTime(parseInt(data.idle, 10));\r
+ idle_time = idle_time.h.toString().lpad(2, "0") + ':' + idle_time.m.toString().lpad(2, "0") + ':' + idle_time.s.toString().lpad(2, "0");\r
+ }\r
+\r
tab = Tabview.getCurrentTab();\r
if (data.msg) {\r
tab.addMsg(null, data.nick, data.msg, 'whois');\r
d = new Date();\r
d.setTime(data.logon * 1000);\r
d = d.toLocaleString();\r
- tab.addMsg(null, data.nick, 'idle for ' + data.idle + ' second' + ((data.idle !== 1) ? 's' : '') + ', signed on ' + d, 'whois');\r
+\r
+ tab.addMsg(null, data.nick, 'idle for ' + idle_time + ', signed on ' + d, 'whois');\r
} else {\r
- tab.addMsg(null, data.nick, 'idle for ' + data.idle + ' seconds', 'whois');\r
+ tab.addMsg(null, data.nick, 'idle for ' + idle_time, 'whois');\r
}\r
},\r
onMode: function (e, data) {\r
}
+
+function secondsToTime(secs){
+ var hours = Math.floor(secs / (60 * 60));
+
+ var divisor_for_minutes = secs % (60 * 60);
+ var minutes = Math.floor(divisor_for_minutes / 60);
+
+ var divisor_for_seconds = divisor_for_minutes % 60;
+ var seconds = Math.ceil(divisor_for_seconds);
+
+ var obj = {
+ "h": hours,
+ "m": minutes,
+ "s": seconds
+ };
+ return obj;
+}
+
+
/*
PLUGINS
Each function in each object is looped through and ran. The resulting text
this.parseIRCMessage = function (websocket, ircSocket, data) {
/*global ircSocketDataHandler */
- var msg, regex, opts, options, opt, i, j, matches, nick, users, chan, channel, params, nicklist, caps, rtn, obj, tmp, namespace;
+ var msg, regex, opts, options, opt, i, j, matches, nick, users, chan, channel,
+ params, nicklist, caps, rtn, obj, tmp, namespace, whois_end = false;
//regex = /^(?::(?:([a-z0-9\x5B-\x60\x7B-\x7D\.\-]+)|([a-z0-9\x5B-\x60\x7B-\x7D\.\-]+)!([a-z0-9~\.\-_|]+)@?([a-z0-9\.\-:\/]+)?) )?([a-z0-9]+)(?:(?: ([^:]+))?(?: :(.+))?)$/i;
//regex = /^(?::(\S+) )?(\S+)(?: (?!:)(.+?))?(?: :(.+))?$/i;
regex = /^(?::(?:([a-z0-9\x5B-\x60\x7B-\x7D\.\-]+)|([a-z0-9\x5B-\x60\x7B-\x7D\.\-]+)!([a-z0-9~\.\-_|]+)@?([a-z0-9\.\-:\/]+)?) )?(\S+)(?: (?!:)(.+?))?(?: :(.+))?$/i;
websocket.sendClientEvent('options', {server: '', "options": ircSocket.IRC.options});
break;
+
+ case ircNumerics.RPL_ENDOFWHOIS:
+ whois_end = true;
case ircNumerics.RPL_WHOISUSER:
case ircNumerics.RPL_WHOISSERVER:
case ircNumerics.RPL_WHOISOPERATOR:
- case ircNumerics.RPL_ENDOFWHOIS:
case ircNumerics.RPL_WHOISCHANNELS:
case ircNumerics.RPL_WHOISMODES:
- websocket.sendClientEvent('whois', {server: '', nick: msg.params.split(" ", 3)[1], "msg": msg.trailing});
+ websocket.sendClientEvent('whois', {server: '', nick: msg.params.split(" ", 3)[1], "msg": msg.trailing, end: whois_end});
break;
case ircNumerics.RPL_LISTSTART: