-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.js
More file actions
90 lines (83 loc) · 2.45 KB
/
Copy pathfunction.js
File metadata and controls
90 lines (83 loc) · 2.45 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
function downloadInput() {
let link = document.createElement('a');
link.download = 'geometry_input.txt';
let blob = new Blob([document.getElementById("inputData").value], {type: 'text/plain'});
link.href = URL.createObjectURL(blob);
console.log(link.href);
link.click();
URL.revokeObjectURL(link.href);
}
function uploadInput() {
var up = document.createElement("input");
up.type = "file";
up.addEventListener("change", function() {
let f = new FileReader();
f.onload = function() {
document.getElementById("inputData").value = f.result;
}
f.readAsText(this.files[0]);
})
up.click();
}
function downloadSVG() {
let link = document.createElement('a');
link.download = 'geometry.svg';
let blob = new Blob([document.getElementById("displayArea").outerHTML], {type: 'text/plain'});
link.href = URL.createObjectURL(blob);
console.log(link.href);
link.click();
URL.revokeObjectURL(link.href);
}
var toggleButtonValue = 0;
var toggleButtonSelect = d3.select("#toggleButton").select("ion-icon");
var inputColumnSelect = d3.select("#inputColumn");
var displayColumnSelect = d3.select("#displayColumn");
function toggleInputArea() {
toggleButtonValue ^= 1;
if (toggleButtonValue) {
toggleButtonSelect
.attr("src", "icons/caret-forward-outline.svg");
}
else {
toggleButtonSelect
.attr("src", "icons/caret-back-outline.svg");
}
if (toggleButtonValue) {
inputColumnSelect
.style("display", "none");
displayColumnSelect
.style("left", "0%");
}
else {
inputColumnSelect
.style("display", "unset");
displayColumnSelect
.style("left", "15%");
}
}
var toggleExampleBarMode = 0;
function toggleExampleBar() {
toggleExampleBarMode ^= 1;
if (toggleExampleBarMode == 0)
d3.select(".sideBar")
.style("display", "none");
else
d3.select(".sideBar")
.style("display", "unset");
}
function closeExampleBar() {
toggleExampleBarMode = 0;
d3.select(".sideBar")
.style("display", "none");
}
function runExample(filePath) {
$.ajax({
url: filePath,
success: function (inputText){
document.getElementById("inputData").value = inputText;
display(getInput());
}
});
}
// Shortcut keys
Mousetrap.bind('f9', function() {display(getInput());});