-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformat.html
280 lines (231 loc) · 5.48 KB
/
format.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<!DOCTYPE html>
<html>
<head>
<style>
body
{
font-family: Helvetica;
font-size: 100%;
height: 100vh
}
.banner {
position:absolute;
background-color: white;
text-align: center;
}
h1, h2
{
font-size: 3vw;
font-weight: normal;
animation: clicking 2s ;
animation-iteration-count: 3;
}
h2
{
font-size: 1.3em;
}
#filedrag
{
display: none;
font-weight: bold;
text-align: center;
#padding: 1em 0;
margin: 1em 0;
color: #333;
border: 2px dashed #333;
#border-radius: 0px;
cursor: default;
#height: 15vh;
}
#filedrag.hover
{
color: #f00;
border-color: #f00;
border-style: solid;
box-shadow: inset 0 10px 20px #888;
}
img
{
max-width: 100%;
}
fileselect {
align: center;
}
#progress p
{
display: block;
width: 240px;
padding: 2px 5px;
margin: 2px 0;
border: 1px inset #446;
border-radius: 5px;
background: #eee url("progress.png") 100% 0 repeat-y;
}
#progress p.success
{
background: #0c0 none 0 0 no-repeat;
}
#progress p.failed
{
background: #c00 none 0 0 no-repeat;
}
table {
/* Not required only for visualizing */
border-collapse: collapse;
width: 100%;
}
form {
background-color: white;
position: sticky;
z-index: 100;
top: 0;
#height: 20vh;
}
table thead tr th {
/* you could also change td instead th depending your html code */
background-color: lightgreen;
position: sticky;
z-index: 100;
#top: 20vh;
}
td {
/* Not required only for visualizing */
padding: 1em;
}
click{
position:absolute;
font-size:30vw;
top: 1px;
}
@keyframes clicking {
0% {
font-size: 3vw;
}
40% {
font-size: 4vw;
}
80% {
font-size: 2vw;
}
100% {
font-size: 3vw;
}
}
</style>
<meta charset="UTF-8">
<title>omics raw data format identifier</title>
</head>
<body>
<div class="banner" id="banner">
</div>
<form id="choose file" action="index.html" method="POST" enctype="multipart/form-data">
<div>
<label for="fileselect"/>
<div id="filedrag">drop files here or click inside the dashed area:
<div id="button">
<input type="file" id="fileselect" name="fileselect[]" multiple="multiple"/>
<h1 id="click">☝</h1>
</div>
</div>
</div>
<div id="submitbutton">
<button type="submit">Upload Files</button>
</div>
</form>
<div>
<table id="file-table" style="width:100%">
<thead>
<tr>
<th>file name</th>
<th>size</th>
<th>extension</th>
<th>omics</th>
<th>endpoint repositories</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div>
<script type="module">
import name_list from "./js/name_list.json" assert { type: "json" };
function addRow(omics, cells) {
var table = document.getElementById("file-table");
var row = table.insertRow(-1);
for (const cell of cells ) {
var cellx = row.insertCell(-1);
console.log(cell)
cellx.innerHTML = cell;
}
}
function FileDragHover(e) {
e.stopPropagation();
e.preventDefault();
e.target.className = (e.type == "dragover" ? "hover" : "");
}
function FileSelectHandler(e) {
var fileList = [];
FileDragHover(e);
var files = e.target.files || e.dataTransfer.files;
for (const file of files) {
ParseFile(file);
}
}
function formatSize(x){
const units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
let l = 0, n = parseInt(x, 10) || 0;
while(n >= 1024 && ++l){
n = n/1024;
}
return (n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]);
}
function ParseFile(file) {
let extension = file.name.split('.').pop();
var omics = listCompare(extension, name_list);
addRow(omics, [file.name, formatSize(file.size), extension, omics[0] , omics[1]] );
}
function Init() {
var fileSelect = document.getElementById("fileselect"),
fileDrag = document.getElementById("filedrag"),
submitButton = document.getElementById("submitbutton");
fileSelect.addEventListener("change", FileSelectHandler, false);
var xhr = new XMLHttpRequest();
if (xhr.upload) {
fileDrag.addEventListener("dragover", FileDragHover, false);
fileDrag.addEventListener("dragleave", FileDragHover, false);
fileDrag.addEventListener("drop", FileSelectHandler, false);
fileDrag.style.display = "block";
submitbutton.style.display = "none";
}
}
if (window.File && window.FileList && window.FileReader) {
Init();
}
function listCompare(extension, name_list) {
const omics2ep = {
"genomics": "ENA",
"transcriptomics": "GEO",
"proteomics": "PRIDE",
"metabolomics": "Metabolights"
};
var omics1 = [];
var epYes = [];
for (var prop in name_list.extension_ident) {
let listExtension = name_list.extension_ident[prop].split('.').pop();
if (listExtension == extension) {
console.log(name_list.omics[prop]);
omics1.push(name_list.omics[prop]);
let epName = omics2ep[name_list.omics[prop]];
epYes.push(epName + ":" + name_list.EP1[prop]);
} else {}
}
return [omics1, epYes];
}
</script>
</body>
<!
author: xiaoranzhou
modified from SitePoint.com
adapted scripts from Craig Buckler (@craigbuckler) of OptimalWorks.net
>
</html>