This commit is contained in:
thepaperpilot 2023-11-07 00:46:27 +00:00
parent 4de3b9bf94
commit bb365c434a
879 changed files with 55528 additions and 0 deletions
the_ascension_tree/js

View file

@ -0,0 +1,45 @@
const SAVENAME = "tahperaislcfeonodlesd";
function local_save() {
localStorage.setItem(SAVENAME, JSON.stringify(player.save()));
}
function local_load() {
if (SAVENAME in localStorage) player.load(JSON.parse(localStorage.getItem(SAVENAME)));
}
function hard_reset(seed) {
localStorage.removeItem(SAVENAME);
player.reset(seed);
player.current_layer.selectLayer();
}
// those two are not used
async function import_save() {
player.load(JSON.parse(atob(await navigator.clipboard.readText())));
}
function export_save() {
navigator.clipboard.writeText(btoa(JSON.stringify(player.save())));
}
//
function exportToClipboard() {
navigator.clipboard.writeText(document.getElementById('export_save').value);
}
function importFromClipboard() {
navigator.clipboard.readText().then(clipText => document.getElementById('import_save').value = clipText);
}
function importSave() {
let backup = player.save();
try {
player.load(JSON.parse(atob(document.getElementById('import_save').value)));
closeModal();
}
catch (e) {
player.load(backup);
}
}