home
·
contact
·
privacy
projects
/
plomrogue2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Minor refactor.
[plomrogue2]
/
rogue_chat_nocanvas_monochrome.html
diff --git
a/rogue_chat_nocanvas_monochrome.html
b/rogue_chat_nocanvas_monochrome.html
index 6093f9553994b4c73a747f04ee581c1697d434e6..c50a12f20c0f717d39a5d4911029de170f0d7f6b 100644
(file)
--- a/
rogue_chat_nocanvas_monochrome.html
+++ b/
rogue_chat_nocanvas_monochrome.html
@@
-4,8
+4,8
@@
</style>
</head><body>
<div>
</style>
</head><body>
<div>
-terminal rows: <input id="n_rows" type="number" step=4 min=
8
value=24 />
-terminal columns: <input id="n_cols" type="number" step=4 min=
2
0 value=80 />
+terminal rows: <input id="n_rows" type="number" step=4 min=
24
value=24 />
+terminal columns: <input id="n_cols" type="number" step=4 min=
8
0 value=80 />
</div>
<pre id="terminal" style="display: inline-block;"></pre>
<textarea id="input" style="opacity: 0; width: 0px;"></textarea>
</div>
<pre id="terminal" style="display: inline-block;"></pre>
<textarea id="input" style="opacity: 0; width: 0px;"></textarea>
@@
-61,6
+61,7
@@
terminal columns: <input id="n_cols" type="number" step=4 min=20 value=80 />
<script>
"use strict";
let websocket_location = "wss://plomlompom.com/rogue_chat/";
<script>
"use strict";
let websocket_location = "wss://plomlompom.com/rogue_chat/";
+//let websocket_location = "ws://localhost:8000/";
let rows_selector = document.getElementById("n_rows");
let cols_selector = document.getElementById("n_cols");
let rows_selector = document.getElementById("n_rows");
let cols_selector = document.getElementById("n_cols");
@@
-279,6
+280,7
@@
let server = {
} else if (tokens[0] === 'UNHANDLED_INPUT') {
tui.log_msg('? unknown command');
} else if (tokens[0] === 'PLAY_ERROR') {
} else if (tokens[0] === 'UNHANDLED_INPUT') {
tui.log_msg('? unknown command');
} else if (tokens[0] === 'PLAY_ERROR') {
+ tui.log_msg('? ' + tokens[1]);
terminal.blink_screen();
} else if (tokens[0] === 'ARGUMENT_ERROR') {
tui.log_msg('? syntax error: ' + tokens[1]);
terminal.blink_screen();
} else if (tokens[0] === 'ARGUMENT_ERROR') {
tui.log_msg('? syntax error: ' + tokens[1]);
@@
-379,6
+381,7
@@
let tui = {
};
},
switch_mode: function(mode) {
};
},
switch_mode: function(mode) {
+ this.inputEl.focus();
this.show_help = false;
this.map_mode = 'terrain';
if (mode.shows_info && game.player_id in game.things) {
this.show_help = false;
this.map_mode = 'terrain';
if (mode.shows_info && game.player_id in game.things) {
@@
-861,7
+864,6
@@
tui.inputEl.addEventListener('input', (event) => {
}
tui.full_refresh();
}, false);
}
tui.full_refresh();
}, false);
-
tui.inputEl.addEventListener('keydown', (event) => {
tui.show_help = false;
if (event.key == 'Enter') {
tui.inputEl.addEventListener('keydown', (event) => {
tui.show_help = false;
if (event.key == 'Enter') {
@@
-890,7
+892,7
@@
tui.inputEl.addEventListener('keydown', (event) => {
tui.password = tui.inputEl.value
tui.switch_mode(mode_play);
} else if (tui.mode == mode_chat && event.key == 'Enter') {
tui.password = tui.inputEl.value
tui.switch_mode(mode_play);
} else if (tui.mode == mode_chat && event.key == 'Enter') {
- let
[tokens, token_starts]
= parser.tokenize(tui.inputEl.value);
+ let
tokens
= parser.tokenize(tui.inputEl.value);
if (tokens.length > 0 && tokens[0].length > 0) {
if (tui.inputEl.value[0][0] == '/') {
if (tokens[0].slice(1) == 'play' || tokens[0][1] == tui.keys.switch_to_play) {
if (tokens.length > 0 && tokens[0].length > 0) {
if (tui.inputEl.value[0][0] == '/') {
if (tokens[0].slice(1) == 'play' || tokens[0][1] == tui.keys.switch_to_play) {
@@
-967,7
+969,7
@@
tui.inputEl.addEventListener('keydown', (event) => {
}, false);
rows_selector.addEventListener('input', function() {
}, false);
rows_selector.addEventListener('input', function() {
- if (rows_selector.value % 4 != 0) {
+ if (rows_selector.value % 4 != 0
|| rows_selector.value < 24
) {
return;
}
window.localStorage.setItem(rows_selector.id, rows_selector.value);
return;
}
window.localStorage.setItem(rows_selector.id, rows_selector.value);
@@
-975,7
+977,7
@@
rows_selector.addEventListener('input', function() {
tui.full_refresh();
}, false);
cols_selector.addEventListener('input', function() {
tui.full_refresh();
}, false);
cols_selector.addEventListener('input', function() {
- if (cols_selector.value % 4 != 0) {
+ if (cols_selector.value % 4 != 0
|| cols_selector.value < 80
) {
return;
}
window.localStorage.setItem(cols_selector.id, cols_selector.value);
return;
}
window.localStorage.setItem(cols_selector.id, cols_selector.value);
@@
-989,12
+991,6
@@
for (let key_selector of key_selectors) {
tui.init_keys();
}, false);
}
tui.init_keys();
}, false);
}
-window.setInterval(function() {
- if (!(['input', 'n_cols', 'n_rows'].includes(document.activeElement.id)
- || document.activeElement.id.startsWith('key_'))) {
- tui.inputEl.focus();
- }
-}, 100);
window.setInterval(function() {
if (server.connected) {
server.send(['PING']);
window.setInterval(function() {
if (server.connected) {
server.send(['PING']);
@@
-1003,7
+999,9
@@
window.setInterval(function() {
tui.log_msg('@ attempting reconnect …')
}
}, 5000);
tui.log_msg('@ attempting reconnect …')
}
}, 5000);
-
+document.getElementById("terminal").onclick = function() {
+ tui.inputEl.focus();
+};
document.getElementById("help").onclick = function() {
tui.show_help = true;
tui.full_refresh();
document.getElementById("help").onclick = function() {
tui.show_help = true;
tui.full_refresh();