forked from thebrentc/wsg-assess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
48 lines (42 loc) · 996 Bytes
/
script.js
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
(function () {
const wsgParser = new WSGParser(
function() {
showJSON()
}
)
function copyToClipboard(e) {
// Select the text field
e.select();
e.setSelectionRange(0, 99999); // For mobile devices
// Copy the text inside the text field
navigator.clipboard.writeText(e.value);
}
function showJSON() {
let json = wsgParser.getJSON()
document.getElementById('output').value = json
}
function showCSV() {
let csv = wsgParser.getCSV()
document.getElementById('output').value = csv
}
document.getElementById('json-button').addEventListener(
"click",
function () {
showJSON()
}.bind(wsgParser)
);
document.getElementById('csv-button').addEventListener(
"click",
function () {
showCSV()
}.bind(wsgParser)
);
document.getElementById('copy-button').addEventListener(
"click",
function () {
let e = document.getElementById("output")
copyToClipboard(e)
document.getElementById("copy-button").classList.add('visited')
}
);
})();