forked from warner/jetpack-workshop-slides
-
Notifications
You must be signed in to change notification settings - Fork 0
/
master.html
227 lines (207 loc) · 6.76 KB
/
master.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<meta charset="utf8">
<title>master</title>
<!-- <link href='http://fonts.googleapis.com/css?family=Copse' rel='stylesheet' type='text/css'> -->
<script> var URL = "slides.html"; </script>
<script>
function $(query) { return document.querySelector(query)}
function $$(query) { return document.querySelectorAll(query)}
NodeList.prototype.forEach = function(fun) {
if (typeof fun !== "function") throw new TypeError();
for (var i = 0; i < this.length; i++) {
fun.call(this, this[i]);
}
}
var views = {}, notes, idx = 1;
function onload() {
var iframes = $$("iframe");
var operationsCount = iframes.length;
iframes.forEach(function(f) {
f.onload = function() {
operationsCount--;
if (operationsCount == 0) {
iframesLoaded();
}
}
f.src = URL;
});
function iframesLoaded() {
views.present = document.querySelector("#present > iframe").contentWindow;
views.future = document.querySelector("#future > iframe").contentWindow;
views.present.postMessage("register", document.location);
}
notes = document.querySelector("#notes > #content");
}
function onmessage(e) {
if (e.source === views.present) {
var args = JSON.parse(e.data);
if (args.method === "newslide") {
idx = ~~args.idx;
notes.innerHTML = args.details
$$(".slideidx").forEach(function(p) {p.innerHTML = idx;});
$$(".nextslideidx").forEach(function(p) {p.innerHTML = idx + 1;});
views.future.postMessage("setSlide(" + (idx + 1) + ")", document.location);
if (views.remote) views.remote.postMessage("setSlide(" + idx + ")", document.location);
}
if (args.method === "registered") {
$$(".slidecount").forEach(function(p) {p.innerHTML = args.count;});
}
}
}
function back() { views.present.postMessage("back", document.location); }
function forward() { views.present.postMessage("forward", document.location); }
function toggleContent() {
views.present.postMessage("toggleContent", document.location);
views.remote.postMessage("toggleContent", document.location);
}
function onkeydown(e) {
// Don't intercept keyboard shortcuts
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
return;
}
if ( e.keyCode == 37 // left arrow
|| e.keyCode == 33 // page up
) {
e.preventDefault();
back();
}
if ( e.keyCode == 39 // right arrow
|| e.keyCode == 34 // page down
) {
e.preventDefault();
forward();
}
if ( e.keyCode == 32) {
e.preventDefault();
toggleContent();
}
}
var start;
function startTimer() {
if (!start) {
start = new Date();
var minutesElt = $("#minutes");
var secondsElt = $("#seconds");
minutesElt.innerHTML = "00";
secondsElt.innerHTML = "00";
setInterval(function() {
var now = new Date();
var delta = now - start;
delta = ~~(delta / 1000)
seconds = delta % 60;
minutes = ~~(delta / 60);
if (seconds < 10) seconds = "0" + seconds;
if (minutes < 10) minutes = "0" + minutes;
secondsElt.innerHTML = seconds;
minutesElt.innerHTML = minutes;
}, 2000);
}
}
function openSlides() {
var windowObjectReference;
document.body.classList.add("slidesopen");
var strWindowFeatures = "resizable=yes";
views.remote = window.open(URL, "slides", strWindowFeatures);
setTimeout(function() {
views.remote.postMessage("setSlide(" + idx + ")", document.location);
}, 1000);
}
</script>
<style>
iframe {
pointer-events: none;
border: none;
width: 100%;
height: 80%;
outline: 4px solid black;
}
#present > h1, #future > h1, #notes h1 {
font-size: 20px;
}
#present {
width: 600px;
height: 600px;
position: absolute;
top: 0;
left: 50%;
margin-left: -300px;
}
.slidesopen #present button {
display: none;
}
#future {
width: 250px;
height: 250px;
position: absolute;
top: 280px;
right: 40px;
}
body {
text-align: center;
background-image: -moz-linear-gradient(top, #253D61, #3A2137);
background-image: -webkit-linear-gradient(top, #253D61, #3A2137);
font-family: 'Copse', arial, serif;
overflow: hidden;
}
html, body {
height: 100%;
color: white;
}
button.forward {
-moz-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
}
#controls {
width: 100%;
position: absolute;
bottom: 20px;
left: 0;
text-align: center;
}
#controls button {
background-color: transparent;
border: none;
}
#time {
position: absolute;
bottom: 0; right: 30px;
cursor: pointer;
}
#minutes { font-size: 30px; }
#seconds { opacity: 0.5; }
#notes {
position: absolute;
top: 40px; left: 20px;
width: 300px;
text-align: left;
background-color: rgba(50%, 50%, 50%, 0.7);
font-size: 20px;
}
#notes li {
margin-top: 20px;
font-size: 16px;
}
</style>
<div id="future">
<h1>Next slide: <span class="nextslideidx">n/a</span> of <span class="slidecount">n/a</span></h1>
<iframe></iframe>
</div>
<div id="controls">
<button class="back" onclick="back()">
<svg width="50px" height="50px" viewBox="0 0 50 50"><path fill="#fff" d="M46.686,2.632L23.694,25.624l22.992,22.993H27.183L4.189,25.624 L27.183,2.632H46.686z"/></svg>
</button>
<button class="forward" onclick="forward()">
<svg width="50px" height="50px" viewBox="0 0 50 50"><path fill="#fff" d="M46.686,2.632L23.694,25.624l22.992,22.993H27.183L4.189,25.624 L27.183,2.632H46.686z"/></svg>
</button>
</div>
<div id="time">
<p onclick="startTimer()"><span id="minutes">00</span>:<span id="seconds">00<br>Click to start the timer</span></p>
</div>
<div id="present">
<h1>Current slide: <span class="slideidx">n/a</span> of <span class="slidecount">n/a</span></h1>
<iframe></iframe>
<button onclick="openSlides()">Click to open the presentation</button>
</div>
<div id="notes">
<p id="content"></p>
</div>