Skip to content

Commit 190da3e

Browse files
Latest HTML
1 parent f634f1a commit 190da3e

File tree

9 files changed

+382
-133
lines changed

9 files changed

+382
-133
lines changed

docs/index.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5619,6 +5619,17 @@
56195619
})
56205620
}
56215621

5622+
function saveKLiteAutosaveToIndexDB(filename, data) {
5623+
let charName = filename.replaceAll(/[^\w()_\-'",!\[\].]/g, " ").replaceAll(/\s+/g, " ").trim();
5624+
let dataToSave = {
5625+
name: charName,
5626+
data: data
5627+
}
5628+
indexeddb_save(`character_${charName}`, JSON.stringify(dataToSave)).then(() => {
5629+
allCharacterNames.push({ name: charName, type: "Autosave" })
5630+
updateCharacterListFromAllDe();
5631+
})
5632+
}
56225633

56235634
function getTypeFromAllCharacterData(data)
56245635
{
@@ -8503,6 +8514,7 @@ <h4><li><a href="${reader.result}" class="color_blueurl" target="_blank" downloa
85038514
function generate_savefile(save_images,export_settings,export_aesthetic_settings) //takes the current loaded story and generates a new savefile json object
85048515
{
85058516
let new_save_storyobj = generate_base_storyobj();
8517+
new_save_storyobj.saveCreationDate = new Date().toUTCString();
85068518

85078519
let export_arr = gametext_arr;
85088520
let export_arr_no_img = [];
@@ -24995,7 +25007,8 @@ <h4><li><a href="${reader.result}" class="color_blueurl" target="_blank" downloa
2499525007

2499625008
function getCharacterData(characterName)
2499725009
{
24998-
return indexeddb_load(`character_${characterName}`, "{}").then(charData => {
25010+
let charName = characterName.replaceAll(/[^\w()_\-'",!\[\].]/g, " ").replaceAll(/\s+/g, " ").trim()
25011+
return indexeddb_load(`character_${charName}`, "{}").then(charData => {
2499925012
return JSON.parse(charData);
2500025013
});
2500125014
}

docs/static/css/esoStyling.css

Lines changed: 15 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/static/css/popupUtils.css

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@
4343
box-sizing: border-box;
4444
}
4545

46-
#popupContainer .popupContent input::placeholder,
47-
#popupContainer .popupContent textarea::placeholder {
48-
color: #666;
49-
}
50-
5146
.containAndScaleImage.tile {
5247
height: 128px;
5348
width: 128px;
@@ -83,7 +78,7 @@
8378
}
8479

8580
.characterCreatorGrid {
86-
color: white;
81+
color: var(--theme_color_text);
8782
padding: 10px;
8883
display: grid;
8984
grid-template-columns: 1fr 1fr;

docs/static/js/autosaveToServer.js

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,26 @@
11
let originalIndexDBSave = indexeddb_save
22
let numberOfActionsBetweenSaves = 5, currentTurn = 0
33
indexeddb_save = async (name, data) => {
4-
if (is_using_kcpp_with_server_saving() && !!localsettings?.enableAutosaveToServer) {
5-
if (name === "story") {
6-
if (currentTurn === numberOfActionsBetweenSaves) {
7-
try {
8-
await fetch(`${custom_kobold_endpoint}/api/data/delete`, {
9-
method: "POST",
10-
headers: getAuthHeaders(),
11-
body: JSON.stringify({ filename: "Autosave" })
12-
})
13-
.catch(e => {
14-
15-
})
16-
17-
let data = generate_compressed_story(true, true, true)
18-
let bodyData = {
19-
filename: "Autosave",
20-
data: btoa(data),
21-
type: "Save",
22-
isEncrypted: "0",
23-
group: "Public (can be accessed by anybody)",
24-
type: null,
25-
thumbnail: null
26-
};
27-
fetch(`${custom_kobold_endpoint}/api/data/put`, {
28-
method: "POST",
29-
body: JSON.stringify(bodyData),
30-
headers: getAuthHeaders()
31-
})
32-
.then(resp => resp.json())
33-
.catch(e => {
34-
handleError(e)
35-
})
36-
}
37-
catch (e) {
38-
console.error(e)
4+
if (name === "story") {
5+
if (currentTurn === numberOfActionsBetweenSaves)
6+
{
7+
try
8+
{
9+
let remoteDataSettings = JSON.parse(await indexeddb_load("remoteDataSettings"))
10+
if (!!remoteDataSettings) {
11+
let { remoteDataStorageUrl, autosaveName, autosaveMaxNumber, autosaveRemoteSync } = remoteDataSettings;
12+
await syncAutosave(autosaveName, true)
3913
}
40-
41-
currentTurn = 0
4214
}
43-
else {
44-
currentTurn++
15+
catch (e)
16+
{
17+
console.error("Error during autosave", e)
4518
}
19+
currentTurn = 0
20+
}
21+
else
22+
{
23+
currentTurn++
4624
}
4725
}
4826

0 commit comments

Comments
 (0)