mirror of
https://github.com/thelounge/thelounge
synced 2024-11-14 16:27:22 +00:00
Add some human-friendliness to the condensed status messages
This commit is contained in:
parent
853e646670
commit
43a8604b32
2 changed files with 39 additions and 23 deletions
|
@ -8,32 +8,48 @@ module.exports = {
|
|||
};
|
||||
|
||||
function updateText(condensed, addedTypes) {
|
||||
var obj = {};
|
||||
const obj = {};
|
||||
|
||||
for (var i in constants.condensedTypes) {
|
||||
var msgType = constants.condensedTypes[i];
|
||||
obj[msgType] = condensed.data(msgType) || 0;
|
||||
}
|
||||
constants.condensedTypes.forEach((type) => {
|
||||
obj[type] = condensed.data(type) || 0;
|
||||
});
|
||||
|
||||
for (var k in addedTypes) {
|
||||
var added = addedTypes[k];
|
||||
obj[added]++;
|
||||
condensed.data(added, obj[added]);
|
||||
}
|
||||
addedTypes.forEach((type) => {
|
||||
obj[type]++;
|
||||
condensed.data(type, obj[type]);
|
||||
});
|
||||
|
||||
var text = "";
|
||||
|
||||
for (var j in constants.condensedTypes) {
|
||||
var messageType = constants.condensedTypes[j];
|
||||
if (obj[messageType]) {
|
||||
text += text === "" ? "" : ", ";
|
||||
text += obj[messageType] + " " + messageType;
|
||||
if (messageType === "nick" || messageType === "mode") {
|
||||
text += " change";
|
||||
const strings = [];
|
||||
constants.condensedTypes.forEach((type) => {
|
||||
if (obj[type]) {
|
||||
switch (type) {
|
||||
case "join":
|
||||
strings.push(obj[type] + (obj[type] > 1 ? " users have joined the channel" : " user has joined the channel"));
|
||||
break;
|
||||
case "part":
|
||||
strings.push(obj[type] + (obj[type] > 1 ? " users have left the channel" : " user has left the channel"));
|
||||
break;
|
||||
case "quit":
|
||||
strings.push(obj[type] + (obj[type] > 1 ? " users have quit" : " user has quit"));
|
||||
break;
|
||||
case "nick":
|
||||
strings.push(obj[type] + (obj[type] > 1 ? " users have changed nick" : " user has changed nick"));
|
||||
break;
|
||||
case "kick":
|
||||
strings.push(obj[type] + (obj[type] > 1 ? " users were kicked" : " user was kicked"));
|
||||
break;
|
||||
case "mode":
|
||||
strings.push(obj[type] + (obj[type] > 1 ? " modes were set" : " mode was set"));
|
||||
break;
|
||||
}
|
||||
text += obj[messageType] > 1 ? "s" : "";
|
||||
}
|
||||
});
|
||||
|
||||
let text = strings.pop();
|
||||
if (strings.length) {
|
||||
text = strings.join(", ") + ", and " + text;
|
||||
}
|
||||
|
||||
condensed.find(".condensed-text")
|
||||
.html(text + templates.msg_condensed_toggle());
|
||||
}
|
||||
|
|
|
@ -75,11 +75,11 @@ const actionTypes = [
|
|||
|
||||
const condensedTypes = [
|
||||
"join",
|
||||
"kick",
|
||||
"mode",
|
||||
"nick",
|
||||
"part",
|
||||
"quit",
|
||||
"nick",
|
||||
"kick",
|
||||
"mode",
|
||||
];
|
||||
|
||||
const timeFormats = {
|
||||
|
|
Loading…
Reference in a new issue