Skip to content

Commit a3fc505

Browse files
committed
Dynamic message box
The message box now resizes when content in it wraps. It can only hold up to 6 lines until it requires that you scroll.
1 parent dc5554d commit a3fc505

8 files changed

Lines changed: 34 additions & 13 deletions

File tree

css/messageBar.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ limitations under the License. */
2121
height: 40px;
2222
padding-bottom: 10px;
2323
z-index: 2;
24+
2425
}
2526

2627
#sendmsg::before {
2728
content: "";
2829
width: 100%;
2930
background-color: #36393e;
30-
height: 40px;
31+
height: 4000px;
3132
position: absolute;
3233
top: 20px;
3334
z-index: -1;
@@ -43,6 +44,8 @@ limitations under the License. */
4344
border-radius: 5px;
4445
padding: 0 10px 0 0;
4546
display: flex;
47+
48+
/* display: table; */
4649
}
4750

4851
#msgbox::-webkit-scrollbar {
@@ -72,6 +75,7 @@ limitations under the License. */
7275
/* width: calc(100% - 40px); */
7376
word-spacing: 2px;
7477
position: relative;
78+
/* display: table-row; */
7579
}
7680

7781

@@ -84,6 +88,7 @@ limitations under the License. */
8488
display: grid;
8589
grid-auto-flow: column;
8690
grid-column-gap: 4px;
91+
8792
}
8893

8994
#msgMisc img {

js/app.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,32 @@ async function create() {
4343
};
4444

4545
document.getElementById('msgbox').addEventListener('keydown', (event) => {
46-
if (event.key === 13 && !event.shiftKey) {
46+
if (event.key == "Enter" && !event.shiftKey) {
4747
event.preventDefault();
48-
sendmsg();
48+
49+
// If the message was able to be sent, reset the message box size
50+
if (!sendmsg()) {
51+
// Reset the textbox height
52+
let msgBox = document.getElementById("sendmsg");
53+
msgBox.style.height = '38px'; // Reset the height first
54+
msgBox.style.transform = '';
55+
}
4956
}
5057
});
5158

5259
document.getElementById('msgbox').addEventListener('input', (event) => {
53-
let rows = document.getElementById('msgbox').value.split('\n').length;
54-
if (rows == 0) rows++;
60+
let textElem = document.getElementById('msgbox');
61+
let rows = textElem.value.split('\n').length;
62+
rows = (rows == 0) ? 1 : rows;
5563
// document.getElementById("msgbox").rows = rows;
64+
65+
let msgBox = document.getElementById("sendmsg");
66+
67+
if (textElem.scrollHeight < 38*5) {
68+
msgBox.style.height = '0px' // Reset the height first
69+
msgBox.style.height = `${textElem.scrollHeight}px`;
70+
msgBox.style.transform = `translateY(-${textElem.scrollHeight-38}px)`
71+
}
5672
});
5773

5874
// Call the settings menu builder

js/guildSelect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let guildSelect = (g, img) => {
2424
img.classList.add('selectedGuild');
2525

2626
// this should be done another way
27-
document.getElementById('guildIndicator').style.marginTop = `${img.offsetTop - 69}px`;
27+
document.getElementById('guildIndicator').style.marginTop = `${img.offsetTop - 64}px`;
2828
document.getElementById('guildIndicator').style.display = 'block';
2929

3030
oldimg = img;

js/rcMenuFuncs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function editMsg(target) {
6363
target.appendChild(textarea);
6464

6565
textarea.addEventListener('keydown', (e) => {
66-
if (e.key === 13 && !e.shiftKey) {
66+
if (e.key == "Enter" && !e.shiftKey) {
6767
if (textarea.value == text) return editDOM(target, textarea, text);
6868
let newText = textarea.value;
6969
newText = newText.replace(

js/sendMsg.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ let helpMsg = [
3131
let sendmsg = (text = '') => {
3232
if (selectedChan) {
3333
text = text.length ? text : document.getElementById('msgbox').value;
34-
if (!text.replace(/ |\n| /gm, '')) return;
35-
// If the emoji isn't a gloabal emoji, treat it as one.
34+
if (!text.replace(/ |\n| /gm, '')) return true;
35+
// If the emoji isn't a global emoji, treat it as one.
3636
// let customEmoji = /(<a?:)(!)?(.+?:[0-9]+?>)/gm
3737
// text = text.replace(customEmoji, (a, b, c, d) => {
3838
// if (c != '!') {

js/typingStatus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ let typingTimer = {
4949
this.timers[id] = { timeout, interval };
5050
},
5151
decrease: function (id, channel) {
52-
channel.stopTyping();
52+
channel.stopTyping(true);
5353
this.timers[id]['timeout']--;
5454
if (this.timers[id]['timeout'] < 0) {
5555
clearInterval(this.timers[id]['interval']);

js/userSettings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ function genCheckbox(parent, option) {
512512

513513
// document.getElementById("tokenbox")
514514
// .addEventListener("keydown", event => {
515-
// if (event.key === 13) {
515+
// if (event.key == "Enter") {
516516
// unloadAllScripts();
517517
// setToken();
518518
// }
@@ -543,7 +543,7 @@ function genShortInput(
543543
if (id == 'tokenbox') {
544544
input.type = 'password';
545545
input.addEventListener('keydown', (event) => {
546-
if (event.key === 13) showSplashScreen(input.value);
546+
if (event.key === "Enter") showSplashScreen(input.value);
547547
});
548548
}
549549
}

scripts/template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
module.exports.info = {
16-
author: 'Your discord username and tag (ex: daniel_crime#1551)',
16+
author: 'Your discord username and tag (ex: SharkFin#1504)',
1717
title: 'Name of your script',
1818
description: 'Description of your script',
1919
version: '1.0.0',

0 commit comments

Comments
 (0)