Merge pull request #677 from pmelanson/date-change
date change messages are chat_day_change color, multiple messages gerated for diff of 1-5 days
This commit is contained in:
commit
38d2f332db
2 changed files with 21 additions and 6 deletions
|
@ -20,12 +20,27 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
|
||||||
};
|
};
|
||||||
|
|
||||||
// inject a fake buffer line for date change
|
// inject a fake buffer line for date change
|
||||||
var injectDateChangeMessage = function(message, buffer, date) {
|
var injectDateChangeMessage = function(message, buffer, d1, d2) {
|
||||||
var content = "Date changed to " + date.toDateString();
|
var d1_plus_one = d1;
|
||||||
|
d1_plus_one.setDate(d1_plus_one.getDate() + 1);
|
||||||
|
d1.setHours(0, 0, 0, 0);
|
||||||
|
d2.setHours(0, 0, 0, 0);
|
||||||
|
// it's not always true that a date with time 00:00:00
|
||||||
|
// plus one day will be time 00:00:00
|
||||||
|
d1_plus_one.setHours(0, 0, 0, 0);
|
||||||
|
var content = "";
|
||||||
|
if (d1_plus_one.valueOf() === d2.valueOf()) {
|
||||||
|
content = "\u001943Date changed to " + d2.toDateString();
|
||||||
|
} else {
|
||||||
|
var date_diff = Math.round((d2 - d1)/(24*60*60*1000));
|
||||||
|
date_diff = date_diff >= 0 ? date_diff : date_diff + 1;
|
||||||
|
content = "\u001943Date changed to " + d2.toDateString();
|
||||||
|
content += " (" + date_diff + " days from " + d1.toDateString() + ")";
|
||||||
|
}
|
||||||
var line = {
|
var line = {
|
||||||
buffer: buffer,
|
buffer: buffer,
|
||||||
date: date,
|
date: d2,
|
||||||
prefix: '—',
|
prefix: '\u001943\u2500\u2500',
|
||||||
tags_array: [],
|
tags_array: [],
|
||||||
displayed: true,
|
displayed: true,
|
||||||
highlight: 0,
|
highlight: 0,
|
||||||
|
@ -48,7 +63,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
|
||||||
previous_date.setHours(0, 0, 0, 0);
|
previous_date.setHours(0, 0, 0, 0);
|
||||||
current_date.setHours(0, 0, 0, 0);
|
current_date.setHours(0, 0, 0, 0);
|
||||||
if (previous_date.valueOf() !== current_date.valueOf()) {
|
if (previous_date.valueOf() !== current_date.valueOf()) {
|
||||||
injectDateChangeMessage(message, buffer, current_date);
|
injectDateChangeMessage(message, buffer, previous_date, current_date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,7 @@
|
||||||
var ret = {};
|
var ret = {};
|
||||||
var optionCode = parseInt(m[1]);
|
var optionCode = parseInt(m[1]);
|
||||||
|
|
||||||
if (optionCode > 43) {
|
if (optionCode >= WeeChatProtocol._colorsOptionsNames.length) {
|
||||||
// should never happen
|
// should never happen
|
||||||
return {
|
return {
|
||||||
fgColor: null,
|
fgColor: null,
|
||||||
|
|
Loading…
Reference in a new issue