memory leak problems with tetris poop

This commit is contained in:
2025-10-26 19:51:57 -07:00
parent 4bd279798c
commit 882a416831
19 changed files with 397 additions and 80 deletions
+33
View File
@@ -5,6 +5,39 @@
*/
export {
auto_resize,
auto_scroll_to_bottom
};
function
auto_resize
(checkbox_element : HTMLInputElement,
target_element : HTMLTextAreaElement,
max_height : number)
: void
{
// if the user has manually resized their output, we do nothing
if (checkbox_element.checked) {
let target_height: number = target_element.scrollHeight;
// resize it automagically up to 500px
if (target_height < max_height)
target_element.style.height = String(target_height) + 'px';
else
target_element.style.height = String(max_height) + 'px';
}
}
function
auto_scroll_to_bottom
(checkbox_element : HTMLInputElement,
target_element : HTMLTextAreaElement)
: void
{
if (checkbox_element.checked) {
// scroll to bottom
target_element.scrollTop = target_element.scrollHeight;
}
}
+49
View File
@@ -0,0 +1,49 @@
/**
* Tetris
*
* @module
*/
export {
};
import * as libfewd from './libfewd.js';
main();
async function
main
()
: Promise<void>
{
let ws : WebSocket = new WebSocket("/ws/tetris") ;
let elt_tetris_state : HTMLTextAreaElement = document.getElementById('tetris-state') as HTMLTextAreaElement ;
ws.onmessage =
(e: MessageEvent) => {
handle_evt(e, elt_tetris_state);
}
}
//-----------------------------------------------------
// Tetris
//-----------------------------------------------------
/**
* take the entire tetris state, render the html elements
*
* then fish out the element in the document, and replace it
*
* blitting basically
*/
async function
handle_evt
(e : MessageEvent,
oelt : HTMLTextAreaElement)
: Promise<void>
{
let state_str : string = e.data as string;
oelt.value = state_str;
}