diff --git a/aiserver.py b/aiserver.py index f34734ae..ee7572e0 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1429,6 +1429,8 @@ def inlinedelete(chunk): # Don't delete prompt if(chunk == 0): # Send error message + refresh_story() + emit('from_server', {'cmd': 'errmsg', 'data': "Cannot delete the prompt."}) emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True) else: del vars.actions[chunk-1] diff --git a/static/application.js b/static/application.js index 9e663874..6626f24f 100644 --- a/static/application.js +++ b/static/application.js @@ -622,7 +622,9 @@ function setadventure(state) { function autofocus(event) { if(connected) { - current_editing_chunk = event.target; + if(event.target.tagName == "CHUNK") { + current_editing_chunk = event.target; + } event.target.focus(); } else { event.preventDefault(); @@ -644,11 +646,17 @@ function chunkOnKeyDown(event) { switch(event.keyCode) { case 37: // left case 39: // right - old_selection_offset = getSelection().focusOffset; + old_range = getSelection().getRangeAt(0); + old_range_start = old_range.startOffset; + old_range_end = old_range.endOffset; + old_range_ancestor = old_range.commonAncestorContainer; + old_range_start_container = old_range.startContainer; + old_range_end_container = old_range.endContainer; setTimeout(function () { // Wait a few milliseconds and check if the caret has moved new_selection = getSelection(); - if(old_selection_offset != new_selection.focusOffset) { + new_range = new_selection.getRangeAt(0); + if(old_range_start != new_range.startOffset || old_range_end != new_range.endOffset || old_range_ancestor != new_range.commonAncestorContainer || old_range_start_container != new_range.startContainer || old_range_end_container != new_range.endContainer) { return; } // If it hasn't moved, we're at the beginning or end of a chunk @@ -850,6 +858,7 @@ $(document).ready(function(){ }, 5); } newly_loaded = false; + hideMessage(); } else if(msg.cmd == "scrolldown") { setTimeout(function () { $('#gamescreen').animate({scrollTop: $('#gamescreen').prop('scrollHeight')}, 1000);