From: Christian Heller Date: Sat, 31 Oct 2020 10:10:14 +0000 (+0100) Subject: Refactor cols, rows initialization. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/static/todos?a=commitdiff_plain;h=506e675d9cd9364686a8ee91f8574dcfea27e51a;p=plomrogue2-experiments Refactor cols, rows initialization. --- diff --git a/new2/rogue_chat_nocanvas_monochrome.html b/new2/rogue_chat_nocanvas_monochrome.html index 2c196d4..ffe0132 100644 --- a/new2/rogue_chat_nocanvas_monochrome.html +++ b/new2/rogue_chat_nocanvas_monochrome.html @@ -17,12 +17,16 @@ cols: "use strict"; let websocket_location = "ws://localhost:8000"; +let wasd_selector = document.getElementById("WASD_selector"); +let rows_selector = document.getElementById("n_rows"); +let cols_selector = document.getElementById("n_cols"); + let terminal = { - rows: 24, - cols: 80, foreground: 'white', background: 'black', initialize: function() { + this.rows = rows_selector.value; + this.cols = cols_selector.value; this.pre_el = document.getElementById("terminal"); this.pre_el.style.color = this.foreground; this.pre_el.style.backgroundColor = this.background; @@ -77,6 +81,7 @@ let terminal = { } }, } +terminal.initialize(); let parser = { tokenize: function(str) { @@ -374,7 +379,6 @@ let game = { player_id: -1 } -terminal.initialize(); tui.init(); tui.full_refresh(); @@ -575,7 +579,6 @@ tui.inputEl.addEventListener('keydown', (event) => { } }, false); -let wasd_selector = document.getElementById("WASD_selector"); wasd_selector.addEventListener('input', function() { if (wasd_selector.value == 'w, a, s, d') { tui.key_up = 'w'; @@ -590,15 +593,11 @@ wasd_selector.addEventListener('input', function() { }; tui.movement_keys_desc = wasd_selector.value; }, false); -let rows_selector = document.getElementById("n_rows"); rows_selector.addEventListener('input', function() { - terminal.rows = rows_selector.value; terminal.initialize(); tui.full_refresh(); }, false); -let cols_selector = document.getElementById("n_cols"); cols_selector.addEventListener('input', function() { - terminal.cols = cols_selector.value; terminal.initialize(); tui.window_width = terminal.cols / 2, tui.full_refresh();