Allow pressing send button again to stop generation

This commit is contained in:
Gnome Ann
2022-01-10 16:36:15 -05:00
parent c84d864021
commit f718fdf65e
4 changed files with 40 additions and 16 deletions

View File

@ -92,6 +92,7 @@ var sman_allow_delete = false;
var sman_allow_rename = false;
var allowsp = false;
var remote = false;
var gamestate = "";
// This is true iff [we're in macOS and the browser is Safari] or [we're in iOS]
var using_webkit_patch = true;
@ -648,12 +649,14 @@ function disableButtons(refs) {
}
function enableSendBtn() {
enableButtons([button_send])
button_send.removeClass("wait");
button_send.addClass("btn-primary");
button_send.html("Submit");
}
function disableSendBtn() {
disableButtons([button_send])
button_send.removeClass("btn-primary");
button_send.addClass("wait");
button_send.html("");
}
@ -794,15 +797,15 @@ function formatChunkInnerText(chunk) {
return text;
}
function dosubmit() {
function dosubmit(disallow_abort) {
var txt = input_text.val().replace(/\u00a0/g, " ");
if(!memorymode && !gamestarted && ((!adventure || !action_mode) && txt.trim().length == 0)) {
if(gamestate !== "wait" && !memorymode && !gamestarted && ((!adventure || !action_mode) && txt.trim().length == 0)) {
return;
}
input_text.val("");
hideMessage();
hidegenseqs();
socket.send({'cmd': 'submit', 'actionmode': adventure ? action_mode : 0, 'chatname': chatmode ? chat_name.val() : undefined, 'data': txt});
socket.send({'cmd': 'submit', 'allowabort': !disallow_abort, 'actionmode': adventure ? action_mode : 0, 'chatname': chatmode ? chat_name.val() : undefined, 'data': txt});
if(memorymode) {
memorytext = input_text.val();
}
@ -1889,12 +1892,15 @@ $(document).ready(function(){
enableSendBtn();
enableButtons([button_actmem, button_actwi, button_actback, button_actretry]);
hideWaitAnimation();
gamestate = "ready";
} else if(msg.data == "wait") {
gamestate = "wait";
disableSendBtn();
disableButtons([button_actmem, button_actwi, button_actback, button_actretry]);
showWaitAnimation();
} else if(msg.data == "start") {
setStartState();
gamestate = "ready";
}
} else if(msg.cmd == "allowsp") {
allowsp = !!msg.data;
@ -2495,7 +2501,7 @@ $(document).ready(function(){
input_text.keydown(function (ev) {
if (ev.which == 13 && !shift_down) {
do_clear_ent = true;
dosubmit();
dosubmit(true);
} else if(ev.which == 16) {
shift_down = true;
}