MCPcopy Create free account
hub / github.com/aosabook/500lines / saveFile

Function saveFile

blockcode/code/file.js:38–49  ·  view source on GitHub ↗
(evt)

Source from the content-addressed store, hash-verified

36 }
37
38 function saveFile(evt){
39 var title = prompt("Save file as: ");
40 if (!title){ return; }
41 var file = new Blob([scriptToJson()], {type: 'application/json'});
42 var reader = new FileReader();
43 var a = document.createElement('a');
44 reader.onloadend = function(){
45 var a = elem('a', {'href': reader.result, 'download': title + '.json'});
46 a.click();
47 };
48 reader.readAsDataURL(file);
49 }
50
51 function readFile(file){
52 var fileName = file.name;

Callers

nothing calls this directly

Calls 1

scriptToJsonFunction · 0.85

Tested by

no test coverage detected