-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-youtube.html
99 lines (86 loc) · 2.86 KB
/
index-youtube.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Educational Video + GenAI Explain Button</title>
<link rel="stylesheet" type="text/css" href="css/huh.css">
<style>
/* Custom styles */
#player {
width: 100%;
max-width: 640px;
aspect-ratio: 16 / 9; /* Maintain a 16:9 aspect ratio */
margin: 0 auto; /* Center the player */
}
#explanation-container {
width: 100%;
max-width: 640px;
margin: 10px auto;
padding: 10px;
}
/* Button container styling */
.button-container {
text-align: center;
}
/* Note styling */
#note {
text-align: center;
font-size: 0.9em;
}
</style>
</head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-LM1KEZKRVQ"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-LM1KEZKRVQ');
</script>
<body>
<div id="player"></div><br/>
<div id="explanation-container">
<button id="info-button">ⓘ</button>
<div id="explanation-content"></div>
<div id="feedback-container">
<button id="helpful-button" title="Helpful explanation"></button>
<button id="unhelpful-button" title="Unhelpful explanation"></button>
</div>
</div>
<div class="button-container"></div>
<p id="note"></p>
<script src="https://www.youtube.com/iframe_api"></script>
<script type="text/javascript">
// YouTube video configuration
const VIDEO_ID = 'kCc8FmEb1nY'; // Replace VIDEO_ID with the actual ID of the YouTube video
// This function creates an <iframe> (and YouTube player) after the API code downloads.
let player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '360',
width: '640',
videoId: VIDEO_ID,
events: {
'onStateChange': onPlayerStateChange
}
});
}
// Huh? button configuration
const SERVER_PATH = `https://borisruf.github.io/the-huh-button/api/${VIDEO_ID}/`
const TIMESTAMP_RESOLUTION = 5;
const BUTTON_ACTIVATION_DELAY = 10
const BUTTON_DEACTIVATION_DELAY = 825;
//const BUTTON1_LABEL = "What??"
//const BUTTON2_LABEL = "Whaaaaaat????"
const ENABLE_USER_FEEDBACK = true;
function toTime(seconds) {
var date = new Date(null);
date.setSeconds(seconds);
return date.toISOString().substr(11, 8);
}
document.getElementById('note').textContent = '(Note: In this demo, explanations are available from timestamp ' + toTime(BUTTON_ACTIVATION_DELAY) + ' to ' + toTime(BUTTON_DEACTIVATION_DELAY) + ')';
</script>
<script src="js/huh-youtube.js"></script>
</body>
</html>