hardlounge/client/js/condensed.js

38 lines
814 B
JavaScript
Raw Normal View History

2017-06-22 20:08:36 +00:00
"use strict";
const constants = require("./constants");
module.exports = {
updateText
};
function updateText(condensed, addedTypes) {
var obj = {};
for (var i in constants.condensedTypes) {
var msgType = constants.condensedTypes[i];
obj[msgType] = condensed.data(msgType) || 0;
}
for (var k in addedTypes) {
var added = addedTypes[k];
obj[added]++;
condensed.data(added, obj[added]);
}
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";
}
text += obj[messageType] > 1 ? "s" : "";
}
}
condensed.find(".condensed-msg").text(text);
}