This repository was archived by the owner on Mar 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
51 lines (49 loc) · 1.67 KB
/
index.html
File metadata and controls
51 lines (49 loc) · 1.67 KB
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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<meta charset="UTF-8">
<title>ChoiceScript Player</title>
</head>
<body>
<script>
const fs = require('fs')
function getDirectories(path) {
return fs.readdirSync(path).filter(function (file) {
return fs.statSync(path+'/'+file).isDirectory();
});
}
function getExists(path) {
return fs.existsSync(path);
}
function getName(path) {
return fs.readFileSync(path);
}
</script>
<h1 class="gameTitle">ChoiceScript Player</h1>
<h2 class="gameTitle">By WORD559</h2>
<br>
<input value="Select Games Folder" type="file" id="file_input" webkitdirectory="" directory="" onChange="refresh(event)">
<h3 id="path"></h3>
<h2>Available Games</h2>
<p id="games"></p>
<script>
function refresh(e) {
var path = e.target.files[0].path + "\\";
document.getElementById("path").innerHTML = path;
var games = [];
var dirs = getDirectories(path);
for (var i = 0; i < dirs.length; i++) {
if (fs.existsSync(path+dirs[i]+"/index.html")) {
if (fs.existsSync(path+dirs[i]+"/name.txt")) {
//games.push([dirs[i],getName(dirs[i]+"/name.txt")]);
document.getElementById("games").innerHTML += "<a href='file:///"+path+dirs[i]+"\\index.html'>"+getName(path+dirs[i]+"/name.txt")+"</a><br>";
} else {
document.getElementById("games").innerHTML += "<a href='file:///"+path+dirs[i]+"\\index.html'>"+dirs[i]+"</a><br>";
}
}
}
}
</script>
</body>
</html>