Skip to content

Commit

Permalink
Fix incorrectly appearing messages. Add notifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
Toon324 committed Jul 12, 2020
1 parent 6a3139f commit 41328ca
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ Splits the Chatlog into In Character (per scene), Rolls (per scene), and Out of

## Changelog

### v1.1.0

Added notifications for new messages in inactive tabs.
Fixed new messages showing up incorrectly.
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "tabbed-chatlog",
"title": "Tabbed Chatlog",
"description": "Splits the Chatlog into In Character (per scene), Rolls (per scene), and Out of Character (global).",
"version": "1.0.0",
"version": "1.1.0",
"minimumCoreVersion": "0.6.2",
"compatibleCoreVersion": "0.6.0",
"author": "Cody Swendrowski <[email protected]>",
Expand Down
23 changes: 23 additions & 0 deletions styles/tabbed-chatlog.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@
display: none;
}

.type4 {
display: none;
}

.type5 {
display: none;
}

.hardHide {
display: none !important;
}

#icNotification {
top: 35px;
right: 196px;
}

#oocNotification {
top: 35px;
right: -3px;
}

#rollsNotification {
top: 35px;
right: 92px;
}
78 changes: 72 additions & 6 deletions tabbed-chatlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ Hooks.on("renderChatLog", async function(chatLog, html, user) {
console.log(html);
console.log(user);

//html.prepend('<section class="tabbedchatlog content"><div class="tab" data-tab="tab1">Content 1</div><div class="tab" data-tab="tab2">Content 2</div></section>');
html.prepend('<nav class="tabbedchatlog tabs"><a class="item ic" data-tab="ic">In Character</a><a class="item rolls" data-tab="rolls">Rolls</a><a class="item ooc" data-tab="ooc">OOC</a></nav>');
var toPrepend = '<nav class="tabbedchatlog tabs">';
toPrepend += '<a class="item ic" data-tab="ic">In Character</a><i id="icNotification" class="notification-pip fas fa-exclamation-circle" style="display: none;"></i>'
toPrepend += '<a class="item rolls" data-tab="rolls">Rolls</a><i id="rollsNotification" class="notification-pip fas fa-exclamation-circle" style="display: none;"></i>';
toPrepend += '<a class="item ooc" data-tab="ooc">OOC</a></nav><i id="oocNotification" class="notification-pip fas fa-exclamation-circle" style="display: none;"></i>';
html.prepend(toPrepend);

var me = this;
const tabs = new TabsV2({
Expand All @@ -36,7 +39,10 @@ Hooks.on("renderChatLog", async function(chatLog, html, user) {
$(".type2").hide();
$(".type3").hide();
$(".type4").hide();
$(".type5").removeClass("hardHide");
$(".type5").show();

$("#rollsNotification").hide();
}
else if (tab == "ic") {
$(".type0").hide();
Expand All @@ -46,15 +52,19 @@ Hooks.on("renderChatLog", async function(chatLog, html, user) {
$(".type4").hide();
$(".type5").hide();

console.log("Showing messages for " + game.user.viewedScene);
$("#icNotification").hide();
}
else if (tab == "ooc") {
$(".type0").hide();
$(".type1").removeClass("hardHide");
$(".type1").show();
$(".type2").hide();
$(".type3").hide();
$(".type4").hide();
$(".type3").removeClass("hardHide");
$(".type4").show();
$(".type5").hide();

$("#oocNotification").hide();
}
else {
console.log("Unknown tab " + tab + "!");
Expand All @@ -74,15 +84,71 @@ Hooks.on("renderChatMessage", (chatMessage, html, data) => {

html.addClass("type" + data.message.type);

var sceneMatches = true;

if (data.message.type == 0 || data.message.type == 2 || data.message.type == 3 || data.message.type == 5) {
if (data.message.speaker.scene != undefined) {
html.addClass("scenespecific");
html.addClass("scene" + data.message.speaker.scene);
if (data.message.speaker.scene != game.user.viewedScene) {
sceneMatches = false;
}
}
}

if (currentTab == "ooc") {
html.css("display", "list-item");
if (currentTab == "rolls") {
if (data.message.type == 5 && sceneMatches)
{
html.css("display", "list-item");
}
else {
html.css("display", "none");
}
}
else if (currentTab == "ic") {
if ((data.message.type == 2 || data.message.type == 3) && sceneMatches)
{
html.css("display", "list-item");
}
else {
html.css("cssText", "display: none !important;");
html.addClass("hardHide");
}
}
else if (currentTab == "ooc") {
if (data.message.type == 1 || data.message.type == 4)
{
html.css("display", "list-item");
}
else {
html.css("display", "none");
}
}
});

Hooks.on("createChatMessage", (chatMessage, content) => {
var sceneMatches = true;

if (chatMessage.data.speaker.scene) {
if (chatMessage.data.speaker.scene != game.user.viewedScene) {
sceneMatches = false;
}
}

if (chatMessage.data.type == 5) {
if (currentTab != "rolls" && sceneMatches) {
$("#rollsNotification").show();
}
}
else if (chatMessage.data.type == 2 || chatMessage.data.type == 3) {
if (currentTab != "ic" && sceneMatches) {
$("#icNotification").show();
}
}
else {
if (currentTab != "ooc") {
$("#oocNotification").show();
}
}
});

Expand Down

0 comments on commit 41328ca

Please sign in to comment.