I want to export several items from my local storage in order to save it from the outside, but in a format so that I can import it later.
My attempt was to write executable code that can be inserted later in a text box. Then the value of this textare will be just eval () ed.
Problem: Data stored in localStorage was saved as
var data = []; data.push('sampledata'); data.push({sample: 'object'}); localStorage.setItem('varname',data);
Thus, it contains various characters that I do not like, for example, "," etc.
My (not working) solution so far:
var container = $('#localDataContainer'); container.append('localStorage.setItem("cockpitLastVisited","' + localStorage.getItem("cockpitLastVisited") + '");<br/>'); container.append('localStorage.setItem("cockpit_services","' + localStorage.getItem("cockpit_services") + '");<br/>'); container.append('localStorage.setItem("cockpit_users","' + localStorage.getItem("cockpit_users") + '");');
If my attempt seems to be in order, what is the best way to create the code, which can then be executed as it is?
Zim84 source share