-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
135 lines (120 loc) · 3.68 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Audible Annotations</title>
<link rel="manifest" href="manifest.json">
<style>
body {
margin: 0;
overflow: hidden;
}
.audiobutton {
text-align: center;
text-transform: uppercase;
float: left;
cursor: pointer;
font-family: sans-serif;
font-weight: bold;
display: flex;
justify-content: center;
align-items: center;
font-size: xx-large;
}
.quadrant {
width: 50%;
height: 50vh;
}
.undo {
width: 20%;
height: 40vh;
position: absolute;
left: 40%; /* 100 (total) - 20 (width) = 80 / 2 */
top: 30%; /* 100 (total) - 40 (height) = 60 / 2 */
border-radius: 4em;
}
#quadrant1 { background-color: #00FF00; }
#quadrant2 { background-color: #FF0000; }
#quadrant3 { background-color: #0000FF; }
#quadrant4 { background-color: #FFFF00; }
#undo { background-color: #fff; }
a {
color: #000;
text-decoration: unset;
}
.quadrant a:hover {
color: #fff;
text-decoration: underline;
}
.undo a:hover {
color: #c00000;
text-decoration: underline;
}
</style>
</head>
<body>
<div class="audiobutton quadrant" id="quadrant1" onclick="handleInput('q1')"><h1><a href="#">Positive</a></h1></div>
<div class="audiobutton quadrant" id="quadrant2" onclick="handleInput('q2')"><h1><a href="#">Interesting</a></h1></div>
<div class="audiobutton quadrant" id="quadrant3" onclick="handleInput('q3')"><h1><a href="#">Question</a></h1></div>
<div class="audiobutton quadrant" id="quadrant4" onclick="handleInput('q4')"><h1><a href="#">To Do</a></h1></div>
<div class="audiobutton undo" id="undo" onclick="handleInput('undo')"><h2><a href="#">Undo</a></h2></div>
<script>
function handleInput(command) {
let filename = "";
if (command == "q1") {
filename = "audio/annotating_positive.mp3";
} else if (command == "q2") {
filename = "audio/annotating_interesting.mp3";
} else if (command == "q3") {
filename = "audio/annotating_question.mp3";
} else if (command == "q4") {
filename = "audio/annotating_to_do.mp3";
} else if (command == "undo") {
filename = "audio/annotating_undo.mp3";
}
playAudio(filename);
}
function playAudio(filename) {
var audio = new Audio(filename);
audio.play();
}
function handleKeyPress(event) {
switch (event.key) {
case '7':
handleInput("q1");
break;
case '9':
handleInput("q2");
break;
case '1':
handleInput("q3");
break;
case '3':
handleInput("q4");
break;
case '5':
handleInput("undo");
break;
}
}
document.addEventListener('keydown', handleKeyPress);
// Auto-play initial audio when the user visits the webpage
// This is typically blocked, see https://developer.chrome.com/blog/autoplay/
document.addEventListener('DOMContentLoaded', function() {
var initialAudio = new Audio('audio/welcome_and_help.mp3');
initialAudio.play();
});
// Progressive Web App installation handler
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js')
.then((registration) => {
console.log('Service Worker registered with scope:', registration.scope);
})
.catch((error) => {
console.error('Service Worker registration failed:', error);
});
}
</script>
</body>
</html>