Skip to content

Commit 8375c0c

Browse files
ConcedoConcedo
Concedo
authored and
Concedo
committed
tidy code
1 parent d783a19 commit 8375c0c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

index.html

+11-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
-->
1313

1414
<script>
15-
const LITEVER = 163;
15+
const LITEVER = 164;
1616
const urlParams = new URLSearchParams(window.location.search);
1717
const localflag = urlParams.get('local');
1818
const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_";
@@ -5945,7 +5945,7 @@
59455945
try {
59465946
let new_loaded_storyobj = JSON.parse(text);
59475947
//we don't want to fiddle with the file as its very complex. only handle the parts we are interested in, and just leave the rest untouched.
5948-
if (new_loaded_storyobj.prompt != null && !new_loaded_storyobj.scenarioVersion) {
5948+
if (is_kai_json(new_loaded_storyobj) && !new_loaded_storyobj.scenarioVersion) {
59495949
//quick sanity check. if prompt does not exist, this is not a KAI save.
59505950
kai_json_load(new_loaded_storyobj,false);
59515951
if (selectedFilename && selectedFilename != "") {
@@ -6043,6 +6043,12 @@
60436043
return (gametext_arr.length == 0 && current_memory == "" && current_anote == "" && current_wi.length == 0 && redo_arr.length == 0);
60446044
}
60456045

6046+
function is_kai_json(obj)
6047+
{
6048+
let is_kai = (!(tmpstory.prompt==null) || tmpstory.savedsettings!=null);
6049+
return is_kai;
6050+
}
6051+
60466052
function kai_json_load(storyobj, force_load_settngs)
60476053
{
60486054
//either show popup or just proceed to load
@@ -6151,7 +6157,7 @@
61516157
}
61526158
} else {
61536159
//v2 load
6154-
if(storyobj.prompt!="")
6160+
if(storyobj.prompt != "")
61556161
{
61566162
gametext_arr.push(storyobj.prompt);
61576163
}
@@ -6517,7 +6523,7 @@
65176523
{
65186524
console.log("Loading nai obj");
65196525
restart_new_game(false);
6520-
if(obj.prompt!="")
6526+
if(obj.prompt != "")
65216527
{
65226528
gametext_arr.push(obj.prompt);
65236529
}
@@ -8521,8 +8527,7 @@
85218527
.then(response => response.json())
85228528
.then(values5 => {
85238529
let tmpstory = values5;
8524-
let is_kai = !(tmpstory.prompt==null);
8525-
if(is_kai)
8530+
if(is_kai_json(tmpstory))
85268531
{
85278532
if (localsettings.persist_session && !safe_to_overwrite()) {
85288533
console.log("Preload story: Unsafe to overwrite");

0 commit comments

Comments
 (0)