-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
81 lines (59 loc) · 2.39 KB
/
index.html
File metadata and controls
81 lines (59 loc) · 2.39 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
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
<!doctype html>
<html>
<head>
</head>
<body>
<h1>Eas-Dec</h1>
<select name="Messages" id="Messages">
</select>
<p id="message_field"></p>
<audio controls id="audio_player">
<source id="audio_source" src="" type="audio/wav">
Your browser does not support the audio element.
</audio>
</body>
<script>
function ChangeAudio(audioFile) {
const audioplayer = document.getElementById('audio_player');
const audioSource = document.getElementById('audio_source');
audioSource.src = audioFile
audioplayer.load();
}
function ChangeText(filePath) {
fetch(filePath)
.then(response => response.text())
.then(text => {
const messageField = document.getElementById('message_field');
messageField.textContent = text;
});
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
fetch('directories.txt')
.then(response => response.text())
.then(text => {
var dirs = text.split("\n");
const messagesDropdown = document.getElementById('Messages');
dirs.forEach(function(directory) {
if (directory.trim()) {
const option = document.createElement('option');
option.value = directory;
option.textContent = directory;
messagesDropdown.appendChild(option);
}
});
})
.catch(error => console.error('Error fetching the file:', error));
const messagesDropdown = document.getElementById('Messages');
messagesDropdown.addEventListener('change', function() {
const selectedOption = messagesDropdown.options[messagesDropdown.selectedIndex];
const selectedValue = selectedOption.value;
const selectedText = selectedOption.textContent;
console.log('Selected value changed to:', selectedValue);
console.log('Selected text changed to:', selectedText);
ChangeText(`/output/${selectedText}/output.txt`);
ChangeAudio(`/output/${selectedText}/output.wav`);
});
</script>
</html>