-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
88 lines (74 loc) · 2.61 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Results Tidyup</title>
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="results-tidyup-container" class="main-content container-fluid">
<div id="results-tidyup"></div>
</div>
<noscript>
<div class="container-fluid">
<h1>Results Tidyup</h1>
<h3>JavaScript is disabled</h3>
<p>You appear to have JavaScript disabled in your browser. To use Results Tidyup please enable JavaScript.</p>
</div>
</noscript>
<script src="results-tidyup.js"></script>
<script src="jquery-3.6.0.min.js"></script>
<script>
var app = Elm.ResultsTidyup.init({
node: document.getElementById("results-tidyup"),
flags: { isBeta: true }
});
var allFilesDropped = [];
function handleNextFileLoad(files, index) {
var reader = new FileReader();
reader.onload = function (e) {
allFilesDropped.push({
fileName: files[index].name,
// Replace UTF-8 byte-order marks for the benefit of IE.
fileText: e.target.result.replace(/\ufeff/, "")
});
if (allFilesDropped.length < files.length) {
handleNextFileLoad(files, index + 1);
}
else {
app.ports.filesDropped.send(allFilesDropped);
allFilesDropped = [];
}
};
if (index < files.length) {
reader.readAsText(files[index], "UTF-8");
}
}
function handleLoad(files) {
if (typeof files === "undefined") {
// Sorry, IE9 users, can't help you here.
alert("Sorry, this feature doesn't work in your browser. Please try another browser.");
return;
}
allFilesDropped = [];
handleNextFileLoad(files, 0);
}
// The following functions have been adapted from
// https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications#Selecting_files_using_drag_and_drop
function stopDefaultBehaviour(e) {
e.stopPropagation();
e.preventDefault();
}
function drop(e) {
stopDefaultBehaviour(e);
handleLoad(e.dataTransfer.files);
}
document.body.addEventListener("dragenter", stopDefaultBehaviour, false);
document.body.addEventListener("dragover", stopDefaultBehaviour, false);
document.body.addEventListener("drop", drop, false);
</script>
</body>
</html>