Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • Arkerthan/sugarcube-2
  • franklygeorge/sugarcube-2
  • bcy603/sugarcube-2
3 results
Show changes
Commits on Source (6)
......@@ -125,7 +125,7 @@ SimpleStore.adapters.push((() => {
return value == null ? null : _WebStorageAdapter._deserialize(value); // lazy equality for null
}
set(key, value) {
set(key, value, compression = true) {
if (DEBUG) { console.log(`[<SimpleStore:${this.name}>.set(key: "${key}", value: \u2026) : Boolean]`); }
if (typeof key !== 'string' || !key) {
......@@ -133,7 +133,8 @@ SimpleStore.adapters.push((() => {
}
try {
this._engine.setItem(this._prefix + key, _WebStorageAdapter._serialize(value));
this._engine.setItem(this._prefix + key,
_WebStorageAdapter._serialize(value, this.persistent && compression));
}
catch (ex) {
/*
......@@ -188,7 +189,10 @@ SimpleStore.adapters.push((() => {
return true;
}
static _serialize(obj) {
static _serialize(obj, compression) {
if (compression) {
return LZString.compressToUTF16(JSON.stringify(obj));
}
return JSON.stringify(obj);
}
......
......@@ -175,7 +175,7 @@ var Save = (() => { // eslint-disable-line no-unused-vars, no-var
function savesObjClear() {
storage.delete('autosave');
const index = indexGet();
for (let i = 0; i < index.saves.length; i++) {
for (let i = 0; i < index.slots.length; i++) {
storage.delete(`slot${i}`);
}
storage.delete('index');
......@@ -234,7 +234,7 @@ var Save = (() => { // eslint-disable-line no-unused-vars, no-var
}
try {
return storage.set('autosave', _marshal(supplemental));
return storage.set('autosave', _marshal(supplemental), false);
} catch (ex) {
index.autosave = null;
indexSave(index);
......
......@@ -331,7 +331,7 @@ var UI = (() => { // eslint-disable-line no-unused-vars, no-var
// Add the slot ID.
$tdSlot.append(document.createTextNode(i + 1));
if (saves.slots[i]) {
if (index.slots[i]) {
// Add the save & load buttons.
$tdLoad.append(
createButton('save', 'ui-close', L10n.get('savesLabelSave'), i, Save.slots.save),
......