date change messages are chat_day_change color, multiple messages generated for diff of 1-5 days
This commit is contained in:
parent
b883a52b09
commit
0a1726e359
2 changed files with 21 additions and 5 deletions
|
@ -21,11 +21,11 @@ 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, date) {
|
||||||
var content = "Date changed to " + date.toDateString();
|
var content = "\u001943Date changed to " + date.toDateString();
|
||||||
var line = {
|
var line = {
|
||||||
buffer: buffer,
|
buffer: buffer,
|
||||||
date: date,
|
date: date,
|
||||||
prefix: '—',
|
prefix: '\u001943\u2500\u2500',
|
||||||
tags_array: [],
|
tags_array: [],
|
||||||
displayed: true,
|
displayed: true,
|
||||||
highlight: 0,
|
highlight: 0,
|
||||||
|
@ -47,8 +47,24 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
|
||||||
current_date = new Date(message.date);
|
current_date = new Date(message.date);
|
||||||
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()) {
|
var dateDifference =
|
||||||
injectDateChangeMessage(message, buffer, current_date);
|
Math.round((current_date - previous_date)/(24*60*60*1000));
|
||||||
|
if (dateDifference !== 0) {
|
||||||
|
console.log(dateDifference);
|
||||||
|
// if it's a small, positive number display a message
|
||||||
|
// for each one. Otherwise, just display one big
|
||||||
|
// date change message
|
||||||
|
// The range [1,5] was chosen arbitrarily
|
||||||
|
if (dateDifference >= 1 && dateDifference <= 5) {
|
||||||
|
var prev_date_clone = previous_date;
|
||||||
|
for (var i = 1; i <= dateDifference; ++i) {
|
||||||
|
prev_date_clone.setDate(prev_date_clone.getDate()+1);
|
||||||
|
injectDateChangeMessage(message, buffer,
|
||||||
|
prev_date_clone);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
injectDateChangeMessage(message, buffer, 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