As I work on implementing a feature where a small JSON object is written to the URL as a user interacts with items on a page, I also want to make sure the URL can be read later so users can resume where they left off.
I successfully managed to create the zip file using JSZip, but I'm struggling to find the right approach to open the zip from the base64 string. Here's the snippet of code I've been trying to work with. While zip.file contains elements, I need help figuring out how to decode the base64 string back into zip2 for it to be opened.
var figures = [{
"qty": 1,
"name": "",
"level": 1,
"defense": 1,
"melee": 3,
"ranged": 1,
"abilities": [
"c02","c12","c22","c32","t12"
]
},{
"qty": 1,
"name": "",
"level": 1,
"defense": 2,
"melee": 1,
"ranged": 1,
"abilities": [
"c02","c12","c22","c32","t45"
]
},{
"qty": 1,
"name": "",
"level": 4,
"defense": 1,
"melee": 1,
"ranged": 5,
"abilities": [
"c01","c14","c23","c35"
]
}]
var zip = new JSZip()
zip.file = figures
var urlString = zip.generate({type:"base64"})
location.href="#"+ urlString
console.log(urlString)
console.log(zip)
var zip2 = new JSZip()
zip2.load(urlString,{"base64": true})
console.log(zip2)