mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Detect and show properly when story is unsaved
This commit is contained in:
42
aiserver.py
42
aiserver.py
@ -105,6 +105,7 @@ class vars:
|
|||||||
tfs = 1.0 # Default generator tfs (tail-free sampling)
|
tfs = 1.0 # Default generator tfs (tail-free sampling)
|
||||||
numseqs = 1 # Number of sequences to ask the generator to create
|
numseqs = 1 # Number of sequences to ask the generator to create
|
||||||
gamestarted = False # Whether the game has started (disables UI elements)
|
gamestarted = False # Whether the game has started (disables UI elements)
|
||||||
|
gamesaved = True # Whether or not current game is saved
|
||||||
serverstarted = False # Whether or not the Flask server has started
|
serverstarted = False # Whether or not the Flask server has started
|
||||||
prompt = "" # Prompt
|
prompt = "" # Prompt
|
||||||
memory = "" # Text submitted to memory field
|
memory = "" # Text submitted to memory field
|
||||||
@ -1646,6 +1647,7 @@ def lua_is_custommodel():
|
|||||||
#
|
#
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def execute_inmod():
|
def execute_inmod():
|
||||||
|
setgamesaved(False)
|
||||||
vars.lua_logname = ...
|
vars.lua_logname = ...
|
||||||
vars.lua_edited = set()
|
vars.lua_edited = set()
|
||||||
vars.lua_deleted = set()
|
vars.lua_deleted = set()
|
||||||
@ -1665,6 +1667,7 @@ def execute_genmod():
|
|||||||
vars.lua_koboldbridge.execute_genmod()
|
vars.lua_koboldbridge.execute_genmod()
|
||||||
|
|
||||||
def execute_outmod():
|
def execute_outmod():
|
||||||
|
setgamesaved(False)
|
||||||
emit('from_server', {'cmd': 'hidemsg', 'data': ''}, broadcast=True)
|
emit('from_server', {'cmd': 'hidemsg', 'data': ''}, broadcast=True)
|
||||||
try:
|
try:
|
||||||
tpool.execute(vars.lua_koboldbridge.execute_outmod)
|
tpool.execute(vars.lua_koboldbridge.execute_outmod)
|
||||||
@ -1732,7 +1735,7 @@ def do_connect():
|
|||||||
print("{0}Client connected!{1}".format(colors.GREEN, colors.END))
|
print("{0}Client connected!{1}".format(colors.GREEN, colors.END))
|
||||||
emit('from_server', {'cmd': 'setchatname', 'data': vars.chatname})
|
emit('from_server', {'cmd': 'setchatname', 'data': vars.chatname})
|
||||||
emit('from_server', {'cmd': 'setanotetemplate', 'data': vars.authornotetemplate})
|
emit('from_server', {'cmd': 'setanotetemplate', 'data': vars.authornotetemplate})
|
||||||
emit('from_server', {'cmd': 'connected', 'smandelete': vars.smandelete, 'smanrename': vars.smanrename})
|
emit('from_server', {'cmd': 'connected', 'smandelete': vars.smandelete, 'smanrename': vars.smanrename, 'modelname': getmodelname()})
|
||||||
if(vars.remote):
|
if(vars.remote):
|
||||||
emit('from_server', {'cmd': 'runs_remotely'})
|
emit('from_server', {'cmd': 'runs_remotely'})
|
||||||
if(vars.allowsp):
|
if(vars.allowsp):
|
||||||
@ -1772,6 +1775,8 @@ def do_connect():
|
|||||||
elif(vars.mode == "wi"):
|
elif(vars.mode == "wi"):
|
||||||
emit('from_server', {'cmd': 'wimode', 'data': 'true'})
|
emit('from_server', {'cmd': 'wimode', 'data': 'true'})
|
||||||
|
|
||||||
|
emit('from_server', {'cmd': 'gamesaved', 'data': vars.gamesaved}, broadcast=True)
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
# Event triggered when browser SocketIO sends data to the server
|
# Event triggered when browser SocketIO sends data to the server
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
@ -1936,6 +1941,7 @@ def get_message(msg):
|
|||||||
togglewimode()
|
togglewimode()
|
||||||
elif(msg['cmd'] == 'wiinit'):
|
elif(msg['cmd'] == 'wiinit'):
|
||||||
if(int(msg['data']) < len(vars.worldinfo)):
|
if(int(msg['data']) < len(vars.worldinfo)):
|
||||||
|
setgamesaved(False)
|
||||||
vars.worldinfo[msg['data']]["init"] = True
|
vars.worldinfo[msg['data']]["init"] = True
|
||||||
addwiitem(folder_uid=msg['folder'])
|
addwiitem(folder_uid=msg['folder'])
|
||||||
elif(msg['cmd'] == 'wifolderinit'):
|
elif(msg['cmd'] == 'wifolderinit'):
|
||||||
@ -1950,17 +1956,22 @@ def get_message(msg):
|
|||||||
deletewifolder(msg['data'])
|
deletewifolder(msg['data'])
|
||||||
elif(msg['cmd'] == 'wiexpand'):
|
elif(msg['cmd'] == 'wiexpand'):
|
||||||
assert 0 <= int(msg['data']) < len(vars.worldinfo)
|
assert 0 <= int(msg['data']) < len(vars.worldinfo)
|
||||||
|
setgamesaved(False)
|
||||||
emit('from_server', {'cmd': 'wiexpand', 'data': msg['data']}, broadcast=True)
|
emit('from_server', {'cmd': 'wiexpand', 'data': msg['data']}, broadcast=True)
|
||||||
elif(msg['cmd'] == 'wiexpandfolder'):
|
elif(msg['cmd'] == 'wiexpandfolder'):
|
||||||
assert 0 <= int(msg['data']) < len(vars.worldinfo)
|
assert 0 <= int(msg['data']) < len(vars.worldinfo)
|
||||||
|
setgamesaved(False)
|
||||||
emit('from_server', {'cmd': 'wiexpandfolder', 'data': msg['data']}, broadcast=True)
|
emit('from_server', {'cmd': 'wiexpandfolder', 'data': msg['data']}, broadcast=True)
|
||||||
elif(msg['cmd'] == 'wifoldercollapsecontent'):
|
elif(msg['cmd'] == 'wifoldercollapsecontent'):
|
||||||
|
setgamesaved(False)
|
||||||
vars.wifolders_d[msg['data']]['collapsed'] = True
|
vars.wifolders_d[msg['data']]['collapsed'] = True
|
||||||
emit('from_server', {'cmd': 'wifoldercollapsecontent', 'data': msg['data']}, broadcast=True)
|
emit('from_server', {'cmd': 'wifoldercollapsecontent', 'data': msg['data']}, broadcast=True)
|
||||||
elif(msg['cmd'] == 'wifolderexpandcontent'):
|
elif(msg['cmd'] == 'wifolderexpandcontent'):
|
||||||
|
setgamesaved(False)
|
||||||
vars.wifolders_d[msg['data']]['collapsed'] = False
|
vars.wifolders_d[msg['data']]['collapsed'] = False
|
||||||
emit('from_server', {'cmd': 'wifolderexpandcontent', 'data': msg['data']}, broadcast=True)
|
emit('from_server', {'cmd': 'wifolderexpandcontent', 'data': msg['data']}, broadcast=True)
|
||||||
elif(msg['cmd'] == 'wiupdate'):
|
elif(msg['cmd'] == 'wiupdate'):
|
||||||
|
setgamesaved(False)
|
||||||
num = int(msg['num'])
|
num = int(msg['num'])
|
||||||
fields = ("key", "keysecondary", "content", "comment")
|
fields = ("key", "keysecondary", "content", "comment")
|
||||||
for field in fields:
|
for field in fields:
|
||||||
@ -1968,6 +1979,7 @@ def get_message(msg):
|
|||||||
vars.worldinfo[num][field] = msg['data'][field]
|
vars.worldinfo[num][field] = msg['data'][field]
|
||||||
emit('from_server', {'cmd': 'wiupdate', 'num': msg['num'], 'data': {field: vars.worldinfo[num][field] for field in fields}}, broadcast=True)
|
emit('from_server', {'cmd': 'wiupdate', 'num': msg['num'], 'data': {field: vars.worldinfo[num][field] for field in fields}}, broadcast=True)
|
||||||
elif(msg['cmd'] == 'wifolderupdate'):
|
elif(msg['cmd'] == 'wifolderupdate'):
|
||||||
|
setgamesaved(False)
|
||||||
uid = int(msg['uid'])
|
uid = int(msg['uid'])
|
||||||
fields = ("name", "collapsed")
|
fields = ("name", "collapsed")
|
||||||
for field in fields:
|
for field in fields:
|
||||||
@ -1975,15 +1987,19 @@ def get_message(msg):
|
|||||||
vars.wifolders_d[uid][field] = msg['data'][field]
|
vars.wifolders_d[uid][field] = msg['data'][field]
|
||||||
emit('from_server', {'cmd': 'wifolderupdate', 'uid': msg['uid'], 'data': {field: vars.wifolders_d[uid][field] for field in fields}}, broadcast=True)
|
emit('from_server', {'cmd': 'wifolderupdate', 'uid': msg['uid'], 'data': {field: vars.wifolders_d[uid][field] for field in fields}}, broadcast=True)
|
||||||
elif(msg['cmd'] == 'wiselon'):
|
elif(msg['cmd'] == 'wiselon'):
|
||||||
|
setgamesaved(False)
|
||||||
vars.worldinfo[msg['data']]["selective"] = True
|
vars.worldinfo[msg['data']]["selective"] = True
|
||||||
emit('from_server', {'cmd': 'wiselon', 'data': msg['data']}, broadcast=True)
|
emit('from_server', {'cmd': 'wiselon', 'data': msg['data']}, broadcast=True)
|
||||||
elif(msg['cmd'] == 'wiseloff'):
|
elif(msg['cmd'] == 'wiseloff'):
|
||||||
|
setgamesaved(False)
|
||||||
vars.worldinfo[msg['data']]["selective"] = False
|
vars.worldinfo[msg['data']]["selective"] = False
|
||||||
emit('from_server', {'cmd': 'wiseloff', 'data': msg['data']}, broadcast=True)
|
emit('from_server', {'cmd': 'wiseloff', 'data': msg['data']}, broadcast=True)
|
||||||
elif(msg['cmd'] == 'wiconstanton'):
|
elif(msg['cmd'] == 'wiconstanton'):
|
||||||
|
setgamesaved(False)
|
||||||
vars.worldinfo[msg['data']]["constant"] = True
|
vars.worldinfo[msg['data']]["constant"] = True
|
||||||
emit('from_server', {'cmd': 'wiconstanton', 'data': msg['data']}, broadcast=True)
|
emit('from_server', {'cmd': 'wiconstanton', 'data': msg['data']}, broadcast=True)
|
||||||
elif(msg['cmd'] == 'wiconstantoff'):
|
elif(msg['cmd'] == 'wiconstantoff'):
|
||||||
|
setgamesaved(False)
|
||||||
vars.worldinfo[msg['data']]["constant"] = False
|
vars.worldinfo[msg['data']]["constant"] = False
|
||||||
emit('from_server', {'cmd': 'wiconstantoff', 'data': msg['data']}, broadcast=True)
|
emit('from_server', {'cmd': 'wiconstantoff', 'data': msg['data']}, broadcast=True)
|
||||||
elif(msg['cmd'] == 'sendwilist'):
|
elif(msg['cmd'] == 'sendwilist'):
|
||||||
@ -2279,6 +2295,15 @@ def settingschanged():
|
|||||||
print("{0}Saving settings!{1}".format(colors.GREEN, colors.END))
|
print("{0}Saving settings!{1}".format(colors.GREEN, colors.END))
|
||||||
savesettings()
|
savesettings()
|
||||||
|
|
||||||
|
#==================================================================#
|
||||||
|
# Set value of gamesaved
|
||||||
|
#==================================================================#
|
||||||
|
def setgamesaved(gamesaved):
|
||||||
|
assert type(gamesaved) is bool
|
||||||
|
if(gamesaved != vars.gamesaved):
|
||||||
|
emit('from_server', {'cmd': 'gamesaved', 'data': gamesaved}, broadcast=True)
|
||||||
|
vars.gamesaved = gamesaved
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
# Take input text from SocketIO and decide what to do with it
|
# Take input text from SocketIO and decide what to do with it
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
@ -3330,6 +3355,7 @@ def inlineedit(chunk, data):
|
|||||||
if(chunk-1 in vars.actions):
|
if(chunk-1 in vars.actions):
|
||||||
vars.actions[chunk-1] = data
|
vars.actions[chunk-1] = data
|
||||||
|
|
||||||
|
setgamesaved(False)
|
||||||
update_story_chunk(chunk)
|
update_story_chunk(chunk)
|
||||||
emit('from_server', {'cmd': 'texteffect', 'data': chunk}, broadcast=True)
|
emit('from_server', {'cmd': 'texteffect', 'data': chunk}, broadcast=True)
|
||||||
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
|
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
|
||||||
@ -3349,6 +3375,7 @@ def inlinedelete(chunk):
|
|||||||
else:
|
else:
|
||||||
if(chunk-1 in vars.actions):
|
if(chunk-1 in vars.actions):
|
||||||
del vars.actions[chunk-1]
|
del vars.actions[chunk-1]
|
||||||
|
setgamesaved(False)
|
||||||
remove_story_chunk(chunk)
|
remove_story_chunk(chunk)
|
||||||
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
|
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
|
||||||
|
|
||||||
@ -3418,6 +3445,7 @@ def addwifolder():
|
|||||||
# the WI entry with UID dst
|
# the WI entry with UID dst
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def movewiitem(dst, src):
|
def movewiitem(dst, src):
|
||||||
|
setgamesaved(False)
|
||||||
if(vars.worldinfo_u[src]["folder"] is not None):
|
if(vars.worldinfo_u[src]["folder"] is not None):
|
||||||
for i, e in enumerate(vars.wifolders_u[vars.worldinfo_u[src]["folder"]]):
|
for i, e in enumerate(vars.wifolders_u[vars.worldinfo_u[src]["folder"]]):
|
||||||
if(e is vars.worldinfo_u[src]):
|
if(e is vars.worldinfo_u[src]):
|
||||||
@ -3439,6 +3467,7 @@ def movewiitem(dst, src):
|
|||||||
# the WI folder with UID dst
|
# the WI folder with UID dst
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def movewifolder(dst, src):
|
def movewifolder(dst, src):
|
||||||
|
setgamesaved(False)
|
||||||
vars.wifolders_l.remove(src)
|
vars.wifolders_l.remove(src)
|
||||||
if(dst is None):
|
if(dst is None):
|
||||||
# If dst is None, that means we should move src to be the last folder
|
# If dst is None, that means we should move src to be the last folder
|
||||||
@ -3662,6 +3691,8 @@ def memsubmit(data):
|
|||||||
emit('from_server', {'cmd': 'setinputtext', 'data': data}, broadcast=True)
|
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
|
||||||
|
if(data != vars.memory):
|
||||||
|
setgamesaved(False)
|
||||||
vars.memory = data
|
vars.memory = data
|
||||||
vars.mode = "play"
|
vars.mode = "play"
|
||||||
emit('from_server', {'cmd': 'memmode', 'data': 'false'}, broadcast=True)
|
emit('from_server', {'cmd': 'memmode', 'data': 'false'}, broadcast=True)
|
||||||
@ -3676,6 +3707,8 @@ def anotesubmit(data, template=""):
|
|||||||
assert type(data) is str and type(template) is str
|
assert type(data) is str and type(template) is str
|
||||||
# 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
|
||||||
|
if(data != vars.authornote):
|
||||||
|
setgamesaved(False)
|
||||||
vars.authornote = data
|
vars.authornote = data
|
||||||
|
|
||||||
if(vars.authornotetemplate != template):
|
if(vars.authornotetemplate != template):
|
||||||
@ -3963,6 +3996,7 @@ def saveRequest(savpath):
|
|||||||
filename = filename[:-5]
|
filename = filename[:-5]
|
||||||
vars.laststory = filename
|
vars.laststory = filename
|
||||||
emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True)
|
emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True)
|
||||||
|
setgamesaved(True)
|
||||||
print("{0}Story saved to {1}!{2}".format(colors.GREEN, path.basename(savpath), colors.END))
|
print("{0}Story saved to {1}!{2}".format(colors.GREEN, path.basename(savpath), colors.END))
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
@ -4112,6 +4146,7 @@ def loadRequest(loadpath, filename=None):
|
|||||||
_filename = filename[:-5]
|
_filename = filename[:-5]
|
||||||
vars.laststory = _filename
|
vars.laststory = _filename
|
||||||
emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True)
|
emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True)
|
||||||
|
setgamesaved(True)
|
||||||
sendwi()
|
sendwi()
|
||||||
emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True)
|
emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True)
|
||||||
emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True)
|
emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True)
|
||||||
@ -4319,6 +4354,7 @@ def importgame():
|
|||||||
# Refresh game screen
|
# Refresh game screen
|
||||||
vars.laststory = None
|
vars.laststory = None
|
||||||
emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True)
|
emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True)
|
||||||
|
setgamesaved(False)
|
||||||
sendwi()
|
sendwi()
|
||||||
emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True)
|
emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True)
|
||||||
emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True)
|
emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True)
|
||||||
@ -4399,6 +4435,7 @@ def importAidgRequest(id):
|
|||||||
# Refresh game screen
|
# Refresh game screen
|
||||||
vars.laststory = None
|
vars.laststory = None
|
||||||
emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True)
|
emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True)
|
||||||
|
setgamesaved(False)
|
||||||
sendwi()
|
sendwi()
|
||||||
emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True)
|
emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True)
|
||||||
emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True)
|
emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True)
|
||||||
@ -4456,6 +4493,7 @@ def wiimportrequest():
|
|||||||
print("{0}".format(vars.worldinfo[0]))
|
print("{0}".format(vars.worldinfo[0]))
|
||||||
|
|
||||||
# Refresh game screen
|
# Refresh game screen
|
||||||
|
setgamesaved(False)
|
||||||
sendwi()
|
sendwi()
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
@ -4488,6 +4526,7 @@ def newGameRequest():
|
|||||||
# Refresh game screen
|
# Refresh game screen
|
||||||
vars.laststory = None
|
vars.laststory = None
|
||||||
emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True)
|
emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True)
|
||||||
|
setgamesaved(True)
|
||||||
sendwi()
|
sendwi()
|
||||||
emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True)
|
emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True)
|
||||||
emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True)
|
emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True)
|
||||||
@ -4501,6 +4540,7 @@ def randomGameRequest(topic, memory=""):
|
|||||||
vars.recentrng = topic
|
vars.recentrng = topic
|
||||||
vars.recentrngm = memory
|
vars.recentrngm = memory
|
||||||
newGameRequest()
|
newGameRequest()
|
||||||
|
setgamesaved(False)
|
||||||
_memory = memory
|
_memory = memory
|
||||||
if(len(memory) > 0):
|
if(len(memory) > 0):
|
||||||
_memory = memory.rstrip() + "\n\n"
|
_memory = memory.rstrip() + "\n\n"
|
||||||
|
@ -93,6 +93,8 @@ var sman_allow_rename = false;
|
|||||||
var allowsp = false;
|
var allowsp = false;
|
||||||
var remote = false;
|
var remote = false;
|
||||||
var gamestate = "";
|
var gamestate = "";
|
||||||
|
var gamesaved = true;
|
||||||
|
var modelname = null;
|
||||||
|
|
||||||
// This is true iff [we're in macOS and the browser is Safari] or [we're in iOS]
|
// This is true iff [we're in macOS and the browser is Safari] or [we're in iOS]
|
||||||
var using_webkit_patch = true;
|
var using_webkit_patch = true;
|
||||||
@ -169,6 +171,23 @@ function addSetting(ob) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshTitle() {
|
||||||
|
var title = gamesaved ? "" : "\u2731 ";
|
||||||
|
if(storyname !== null) {
|
||||||
|
title += storyname + " \u2014 ";
|
||||||
|
}
|
||||||
|
title += "KoboldAI Client";
|
||||||
|
if(modelname !== null) {
|
||||||
|
title += " (" + modelname + ")";
|
||||||
|
}
|
||||||
|
document.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setGameSaved(state) {
|
||||||
|
gamesaved = !!state;
|
||||||
|
refreshTitle();
|
||||||
|
}
|
||||||
|
|
||||||
function addFormat(ob) {
|
function addFormat(ob) {
|
||||||
// Check if we need to make a new column for this button
|
// Check if we need to make a new column for this button
|
||||||
if(formatcount == 0) {
|
if(formatcount == 0) {
|
||||||
@ -1780,6 +1799,10 @@ $(document).ready(function(){
|
|||||||
sman_allow_delete = msg.hasOwnProperty("smandelete") && msg.smandelete;
|
sman_allow_delete = msg.hasOwnProperty("smandelete") && msg.smandelete;
|
||||||
sman_allow_rename = msg.hasOwnProperty("smanrename") && msg.smanrename;
|
sman_allow_rename = msg.hasOwnProperty("smanrename") && msg.smanrename;
|
||||||
connected = true;
|
connected = true;
|
||||||
|
if(msg.hasOwnProperty("modelname")) {
|
||||||
|
modelname = msg.modelname;
|
||||||
|
}
|
||||||
|
refreshTitle();
|
||||||
connect_status.html("<b>Connected to KoboldAI Process!</b>");
|
connect_status.html("<b>Connected to KoboldAI Process!</b>");
|
||||||
connect_status.removeClass("color_orange");
|
connect_status.removeClass("color_orange");
|
||||||
connect_status.addClass("color_green");
|
connect_status.addClass("color_green");
|
||||||
@ -1911,6 +1934,7 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
} else if(msg.cmd == "setstoryname") {
|
} else if(msg.cmd == "setstoryname") {
|
||||||
storyname = msg.data;
|
storyname = msg.data;
|
||||||
|
refreshTitle();
|
||||||
} else if(msg.cmd == "editmode") {
|
} else if(msg.cmd == "editmode") {
|
||||||
// Enable or Disable edit mode
|
// Enable or Disable edit mode
|
||||||
if(msg.data == "true") {
|
if(msg.data == "true") {
|
||||||
@ -2141,6 +2165,8 @@ $(document).ready(function(){
|
|||||||
} else if(msg.cmd == "saveas") {
|
} else if(msg.cmd == "saveas") {
|
||||||
// Show Save As prompt
|
// Show Save As prompt
|
||||||
showSaveAsPopup();
|
showSaveAsPopup();
|
||||||
|
} else if(msg.cmd == "gamesaved") {
|
||||||
|
setGameSaved(msg.data);
|
||||||
} else if(msg.cmd == "hidesaveas") {
|
} else if(msg.cmd == "hidesaveas") {
|
||||||
// Hide Save As prompt
|
// Hide Save As prompt
|
||||||
hideSaveAsPopup();
|
hideSaveAsPopup();
|
||||||
@ -2537,8 +2563,12 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$([input_text, anote_input, $("#gamescreen")]).map($.fn.toArray).on("input", function() {
|
||||||
|
setGameSaved(false);
|
||||||
|
});
|
||||||
|
|
||||||
$(window).on("beforeunload", function() {
|
$(window).on("beforeunload", function() {
|
||||||
if(gamestarted || memorytext.length > 0 || $("#anoteinput").val().length > 0 || $(".wilistitem").length > 1) {
|
if(!gamesaved) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -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.4ab"></script>
|
<script src="static/application.js?ver=1.16.4ac"></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">
|
||||||
|
Reference in New Issue
Block a user