Skip to content

Commit 75c905a

Browse files
schrejDaneEveritt
authored andcommitted
Feature/fix terminal notification (pterodactyl#681)
* show terminal notification on top * show notification only when not scrolled down and new output available * terminal: move scrolled down check outside of push loop
1 parent 2b80de0 commit 75c905a

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

public/themes/pterodactyl/css/terminal.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
opacity: .5;
6262
font-size: 16px;
6363
cursor: pointer;
64+
z-index: 10;
6465
}
6566

6667
.terminal-notify:hover {

public/themes/pterodactyl/js/frontend/console.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ $(document).ready(function () {
116116
});
117117

118118
$terminal.on('scroll', function () {
119-
if ($(this).scrollTop() + $(this).innerHeight() + 50 < $(this)[0].scrollHeight) {
120-
$scrollNotify.removeClass('hidden');
121-
} else {
119+
if (isTerminalScrolledDown()) {
122120
$scrollNotify.addClass('hidden');
123121
}
124122
});
125123

124+
function isTerminalScrolledDown() {
125+
return $terminal.scrollTop() + $terminal.innerHeight() + 50 > $terminal[0].scrollHeight;
126+
}
127+
126128
window.scrollToBottom = function () {
127129
$terminal.scrollTop($terminal[0].scrollHeight);
128130
};
@@ -148,16 +150,20 @@ function pushToTerminal(string) {
148150
}
149151

150152
if (TerminalQueue.length > 0) {
153+
var scrolledDown = isTerminalScrolledDown();
154+
151155
for (var i = 0; i < CONSOLE_PUSH_COUNT && TerminalQueue.length > 0; i++) {
152156
pushToTerminal(TerminalQueue[0]);
153157

154-
if (! $scrollNotify.is(':visible')) {
155-
window.scrollToBottom();
156-
}
157-
158158
window.ConsoleElements++;
159159
TerminalQueue.shift();
160160
}
161+
162+
if (scrolledDown) {
163+
window.scrollToBottom();
164+
} else if ($scrollNotify.hasClass('hidden')) {
165+
$scrollNotify.removeClass('hidden');
166+
}
161167

162168
var removeElements = window.ConsoleElements - CONSOLE_OUTPUT_LIMIT;
163169
if (removeElements > 0) {

0 commit comments

Comments
 (0)