-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
96 lines (88 loc) · 2.99 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
<!DOCTYPE html>
<head>
<script type="text/javascript" src="./CSV_Parser.js"></script>
<style>
body {
margin: 0;
padding: 0;
background-color: #2f3640;
color: #dcdde1;
font-family: "Open Sans", verdana, arial, sans-serif;
}
label {
font-size: 15px;
}
.demo {
height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
#file-button {
background-color: #dcdde1;
color: #000;
border: 2px solid #000;
border-radius: 10px;
padding: 5px;
}
#notice {
position: absolute;
top: 40px;
right: 40px;
font-size: 20px;
}
</style>
</head>
<body>
<div class="demo">
<fieldset>
<legend style="font-size: 17px; color:#f1c40f;">Parser Options:</legend>
<div>
<input type="checkbox" id='rows' name="interest" value="rows">
<label for="rows">Row-wise Array</label>
</div>
<div>
<input type="checkbox" id='columns' name="interest" value="columns">
<label for="columns">Column-wise Array</label>
</div>
<div>
<input type="checkbox" id='json' name="interest" value="json">
<label for="json">JSON</label>
</div>
<div>
<input type="checkbox" id='numeric' name="interest" value="numeric">
<label for="numeric">Parse Numeric Values</label>
</div>
</fieldset>
<input type="file" id="file" accept=".csv" onchange="handlefile()" style="display: none;">
<label id='file-button' for="file">Choose a CSV file</label>
</div>
<div id='notice'>Please check your console for results...</div>
<script>
function handlefile() {
var rows = document.getElementById('rows').checked;
var columns = document.getElementById('columns').checked;
var json = document.getElementById('json').checked;
var numeric = document.getElementById('numeric').checked;
var file = document.getElementById('file').files[0];
var reader = new FileReader();
reader.readAsText(file);
reader.onload = function (e) {
var result = CSV_Parser(reader.result,
{
delimiter: ',',
getRows: rows,
getColumns: columns,
getJSON: json,
dataTyping: numeric
}
);
console.log('%cParsed file: ', "color: green; font-size: 17px;");
console.log(result);
}
document.getElementById('file').value = '';
}
</script>
</body>
</html>