mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 01:17:22 +00:00
Use localStorage for saves
This commit is contained in:
parent
881043f4cb
commit
76ffe39348
3 changed files with 23 additions and 7 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
|
@ -5681,6 +5681,11 @@
|
|||
"yallist": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"lz-string": {
|
||||
"version": "1.4.4",
|
||||
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.4.4.tgz",
|
||||
"integrity": "sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY="
|
||||
},
|
||||
"magic-string": {
|
||||
"version": "0.22.5",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz",
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
"dependencies": {
|
||||
"cheap-glkote": "^0.2.4",
|
||||
"emglken": "^0.3.3",
|
||||
"lz-string": "^1.4.4",
|
||||
"preact": "^10.5.12",
|
||||
"wouter-preact": "^2.7.3"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import { h } from 'preact'
|
||||
import { useState, useEffect } from 'preact/hooks'
|
||||
import {
|
||||
compressToUTF16 as encode,
|
||||
decompressFromUTF16 as decode
|
||||
} from 'lz-string'
|
||||
|
||||
import CheapGlkOte from 'cheap-glkote'
|
||||
|
||||
|
|
@ -48,12 +52,17 @@ const Handlers = ({
|
|||
},
|
||||
onFileRead: ({ filename }) => {
|
||||
if (filename === 'save') return null
|
||||
const token = prompt('Enter your SAVE_TOKEN here')
|
||||
return token
|
||||
|
||||
const lsName = prompt('Enter RecordID:')
|
||||
|
||||
const record = localStorage.getItem(`save-${lsName}`)
|
||||
return decode(record)
|
||||
},
|
||||
onFileWrite: ({ filename }, content) => {
|
||||
const token = content
|
||||
prompt('Copy your SAVE_TOKEN', token)
|
||||
const lsName = prompt('Choose RecordID:')
|
||||
const record = encode(content)
|
||||
|
||||
localStorage.setItem(`save-${lsName}`, record)
|
||||
},
|
||||
/* */
|
||||
onExit: _ => setInputType(null)
|
||||
|
|
@ -94,15 +103,16 @@ export default function ({ vmParts: { file, engine } }) {
|
|||
|
||||
return status.stage !== 'ready'
|
||||
? (<div>{status.details}</div>)
|
||||
: (<section>
|
||||
: (
|
||||
<section>
|
||||
<TextBuffer {...{
|
||||
inbox,
|
||||
currentWindow
|
||||
}}/>
|
||||
}} />
|
||||
<InputBox {...{
|
||||
currentWindow,
|
||||
inputType,
|
||||
sendMessage
|
||||
}}/>
|
||||
}} />
|
||||
</section>)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue