Skip to content

Commit

Permalink
Add tabbed chatlog
Browse files Browse the repository at this point in the history
  • Loading branch information
Toon324 committed Jul 11, 2020
1 parent 2fd45ea commit ad8bb4f
Show file tree
Hide file tree
Showing 6 changed files with 849 additions and 1 deletion.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
FoundryVTT Tabbed Chatlog
![](https://img.shields.io/badge/Foundry-v0.6.2-informational)
[![](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-%243-orange)](https://www.buymeacoffee.com/T2tZvWJ)


# Tabbed Chatlog

Splits up the chat into smaller tabs

![](./tabbed-chatlog.gif)



## Changelog

28 changes: 28 additions & 0 deletions module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"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",
"minimumCoreVersion": "0.6.2",
"compatibleCoreVersion": "0.6.0",
"author": "Cody Swendrowski <[email protected]>",
"esmodules": [
"./tabbed-chatlog.js"
],
"scripts": [
"scripts/lib/Sortable.js"
],
"styles": [
"/styles/tabbed-chatlog.css"
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "languages/en.json"
}
],
"url": "https://github.com/cswendrowski/FoundryVTT-tabbed-chatlog",
"manifest": "https://github.com/cswendrowski/FoundryVTT-tabbed-chatlog/releases/download/latest/module.json",
"download": "https://github.com/cswendrowski/FoundryVTT-tabbed-chatlog/releases/download/latest/module.zip"
}
29 changes: 29 additions & 0 deletions styles/tabbed-chatlog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.tabbedchatlog.tabs {
flex: 0;
margin: 0 0 5px;
border-bottom: 1px solid #ff6400;
box-shadow: 0 0 10px red;
}

.tabbedchatlog .item.active {
color: #FFF;
border: 1px solid red;
border-bottom: none;
box-shadow: 0 0 6px inset #ff6400;
}

.tabbedchatlog .item {
height: 18px;
}

.type0 {
display: none;
}

.type1 {
display: none;
}

.type5 {
display: none;
}
Binary file added tabbed-chatlog.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions tabbed-chatlog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
(() => { })();

const CHAT_MESSAGE_TYPES = {
OTHER: 0,
OOC: 1,
IC: 2,
EMOTE: 3,
WHISPER: 4,
ROLL: 5
};

let currentTab = "ic";

Hooks.on("renderChatLog", async function(chatLog, html, user) {
console.log("tabbed chatlog");
console.log(chatLog);
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 me = this;
const tabs = new TabsV2({
navSelector: ".tabs",
contentSelector: ".content",
initial: "tab1",
callback: function(event, html, tab) {
console.log("Tab callback");
console.log(tab);
currentTab = tab;

if (tab == "rolls") {
$(".type0").show();
$(".type1").hide();
$(".type2").hide();
$(".type3").hide();
$(".type4").hide();
$(".type5").show();
}
else if (tab == "ic") {
$(".type0").hide();
$(".type1").hide();
$(".type2.scene" + game.user.viewedScene).show();
$(".type3.scene" + game.user.viewedScene).show();
$(".type4").hide();
$(".type5").hide();

console.log("Showing messages for " + game.user.viewedScene);
}
else if (tab == "ooc") {
$(".type0").hide();
$(".type1").show();
$(".type2").hide();
$(".type3").hide();
$(".type4").hide();
$(".type5").hide();
}
else {
console.log("Unknown tab " + tab + "!");
}
}
});
console.log(html[0]);
tabs.bind(html[0]);

console.log(tabs);
});

Hooks.on("renderChatMessage", (chatMessage, html, data) => {
console.log(chatMessage);
console.log(html);
console.log(data)

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

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 (currentTab == "ooc") {
html.css("display", "list-item");
}
});

Hooks.on("renderSceneNavigation", (sceneNav, html, data) => {
console.log(sceneNav);
console.log(data);
var viewedScene = sceneNav.scenes.find(x => x.isView);
console.log("Navigated to scene " + viewedScene.id);

$(".scenespecific").hide();
if (currentTab == "rolls") {
$(".type0.scene" + viewedScene.id).show();
$(".type5.scene" + viewedScene.id).show();
}
else if (currentTab == "ic") {
$(".type2.scene" + viewedScene.id).show();
$(".type3.scene" + viewedScene.id).show();
}
});

0 comments on commit ad8bb4f

Please sign in to comment.