Do a better job of preventing editing of text when required

This commit is contained in:
Gnome Ann 2021-09-28 00:48:37 -04:00
parent f632ad9880
commit 231290608d
2 changed files with 5 additions and 5 deletions

View File

@ -956,7 +956,7 @@ def actionsubmit(data, actionmode=0):
vars.prompt = data vars.prompt = data
if(not vars.noai): if(not vars.noai):
# Clear the startup text from game screen # Clear the startup text from game screen
emit('from_server', {'cmd': 'updatescreen', 'gamestarted': vars.gamestarted, 'data': 'Please wait, generating story...'}, broadcast=True) emit('from_server', {'cmd': 'updatescreen', 'gamestarted': False, 'data': 'Please wait, generating story...'}, broadcast=True)
calcsubmit(data) # Run the first action through the generator calcsubmit(data) # Run the first action through the generator
emit('from_server', {'cmd': 'scrolldown', 'data': ''}, broadcast=True) emit('from_server', {'cmd': 'scrolldown', 'data': ''}, broadcast=True)
else: else:

View File

@ -944,7 +944,7 @@ function highlightEditingChunks() {
// This gets run every time the text in a chunk is edited // This gets run every time the text in a chunk is edited
// or a chunk is deleted // or a chunk is deleted
function chunkOnDOMMutate(mutations, observer) { function chunkOnDOMMutate(mutations, observer) {
if(!gametext_bound) { if(!gametext_bound || !allowedit) {
return; return;
} }
var nodes = []; var nodes = [];
@ -971,7 +971,7 @@ function chunkOnPaste(event) {
// This gets run every time the caret moves in the editor // This gets run every time the caret moves in the editor
function chunkOnSelectionChange(event) { function chunkOnSelectionChange(event) {
if(!gametext_bound || override_focusout) { if(!gametext_bound || !allowedit || override_focusout) {
override_focusout = false; override_focusout = false;
return; return;
} }
@ -992,7 +992,7 @@ function chunkOnSelectionChange(event) {
// This gets run when you defocus the editor by clicking // This gets run when you defocus the editor by clicking
// outside of the editor or by pressing escape or tab // outside of the editor or by pressing escape or tab
function chunkOnFocusOut(event) { function chunkOnFocusOut(event) {
if(!gametext_bound || event.target !== game_text[0]) { if(!gametext_bound || !allowedit || event.target !== game_text[0]) {
return; return;
} }
setTimeout(function() { setTimeout(function() {
@ -1108,7 +1108,7 @@ $(document).ready(function(){
$('body').on('input', autofocus); $('body').on('input', autofocus);
$('#allowediting').prop('checked', allowedit).prop('disabled', false).change().off('change').on('change', function () { $('#allowediting').prop('checked', allowedit).prop('disabled', false).change().off('change').on('change', function () {
if(allowtoggle) { if(allowtoggle) {
allowedit = $(this).prop('checked'); allowedit = gamestarted && $(this).prop('checked');
game_text.attr('contenteditable', allowedit); game_text.attr('contenteditable', allowedit);
} }
}); });