PageSourceSearch

https://coolstuffgoeshere.github.io/src/saveloadjson.js

js coolstuffgoeshere.github.io collected 2026-10-03 08:49:49 UTC 1,028 bytes, 42 lines download raw bytes

1function loadPinsFromFile (event) {
2  var file = event.target.files[0];
3  var reader = new FileReader();
4
5  console.log(`Loading pins from ${file.name}!`);
6
7  reader.onload = function (event) {
8    var contents = event.target.result;
9    try {
10      data = JSON.parse(contents);
11
12      setMapData(data);
13
14	  console.log(`Finished loading pins from ${file.name}!`);
15
16    } catch (error) {
17      console.error("Error parsing JSON:", error);
18      alert("Error parsing JSON file.");
19    }
20  };
21
22  reader.readAsText(file);
23
24}
25
26function savePinsToFile () {
27  console.log("Saving pins to JSON file!");
28  console.log(state.userMapData);
29
30  var currentFile = state.currentMap.urlName;
31  var json = JSON.stringify(state.userMapData, null, 2);
32  var blob = new Blob([json], { type: "application/json" });
33  var url = URL.createObjectURL(blob);
34
35  var a = document.createElement("a");
36  a.style.display = 'none';
37  document.body.appendChild(a);
38  a.href = url;
39  a.download = currentFile;
40  a.click();
41  window.URL.revokeObjectURL(url);
42}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.