Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
inventionpro authored May 1, 2024
1 parent 038a26b commit c75bfb5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ function file_i() {
document.getElementById('upload').addEventListener("change", function(){
const reader = new FileReader();
reader.onload = (evt) => {
console.log('File load: '+evt.target.result);
let con = evt.target.result;
try {
let json = JSON.parse(con);
if (!Array.isArray(json)) throw new Error('Not a array');
localStorage.setItem('todo', con);
} catch(err) {
alert('Not a valid file')
}
};
reader.readAsText(this.files[0]);
});
Expand Down

0 comments on commit c75bfb5

Please sign in to comment.