memory leak problems with tetris poop
This commit is contained in:
Vendored
+3
-1
@@ -3,4 +3,6 @@
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
export {};
|
||||
export { auto_resize, auto_scroll_to_bottom };
|
||||
declare function auto_resize(checkbox_element: HTMLInputElement, target_element: HTMLTextAreaElement, max_height: number): void;
|
||||
declare function auto_scroll_to_bottom(checkbox_element: HTMLInputElement, target_element: HTMLTextAreaElement): void;
|
||||
|
||||
Vendored
+18
-1
@@ -3,5 +3,22 @@
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
export {};
|
||||
export { auto_resize, auto_scroll_to_bottom };
|
||||
function auto_resize(checkbox_element, target_element, max_height) {
|
||||
// if the user has manually resized their output, we do nothing
|
||||
if (checkbox_element.checked) {
|
||||
let target_height = 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, target_element) {
|
||||
if (checkbox_element.checked) {
|
||||
// scroll to bottom
|
||||
target_element.scrollTop = target_element.scrollHeight;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=libfewd.js.map
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"libfewd.js","sourceRoot":"","sources":["../ts/libfewd.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
||||
{"version":3,"file":"libfewd.js","sourceRoot":"","sources":["../ts/libfewd.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,WAAW,EACX,qBAAqB,EACxB,CAAC;AAGF,SACA,WAAW,CACN,gBAAmC,EACnC,cAAsC,EACtC,UAAyB;IAG1B,+DAA+D;IAC/D,IAAI,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,aAAa,GAAW,cAAc,CAAC,YAAY,CAAC;QACxD,sCAAsC;QACtC,IAAI,aAAa,GAAG,UAAU;YAC1B,cAAc,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;;YAE3D,cAAc,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAChE,CAAC;AACL,CAAC;AAGD,SACA,qBAAqB,CAChB,gBAAmC,EACnC,cAAsC;IAGvC,IAAI,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAC3B,mBAAmB;QACnB,cAAc,CAAC,SAAS,GAAG,cAAc,CAAC,YAAY,CAAC;IAC3D,CAAC;AACL,CAAC"}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Tetris
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
export {};
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Tetris
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
main();
|
||||
async function main() {
|
||||
let ws = new WebSocket("/ws/tetris");
|
||||
let elt_tetris_state = document.getElementById('tetris-state');
|
||||
ws.onmessage =
|
||||
(e) => {
|
||||
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, oelt) {
|
||||
let state_str = e.data;
|
||||
oelt.value = state_str;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=tetris.js.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"tetris.js","sourceRoot":"","sources":["../ts/tetris.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,IAAI,EAAE,CAAC;AAEP,KAAK,UACL,IAAI;IAIA,IAAI,EAAE,GAAuC,IAAI,SAAS,CAAC,YAAY,CAAC,CAAqC;IAC7G,IAAI,gBAAgB,GAAyB,QAAQ,CAAC,cAAc,CAAC,cAAc,CAAwB,CAAE;IAE7G,EAAE,CAAC,SAAS;QACR,CAAC,CAAe,EAAE,EAAE;YAChB,UAAU,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC;QACpC,CAAC,CAAA;AACT,CAAC;AAED,uDAAuD;AACvD,SAAS;AACT,uDAAuD;AAGvD;;;;;;GAMG;AACH,KAAK,UACL,UAAU,CACL,CAAmB,EACnB,IAA0B;IAG3B,IAAI,SAAS,GAAY,CAAC,CAAC,IAAc,CAAC;IAC1C,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;AAC3B,CAAC"}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user