From 227be7062bd19c85ac05bc45c81ef04e8fed050c Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins Date: Sat, 11 Jan 2020 20:17:47 +0000 Subject: [PATCH] Made most of requested changes --- scripts/communityModules/chat/FloofChat.html | 164 +----------------- scripts/communityModules/chat/FloofChat.js | 23 ++- .../communityModules/chat/css/FloofChat.css | 157 +++++++++++++++++ .../notificationCore/notificationCore.js | 3 +- 4 files changed, 176 insertions(+), 171 deletions(-) create mode 100644 scripts/communityModules/chat/css/FloofChat.css diff --git a/scripts/communityModules/chat/FloofChat.html b/scripts/communityModules/chat/FloofChat.html index 6ca92994a1..469ef7cf10 100644 --- a/scripts/communityModules/chat/FloofChat.html +++ b/scripts/communityModules/chat/FloofChat.html @@ -9,169 +9,11 @@ - + - @@ -202,8 +44,6 @@ - - + + \ No newline at end of file diff --git a/scripts/communityModules/chat/FloofChat.js b/scripts/communityModules/chat/FloofChat.js index 1bff83bd0d..b28613d49d 100644 --- a/scripts/communityModules/chat/FloofChat.js +++ b/scripts/communityModules/chat/FloofChat.js @@ -1,6 +1,11 @@ /* globals OverlayWindow */ var ROOT = Script.resolvePath('').split("FloofChat.js")[0]; +var H_KEY = 72; +var ENTER_KEY = 16777220; +var ESC_KEY = 16777216; +var FLOOF_CHAT_CHANNEL = "Chat"; +var FLOOF_NOTIFICATION_CHANNEL = "Floof-Notif"; Script.scriptEnding.connect(function () { shutdown(); @@ -9,7 +14,7 @@ Script.scriptEnding.connect(function () { var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ icon: ROOT + "chat.png", - text: "Chat\nHistory" + text: "CHAT" }); Script.scriptEnding.connect(function () { // So if anything errors out the tablet/toolbar button gets removed! @@ -31,7 +36,7 @@ var muted = Settings.getValue(settingsRoot + "/muted", {"Local": false, "Domain" var ws; var wsReady = false; -var webSocketURL = "ws://gridchat.darlingvr.club:8090"; +var WEB_SOCKET_URL = "ws://gridchat.darlingvr.club:8090"; var shutdownBool = false; var defaultColour = {red: 255, green: 255, blue: 255}; @@ -43,7 +48,7 @@ colours["gridChatColour"] = Settings.getValue(settingsRoot + "/gridChatColour", init(); function init() { - Messages.subscribe("Chat"); + Messages.subscribe(FLOOF_CHAT_CHANNEL); historyLog = []; try { historyLog = JSON.parse(Settings.getValue(settingsRoot + "/HistoryLog", "[]")); @@ -69,7 +74,7 @@ function init() { } function connectWebSocket(timeout) { - ws = new WebSocket(webSocketURL); + ws = new WebSocket(WEB_SOCKET_URL); ws.onmessage = function incoming(_data) { var message = _data.data; var cmd = {FAILED: true}; @@ -81,7 +86,7 @@ function connectWebSocket(timeout) { if (!cmd.FAILED) { addToLog(cmd.message, cmd.displayName, cmd.colour, cmd.channel); if (!muted["Grid"]) { - Messages.sendLocalMessage("Floof-Notif", JSON.stringify({ + Messages.sendLocalMessage(FLOOF_NOTIFICATION_CHANNEL, JSON.stringify({ sender: "(G) " + cmd.displayName, text: replaceFormatting(cmd.message), colour: {text: cmd.colour} @@ -361,7 +366,7 @@ function time() { function addToLog(msg, dp, colour, tab) { historyLog.push([time(), msg, dp, colour, tab]); chatHistory.emitScriptEvent(JSON.stringify({type: "MSG", data: [[time(), msg, dp, colour, tab]]})); - while(historyLog.length > 500) { + while (historyLog.length > 500) { historyLog.shift(); } Settings.setValue(settingsRoot + "/HistoryLog", JSON.stringify(historyLog)) @@ -433,13 +438,13 @@ function setVisible(_visible) { } function keyPressEvent(event) { - if (event.key === 72 && !event.isAutoRepeat && event.isControl) { + if (event.key === H_KEY && !event.isAutoRepeat && event.isControl) { toggleChatHistory() } - if (event.key === 16777220 && !event.isAutoRepeat && !visible) { + if (event.key === ENTER_KEY && !event.isAutoRepeat && !visible) { setVisible(true); } - if (event.key === 16777216 && !event.isAutoRepeat && visible) { + if (event.key === ESC_KEY && !event.isAutoRepeat && visible) { setVisible(false); } } diff --git a/scripts/communityModules/chat/css/FloofChat.css b/scripts/communityModules/chat/css/FloofChat.css new file mode 100644 index 0000000000..0b3a3fc64b --- /dev/null +++ b/scripts/communityModules/chat/css/FloofChat.css @@ -0,0 +1,157 @@ + +.disabledrag { + -webkit-user-drag: none !important; + -khtml-user-drag: none !important; + -moz-user-drag: none !important; + -o-user-drag: none !important; + user-drag: none !important; +} + +html { + height: 100%; +} + +div.dockButton { + + position: absolute; /*or fixed*/ + right: 10px; + + + overflow: hidden; + border: 1px solid #ccc; + background-color: #f1f1f1; +} + +div.dockButton button { + background-color: inherit; + float: right; + border: none; + outline: none; + cursor: pointer; + padding: 14px 16px; + transition: 0.3s; +} + +/* Change background color of buttons on hover */ +div.dockButton button:hover { + background-color: #ddd; +} + +/* Create an active/current tablink class */ +div.dockButton button.active { + background-color: #ccc; +} + +/* Style the tab content */ +.TabContent { + display: none; + + padding: 6px 12px; + border-top: none; +} + +body { + width: 100%; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + margin: 0; + font-family: 'Raleway', sans-serif; + color: white; + background: linear-gradient(#2b2b2b, #0f212e); +} + +.Content { + min-height: 100vh; + font-size: 20px; + width: 100%; + height: 100%; +} + +.ChatLog { + height: calc(100vh - 137px); + padding: 20px !important; + font-size: 20px; + color: white; + background-color: black; + overflow-x: hidden; + overflow-y: scroll; + word-wrap: break-word; +} + +.ChatLogLine { + margin-bottom: 15px; +} + +.ChatLogLineDisplayName { + font-weight: bold; +} + +.ChatLogLineMessage { +} + +.LogLogLine { + margin-bottom: 15px; + padding: 10px !important; +} + +.LogLogLineMessage { + /*font-style: italic;*/ +} + +.ChatInput { + color: #252525; + background: #252525; + height: 60px !important; +} + +.ChatInputText { + padding: 5px !important; + height: 50px !important; + width: calc(100vw - 20px) !important; + font-size: 20px !important; + background-color: white !important; + border-style: solid !important; + border-color: #232323 !important; + border-width: 5px 5px 5px 5px !important; + +} + +.responsive { + width: 100%; + max-width: 420px; + height: auto; +} + +.row .col { + padding: 0; +} + +.switch label .lever { + content: ""; + display: inline-block; + position: relative; + width: 36px; + height: 14px; + background-color: rgba(0, 0, 0, 0.38); + border-radius: 15px; + margin-right: 10px; + -webkit-transition: background 0.3s ease; + transition: background 0.3s ease; + vertical-align: middle; + margin: 0 16px; +} + +.muteSwitch label input[type=checkbox]:checked + .lever:after { + background-color: #a62113 !important; +} + +body, img, a, div { + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; + -webkit-user-drag: none; + user-drag: none; + -webkit-touch-callout: none; +} \ No newline at end of file diff --git a/scripts/communityModules/notificationCore/notificationCore.js b/scripts/communityModules/notificationCore/notificationCore.js index ba820a2634..4f610fa433 100644 --- a/scripts/communityModules/notificationCore/notificationCore.js +++ b/scripts/communityModules/notificationCore/notificationCore.js @@ -4,6 +4,7 @@ var sizeData = {30: {widthMul: 1.8, heightMul: 2.05, split: 35, size: 30}}; var DEFAULT_SIZE = 30; var DEFAULT_OFFSET = 10; +var FLOOF_NOTIFICATION_CHANNEL = "Floof-Notif"; var offset = DEFAULT_OFFSET; @@ -15,7 +16,7 @@ function init(){ function messageReceived(channel, message, sender, local) { if (local) { - if (channel === "Floof-Notif") { + if (channel === FLOOF_NOTIFICATION_CHANNEL) { var cmd = {FAILED: true}; try { cmd = JSON.parse(message);