-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadJSON.js
44 lines (29 loc) · 1.09 KB
/
loadJSON.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// begin throwing away google's secrets if that hasn't been done already
window.onload = function() {
// i'm definitely going to forget to toggle this
debug = false;
// hide the guide link for visual effect
document.getElementById("guide").style.visibility = "hidden";
var fileForm = document.getElementById("file");
fileForm.onchange = function() {
var file = fileForm.files[0];
var reader = new FileReader();
reader.onloadend = loadJavascript;
reader.readAsText(file);
};
// for when you get here with the back button and your file's still selected
if (fileForm.value !== "") {fileForm.onchange();}
};
function createScriptElement(name) {
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', name);
return script;
}
function loadJavascript(e) {
DATA = JSON.parse(e.target.result);
document.head.appendChild(createScriptElement("readJSON.js")).onload =
function() {document.head.appendChild(createScriptElement("fastQueries.js"));
};
document.getElementById("guide").style.visibility = "visible"; // ta da!
}