|
@ -0,0 +1,38 @@ |
|
|
|
|
|
var dataToStore = [ |
|
|
|
|
|
"file___0001.mp4", |
|
|
|
|
|
"file___0002.mp4", |
|
|
|
|
|
"file___0003.mp4", |
|
|
|
|
|
"file___0004.mp4", |
|
|
|
|
|
"file___0005.mp4", |
|
|
|
|
|
"file___0006.mp4", |
|
|
|
|
|
"file___0007.mp4", |
|
|
|
|
|
"file___0008.mp4", |
|
|
|
|
|
"file___0009.mp4", |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
let configKey = "video-files"; |
|
|
|
|
|
|
|
|
|
|
|
var restoreHere = null; // variable where we will restore the data that we read from localStorage
|
|
|
|
|
|
|
|
|
|
|
|
// clear all items for this origin on localStorage
|
|
|
|
|
|
for (var item in localStorage) delete localStorage[item] |
|
|
|
|
|
|
|
|
|
|
|
// store the contents of the variable `dataToStore` in the localStorage
|
|
|
|
|
|
// data to be stored needs to be a string, so we JSON.stringify our data
|
|
|
|
|
|
localStorage.setItem(configKey, JSON.stringify(dataToStore)) |
|
|
|
|
|
|
|
|
|
|
|
// check if the browser supports localStorage
|
|
|
|
|
|
if (typeof(Storage) == "undefined" || !localStorage) { |
|
|
|
|
|
alert("localStorage not supported in this browser") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// this is how we retrieve our data from the browser's localStorage
|
|
|
|
|
|
let storedString = localStorage.getItem( configKey ) |
|
|
|
|
|
let body = document.getElementById('result') |
|
|
|
|
|
if(storedString) { |
|
|
|
|
|
restoreHere = JSON.parse( storedString ) |
|
|
|
|
|
// print results of fetch on webpage
|
|
|
|
|
|
body.innerHTML = `<quote>${restoreHere}</quote>` |
|
|
|
|
|
} else { |
|
|
|
|
|
body.innerHTML = '<em>'+ `couldn't find anything in localStorage with key '${configKey}'` +'</em>' |
|
|
|
|
|
} |