X-Git-Url: https://plomlompom.com/repos/?p=plomrogue2-experiments;a=blobdiff_plain;f=new2%2Frogue_chat_nocanvas_monochrome.html;h=096b6d55fa3f8eee0726999b57b1faa44bae5da6;hp=e8f7873eb3794407c53747938bfe6ec2e1ecd459;hb=40681bd38201ef0caf64a979c97318b090f5cbc0;hpb=24ccb759c7925aa91e87398280fc50a4e6123612 diff --git a/new2/rogue_chat_nocanvas_monochrome.html b/new2/rogue_chat_nocanvas_monochrome.html index e8f7873..096b6d5 100644 --- a/new2/rogue_chat_nocanvas_monochrome.html +++ b/new2/rogue_chat_nocanvas_monochrome.html @@ -11,8 +11,12 @@ let websocket_location = "ws://localhost:8000"; let terminal = { rows: 24, cols: 80, + foreground: 'white', + background: 'black', initialize: function() { this.pre_el = document.getElementById("terminal"); + this.pre_el.style.color = this.foreground; + this.pre_el.style.backgroundColor = this.background; this.content = []; let line = [] for (let y = 0, x = 0; y <= this.rows; x++) { @@ -28,6 +32,14 @@ let terminal = { line.push(' '); } }, + blink_screen: function() { + this.pre_el.style.color = this.background; + this.pre_el.style.backgroundColor = this.foreground; + setTimeout(() => { + this.pre_el.style.color = this.foreground; + this.pre_el.style.backgroundColor = this.background; + }, 100); + }, refresh: function() { let pre_string = ''; for (let y = 0; y < this.rows; y++) { @@ -257,8 +269,12 @@ let tui = { this.height_input = this.input_lines.length; }, shorten_input: function() { - this.input = tui.input.slice(0, -1); - this.recalc_input_lines(); + if (this.input.length == 0) { + terminal.blink_screen(); + } else { + this.input = tui.input.slice(0, -1); + this.recalc_input_lines(); + } }, draw_input: function() { terminal.drawBox(terminal.rows - this.height_input, this.window_width, this.height_input, this.window_width); @@ -385,6 +401,8 @@ server.websocket.onmessage = function (event) { } else if (tokens[0] === 'UNHANDLED_INPUT') { tui.log_msg('? unknown command'); tui.refresh(); + } else if (tokens[0] === 'PLAY_ERROR') { + terminal.blink_screen(); } else if (tokens[0] === 'ARGUMENT_ERROR') { tui.log_msg('? syntax error: ' + tokens[1]); tui.refresh();