-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
189 lines (151 loc) · 4.84 KB
/
index.html
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html lang="en">
<head>
<meta name=viewport content="width=device-width, initial-scale=1">
<script async src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script async src="https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.0.0/dygraph.min.js"></script>
<script async src="logviewer.data.js"></script>
<script async src="logviewer.data.torque.js"></script>
<script async src="logviewer.data.msdroid.js"></script>
<script async src="logviewer.data.wipy.js"></script>
<script async src="logviewer.data.realdash.js"></script>
<script async src="logviewer.chart.js"></script>
<script async src="logviewer.map.js"></script>
<style>
</style>
<title>Speeduino Log Viewer</title>
</head>
<body>
<section id="dropTarget" ondrop="drop(event)" ondragover="allowDrop(event)">
<div id='headings'>
<div >
Select a text file or just drop one here:
<input type="file" id="fileInput">
</div>
<h2 id='CaptureDate'></h2>
</div>
<div id='controls'>
</div>
<div id='controlscontrol'>
<button id="addSeriesBtn" onclick="addSeries()">Add Data Line</button>
<br />
<button id="removeSeriesBtn" onclick="removeSeries()">Remove Data Line</button>
</div>
</section>
<div id='wrapper'>
<div id ='chart'></div>
<div id="map"></div>
</div>
</body>
<script type="text/javascript">
function loadFile(file){
var reader = new FileReader();
reader.onload = function(e) {
processData(reader.result);
setupSelectors()
resetChart()
constructMap()
}
reader.readAsText(file);
}
window.onload = function() {
var fileInput = document.getElementById('fileInput');
var fileDisplayArea = document.getElementById('fileDisplayArea');
fileInput.addEventListener('change', function(e) {
var file = fileInput.files[0];
loadFile(file);
});
}
function createNewSelector(defaultValue) {
var controls=document.getElementById('controls')
var select=document.createElement('select')
select.className='seriesSelect';
setOptions(select,dataStore.dataSeries.headers)
if(!(defaultValue == undefined)) {
select.value=defaultValue;
}
select.addEventListener('change',resetChart)
controls.appendChild(select)
}
function setupSelectors() {
var selectors=document.querySelectorAll('.seriesSelect');
for (var i=0;i<selectors.length;i++) {
var toDie=selectors[i]
toDie.parentNode.removeChild(toDie)
}
var defaults=dataStore.dataSeries.defaultSelections;
for (var i=0;i<defaults.length;i++) {
createNewSelector(defaults[i]);
}
}
function setCaptureDate(dte) {
document.getElementById('CaptureDate').innerText=dte;
}
function setOptions(select,list) {
while (select.options.length > 0) {
select.remove(select.options.length - 1);
}
for(var i=0;i<list.length;i++) {
var opt = document.createElement('option');
opt.text = list[i];
opt.value = list[i];
select.add(opt, null);
}
}
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var dt = ev.dataTransfer;
var files = dt.files;
loadFile(files[0])
}
function numSeries() {
return document.querySelectorAll('.seriesSelect').length
}
function addSeries() {
if(numSeries() < 5) {
createNewSelector(dataStore.dataSeries.defaultSelections[0])
resetChart()
}
}
function removeSeries() {
if(numSeries() > 1) {
var selectors=document.querySelectorAll('.seriesSelect');
var toDie=selectors[selectors.length-1]
toDie.parentNode.removeChild(toDie)
resetChart()
}
}
</script>
<noscript id="deferred-styles">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.0.0/dygraph.min.css" integrity="sha256-y5AaP/PGcK5D8H3WAWp4LTOE7qCYyphket0A3dCOwmk=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<link rel="stylesheet" href="logviewer.css" />
</noscript>
<script>
var loadDeferredStyles = function() {
var addStylesNode = document.getElementById("deferred-styles");
var replacement = document.createElement("div");
replacement.innerHTML = addStylesNode.textContent;
document.body.appendChild(replacement)
addStylesNode.parentElement.removeChild(addStylesNode);
};
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf) raf(function() { window.setTimeout(loadDeferredStyles, 0); });
else window.addEventListener('load', loadDeferredStyles);
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-96223831-1', 'auto');
ga('send', 'pageview');
</script>
</html>