return words_out.join(' ');
}
+
+// Code based on http://anentropic.wordpress.com/2009/06/25/javascript-iso8601-parser-and-pretty-dates/#comment-154
+function parseISO8601(str) {
+ if (Date.prototype.toISOString) {
+ return new Date(str);
+ } else {
+ var parts = str.split('T'),
+ dateParts = parts[0].split('-'),
+ timeParts = parts[1].split('Z'),
+ timeSubParts = timeParts[0].split(':'),
+ timeSecParts = timeSubParts[2].split('.'),
+ timeHours = Number(timeSubParts[0]),
+ _date = new Date();
+
+ _date.setUTCFullYear(Number(dateParts[0]));
+ _date.setUTCDate(1);
+ _date.setUTCMonth(Number(dateParts[1])-1);
+ _date.setUTCDate(Number(dateParts[2]));
+ _date.setUTCHours(Number(timeHours));
+ _date.setUTCMinutes(Number(timeSubParts[1]));
+ _date.setUTCSeconds(Number(timeSecParts[0]));
+ if (timeSecParts[1]) {
+ _date.setUTCMilliseconds(Number(timeSecParts[1]));
+ }
+
+ return _date;
+ }
+}
\ No newline at end of file
\r
members = this.get("members");\r
members.channel = this;\r
- members.bind("add", function (member) {\r
+ members.bind("add", function (member, members, options) {\r
var show_message = _kiwi.global.settings.get('show_joins_parts');\r
if (show_message === false) {\r
return;\r
}\r
\r
- this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_join').fetch(member.displayNick(true)), 'action join');\r
+ this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_join').fetch(member.displayNick(true)), 'action join', {time: options.kiwi.time});\r
}, this);\r
\r
members.bind("remove", function (member, members, options) {\r
var show_message = _kiwi.global.settings.get('show_joins_parts');\r
- var msg = (options.message) ? '(' + options.message + ')' : '';\r
+ var msg = (options.kiwi.message) ? '(' + options.kiwi.message + ')' : '';\r
\r
- if (options.type === 'quit' && show_message) {\r
- this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_quit').fetch(member.displayNick(true), msg), 'action quit');\r
+ if (options.kiwi.type === 'quit' && show_message) {\r
+ this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_quit').fetch(member.displayNick(true), msg), 'action quit', {time: options.kiwi.time});\r
\r
- } else if(options.type === 'kick') {\r
+ } else if (options.kiwi.type === 'kick') {\r
\r
- if (!options.current_user_kicked) {\r
+ if (!options.kiwi.current_user_kicked) {\r
//If user kicked someone, show the message regardless of settings.\r
- if (show_message || options.current_user_initiated) {\r
- this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_kicked').fetch(member.displayNick(true), options.by, msg), 'action kick');\r
+ if (show_message || options.kiwi.current_user_initiated) {\r
+ this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_kicked').fetch(member.displayNick(true), options.kiwi.by, msg), 'action kick', {time: options.kiwi.time});\r
}\r
} else {\r
- this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_selfkick').fetch(options.by, msg), 'action kick');\r
+ this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_selfkick').fetch(options.kiwi.by, msg), 'action kick', {time: options.kiwi.time});\r
}\r
} else if (show_message) {\r
-\r
- this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_part').fetch(member.displayNick(true), msg), 'action part');\r
+ this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_part').fetch(member.displayNick(true), msg), 'action part', {time: options.kiwi.time});\r
}\r
}, this);\r
},\r
opts = opts || {};\r
\r
// Time defaults to now\r
- if (!opts || typeof opts.time === 'undefined') {\r
- d = opts.date = new Date();\r
- opts.time = d.getHours().toString().lpad(2, "0") + ":" + d.getMinutes().toString().lpad(2, "0") + ":" + d.getSeconds().toString().lpad(2, "0");\r
+ if (typeof opts.time === 'undefined') {\r
+ opts.time = new Date();\r
+ } else if (typeof opts.time === 'string') {\r
+ opts.time = parseISO8601(opts.time);\r
}\r
\r
// CSS style defaults to empty string\r
if (!members) return;
user = new _kiwi.model.Member({nick: event.nick, ident: event.ident, hostname: event.hostname});
- members.add(user);
+ members.add(user, {kiwi: event});
}
part_options.type = 'part';
part_options.message = event.message || '';
+ part_options.time = event.time;
channel = this.panels.getByName(event.channel);
if (!channel) return;
user = members.getByNick(event.nick);
if (!user) return;
- members.remove(user, part_options);
+ members.remove(user, {kiwi: part_options});
}
quit_options.type = 'quit';
quit_options.message = event.message || '';
+ quit_options.time = event.time;
$.each(this.panels.models, function (index, panel) {
if (!panel.isChannel()) return;
member = panel.get('members').getByNick(event.nick);
if (member) {
- panel.get('members').remove(member, quit_options);
+ panel.get('members').remove(member, {kiwi: quit_options});
}
});
}
part_options.type = 'kick';
part_options.by = event.nick;
part_options.message = event.message || '';
- part_options.current_user_kicked = (event.kicked == this.get('nick'))
- part_options.current_user_initiated = (event.nick == this.get('nick'))
+ part_options.current_user_kicked = (event.kicked == this.get('nick'));
+ part_options.current_user_initiated = (event.nick == this.get('nick'));
+ part_options.time = event.time;
channel = this.panels.getByName(event.channel);
if (!channel) return;
if (!user) return;
- members.remove(user, part_options);
+ members.remove(user, {kiwi: part_options});
if (part_options.current_user_kicked) {
members.reset([]);
}
}
- panel.addMsg(event.nick, event.msg);
+ panel.addMsg(event.nick, event.msg, 'privmsg', {time: event.time});
}
member = panel.get('members').getByNick(event.nick);
if (member) {
member.set('nick', event.newnick);
- panel.addMsg('', '== ' + _kiwi.global.i18n.translate('client_models_network_nickname_changed').fetch(event.nick, event.newnick) , 'action nick');
+ panel.addMsg('', '== ' + _kiwi.global.i18n.translate('client_models_network_nickname_changed').fetch(event.nick, event.newnick) , 'action nick', {time: event.time});
}
});
}
return;
}
- this.panels.server.addMsg('[' + event.nick + ']', 'CTCP ' + event.msg);
+ this.panels.server.addMsg('[' + event.nick + ']', 'CTCP ' + event.msg, 'ctcp', {time: event.time});
}
panel = this.panels.server;
}
- panel.addMsg('[' + (event.nick||'') + ']', event.msg);
+ panel.addMsg('[' + (event.nick||'') + ']', event.msg, 'notice', {time: event.time});
// Show this notice to the active panel if it didn't have a set target
if (!event.from_server && panel === this.panels.server && _kiwi.app.panels().active !== this.panels.server)
- _kiwi.app.panels().active.addMsg('[' + (event.nick||'') + ']', event.msg);
+ _kiwi.app.panels().active.addMsg('[' + (event.nick||'') + ']', event.msg, 'notice', {time: event.time});
}
}
}
- panel.addMsg('', '* ' + event.nick + ' ' + event.msg, 'action');
+ panel.addMsg('', '* ' + event.nick + ' ' + event.msg, 'action', {time: event.time});
}
}
}
- channel.addMsg('', '== ' + _kiwi.global.i18n.translate('client_models_network_mode').fetch(event.nick, friendlyModeString()), 'action mode');
+ channel.addMsg('', '== ' + _kiwi.global.i18n.translate('client_models_network_mode').fetch(event.nick, friendlyModeString()), 'action mode', {time: event.time});
} else {
// This is probably a mode being set on us.
if (event.target.toLowerCase() === this.get("nick").toLowerCase()) {
if (prev_msg) {
// Time difference between this message and the last (in minutes)
- time_difference = (msg.date.getTime() - prev_msg.date.getTime())/1000/60;
+ time_difference = (msg.time.getTime() - prev_msg.time.getTime())/1000/60;
if (prev_msg.nick === msg.nick && time_difference < 1) {
msg_css_classes += ' repeated_nick';
}
// Build up and add the line
msg.msg_css_classes = msg_css_classes;
- line_msg = '<div class="msg <%= type %> <%= msg_css_classes %>"><div class="time"><%- time %></div><div class="nick" style="<%= nick_style %>"><%- nick %></div><div class="text" style="<%= style %>"><%= msg %> </div></div>';
+ msg.time_string = msg.time.getHours().toString().lpad(2, "0") + ":" + msg.time.getMinutes().toString().lpad(2, "0") + ":" + msg.time.getSeconds().toString().lpad(2, "0");
+ line_msg = '<div class="msg <%= type %> <%= msg_css_classes %>"><div class="time"><%- time_string %></div><div class="nick" style="<%= nick_style %>"><%- nick %></div><div class="text" style="<%= style %>"><%= msg %> </div></div>';
this.$messages.append(_.template(line_msg, msg));
// Activity/alerts based on the type of new message