Show confirmation dialog when navigating away from UI window

This commit is contained in:
Gnome Ann 2022-01-17 12:11:06 -05:00
parent cdf052cd03
commit 54a587d6a3
3 changed files with 13 additions and 7 deletions

View File

@ -3653,6 +3653,7 @@ def checkworldinfo(txt, allowed_entries=None, allowed_folders=None, force_use_tx
# Commit changes to Memory storage # Commit changes to Memory storage
#==================================================================# #==================================================================#
def memsubmit(data): def memsubmit(data):
emit('from_server', {'cmd': 'setinputtext', 'data': data}, broadcast=True)
# Maybe check for length at some point # Maybe check for length at some point
# For now just send it to storage # For now just send it to storage
vars.memory = data vars.memory = data
@ -3676,6 +3677,9 @@ def anotesubmit(data, template=""):
settingschanged() settingschanged()
vars.authornotetemplate = template vars.authornotetemplate = template
emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True)
emit('from_server', {'cmd': 'setanotetemplate', 'data': vars.authornotetemplate}, broadcast=True)
#==================================================================# #==================================================================#
# Assembles game data into a request to InferKit API # Assembles game data into a request to InferKit API
#==================================================================# #==================================================================#

View File

@ -806,9 +806,6 @@ function dosubmit(disallow_abort) {
hideMessage(); hideMessage();
hidegenseqs(); hidegenseqs();
socket.send({'cmd': 'submit', 'allowabort': !disallow_abort, '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();
}
} }
function changemode() { function changemode() {
@ -1772,7 +1769,7 @@ $(document).ready(function(){
seqselcontents = $("#seqselcontents"); seqselcontents = $("#seqselcontents");
// Connect to SocketIO server // Connect to SocketIO server
socket = io.connect(window.document.origin, {transports: ['polling', 'websocket']}); socket = io.connect(window.document.origin, {transports: ['polling', 'websocket'], closeOnBeforeunload: false});
socket.on('from_server', function(msg) { socket.on('from_server', function(msg) {
if(msg.cmd == "connected") { if(msg.cmd == "connected") {
@ -2536,5 +2533,10 @@ $(document).ready(function(){
sendSaveAsRequest(); sendSaveAsRequest();
} }
}); });
});
$(window).on("beforeunload", function() {
if(gamestarted || memorytext.length > 0 || $("#anoteinput").val().length > 0 || $(".wilistitem").length > 1) {
return true;
}
});
});

View File

@ -17,7 +17,7 @@
<script src="static/bootstrap.min.js"></script> <script src="static/bootstrap.min.js"></script>
<script src="static/bootstrap-toggle.min.js"></script> <script src="static/bootstrap-toggle.min.js"></script>
<script src="static/rangy-core.min.js"></script> <script src="static/rangy-core.min.js"></script>
<script src="static/application.js?ver=1.16.4z"></script> <script src="static/application.js?ver=1.16.4aa"></script>
</head> </head>
<body> <body>
<input type="file" id="remote-save-select" accept="application/json" style="display:none"> <input type="file" id="remote-save-select" accept="application/json" style="display:none">