-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
203 lines (188 loc) · 6.58 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Medooze media server BWE stats viewer</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="css/main.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,400" />
<style>
html
{
}
body
{
font-family: Roboto, sans-serif;
color: #0f3c4b;
background-color: #e5edf1;
padding: 1.25rem; /* 80 20 */
}
.chartdiv
{
width: 100%;
height: 100%;
min-height: 800px;
margin: 10px;
}
.chunk {
border: 1px solid #ff8e6a;
margin: 2px;
padding: 2px;
background-color: #ffc35e;
cursor: pointer;
cursor: pointer;
line-height: 20px;
display: inline-block;
}
.loadingdiv {
display: flex;
position: relative;
align-content: space-around;
justify-content: center;
top: 100px;
}
.loader-svg {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
fill: none;
stroke-width: 5px;
stroke-linecap: round;
stroke: rgb(64, 0, 148);
}
.loader-svg.bg {
stroke-width: 8px;
stroke: rgb(207, 205, 245);
}
.animate {
stroke-dasharray: 242.6;
animation: fill-animation 1s cubic-bezier(1,1,1,1) 0s infinite;
}
@keyframes fill-animation {
0% {
stroke-dasharray: 40 242.6;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 141.3;
stroke-dashoffset: 141.3;
}
100% {
stroke-dasharray: 40 242.6;
stroke-dashoffset: 282.6;
}
}
</style>
</head>
<body>
<div class="uploader" role="main">
<h1><a href="/article-url"></a></h1>
<form method="post" enctype="multipart/form-data" novalidate class="box has-advanced-upload">
<div class="box__input">
<svg class="box__icon" xmlns="http://www.w3.org/2000/svg" width="50" height="43" viewBox="0 0 50 43"><path d="M48.4 26.5c-.9 0-1.7.7-1.7 1.7v11.6h-43.3v-11.6c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v13.2c0 .9.7 1.7 1.7 1.7h46.7c.9 0 1.7-.7 1.7-1.7v-13.2c0-1-.7-1.7-1.7-1.7zm-24.5 6.1c.3.3.8.5 1.2.5.4 0 .9-.2 1.2-.5l10-11.6c.7-.7.7-1.7 0-2.4s-1.7-.7-2.4 0l-7.1 8.3v-25.3c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v25.3l-7.1-8.3c-.7-.7-1.7-.7-2.4 0s-.7 1.7 0 2.4l10 11.6z" /></svg>
<input type="file" name="files[]" id="file" class="box__file" data-multiple-caption="{count} files selected" multiple />
<label for="file"><strong>Choose a file</strong><span class="box__dragndrop"> or drag it here</span>.</label>
<button type="submit" class="box__button">Upload</button>
</div>
</form>
</div>
<div class="loadingdiv" style="display:none">
<svg class="svg-container" height="100" width="100" viewBox="0 0 100 100">
<circle class="loader-svg bg" cx="50" cy="50" r="45"></circle>
<circle class="loader-svg animate" cx="50" cy="50" r="45"></circle>
</svg>
</div>
<div class="chartdiv" style="display:none"></div>
</body>
</html>
<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/material.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/dataviz.js"></script>
<script src="js/color-hash.js"></script>
<script src="js/uploader.js"></script>
<script src="js/displayer.js"></script>
<script>
const csv = "1|0|1202|00000000|00000000|000000|000000|000000|0|0\r\n" +
"2|0|1202|00005237|00005000|005237|005000|-000237|0|0\r\n" +
"3|0|1202|00011614|00012000|006377|007000|000623|0|0\r\n" +
"4|0|1202|00017037|00017000|005423|005000|-000423|0|0\r\n" +
"5|1|1202|00029768|00030000|012731|013000|000269|0|0\r\n" +
"6|1|1202|00035956|00036000|006188|006000|-000188|0|0\r\n" +
"7|1|1202|00041604|00042000|005648|006000|000352|0|0\r\n" +
"8|1|1202|00047394|00047000|005790|005000|-000790|0|0\r\n" +
"9|1|1202|00053289|00053000|005895|006000|000105|0|0\r\n" +
"10|1|1202|00065050|00065000|011761|012000|000239|0|0\r\n" +
"11|1|1202|00071024|00071000|005974|006000|000026|0|0\r\n" +
"12|2|1202|00076515|00076000|005491|005000|-000491|0|0\r\n" +
"13|2|1202|00086938|00087000|010423|011000|000577|0|0\r\n" +
"14|2|1202|00092829|00093000|005891|006000|000109|0|0\r\n" +
"15|2|1202|00098565|00099000|005736|006000|000264|0|0\r\n" +
"16|2|1202|00108828|00109000|010263|010000|-000263|0|0\r\n" +
"17|2|1202|00114822|00115000|005994|006000|000006|0|0\r\n" +
"18|2|1202|00119909|00120000|005087|005000|-000087|0|0\r\n" +
"19|3|1202|00130393|00130000|010484|010000|-000484|0|0\r\n" +
"20|3|1202|00135950|00136000|005557|006000|000443|0|0\r\n" +
"21|3|1202|00141986|00142000|006036|006000|-000036|0|0\r\n" +
"22|3|1202|00153072|00153000|011086|011000|-000086|0|0\r\n";
function createTable(data)
{
var table = document.createElement('table');
var row = {};
var cell = {};
data.forEach(function (rowData)
{
row = table.insertRow(-1); // [-1] for last position in Safari
rowData.forEach(function (cellData)
{
cell = row.insertCell();
cell.textContent = cellData;
});
});
document.body.appendChild(table);
}
//Get our url
const href = new URL(window.location.href);
//Get url of csv
const url = href.searchParams.has("url") ? new URL(href.searchParams.get("url")) : 0;
am4core.ready(async function ()
{
// Themes begin
am4core.useTheme(am4themes_dataviz);
// applying the effect for every form
var uploader = document.querySelector('.uploader');
var chartdiv = document.querySelector('.chartdiv');
var loadingdiv = document.querySelector('.loadingdiv');
var form = document.querySelector('.uploader .box');
if (!url)
{
//Listen for uploads
OnFileUpload(form, (name, csv) =>
{
//Hide uploaded
uploader.style.display = "none";
//Show graph
chartdiv.style.display = "inherit";
//Show data
DisplayData(name, csv);
});
} else {
//Hide uploaded
uploader.style.display = "none";
//Show loading
loadingdiv.style.display = "flex";
//Fectch file
const response = await fetch(url);
//get as text
const csv = await response.text()
//Hide loading
loadingdiv.style.display = "none";
//Show graph
chartdiv.style.display = "inherit";
//Show data
DisplayData(url.pathname.split("/").pop(), csv);
}
});
</script>