Add some human-friendliness to the condensed status messages
This commit is contained in:
parent
853e646670
commit
43a8604b32
@ -8,32 +8,48 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function updateText(condensed, addedTypes) {
|
function updateText(condensed, addedTypes) {
|
||||||
var obj = {};
|
const obj = {};
|
||||||
|
|
||||||
for (var i in constants.condensedTypes) {
|
constants.condensedTypes.forEach((type) => {
|
||||||
var msgType = constants.condensedTypes[i];
|
obj[type] = condensed.data(type) || 0;
|
||||||
obj[msgType] = condensed.data(msgType) || 0;
|
});
|
||||||
}
|
|
||||||
|
|
||||||
for (var k in addedTypes) {
|
addedTypes.forEach((type) => {
|
||||||
var added = addedTypes[k];
|
obj[type]++;
|
||||||
obj[added]++;
|
condensed.data(type, obj[type]);
|
||||||
condensed.data(added, obj[added]);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
var text = "";
|
const strings = [];
|
||||||
|
constants.condensedTypes.forEach((type) => {
|
||||||
for (var j in constants.condensedTypes) {
|
if (obj[type]) {
|
||||||
var messageType = constants.condensedTypes[j];
|
switch (type) {
|
||||||
if (obj[messageType]) {
|
case "join":
|
||||||
text += text === "" ? "" : ", ";
|
strings.push(obj[type] + (obj[type] > 1 ? " users have joined the channel" : " user has joined the channel"));
|
||||||
text += obj[messageType] + " " + messageType;
|
break;
|
||||||
if (messageType === "nick" || messageType === "mode") {
|
case "part":
|
||||||
text += " change";
|
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")
|
condensed.find(".condensed-text")
|
||||||
.html(text + templates.msg_condensed_toggle());
|
.html(text + templates.msg_condensed_toggle());
|
||||||
}
|
}
|
||||||
|
@ -75,11 +75,11 @@ const actionTypes = [
|
|||||||
|
|
||||||
const condensedTypes = [
|
const condensedTypes = [
|
||||||
"join",
|
"join",
|
||||||
"kick",
|
|
||||||
"mode",
|
|
||||||
"nick",
|
|
||||||
"part",
|
"part",
|
||||||
"quit",
|
"quit",
|
||||||
|
"nick",
|
||||||
|
"kick",
|
||||||
|
"mode",
|
||||||
];
|
];
|
||||||
|
|
||||||
const timeFormats = {
|
const timeFormats = {
|
||||||
|
Loading…
Reference in New Issue
Block a user