Guard against empty prompts

This commit is contained in:
Gnome Ann
2021-09-28 19:48:43 -04:00
parent 4961273a26
commit 9ab1d182ac
3 changed files with 31 additions and 7 deletions

View File

@ -494,7 +494,11 @@ function returnWiList(ar) {
}
function dosubmit() {
var txt = input_text.val();
var txt = input_text.val().replace(/\u00a0/g, " ");
console.log(gamestarted)
if(!gamestarted && ((!adventure || !action_mode) && txt.trim().length == 0)) {
return;
}
socket.send({'cmd': 'submit', 'actionmode': adventure ? action_mode : 0, 'data': txt});
if(memorymode) {
memorytext = input_text.val();
@ -882,7 +886,7 @@ function syncAllModifiedChunks(including_selected_chunks=false) {
}
function restorePrompt() {
if(game_text[0].firstChild.nodeType === 3) {
if(game_text[0].firstChild && game_text[0].firstChild.nodeType === 3) {
saved_prompt = game_text[0].firstChild.textContent.replace(/\u00a0/g, " ");
unbindGametext();
game_text[0].innerText = "";