-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnoter.html
More file actions
234 lines (196 loc) · 7.53 KB
/
noter.html
File metadata and controls
234 lines (196 loc) · 7.53 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
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
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PRESENTA Lib Notes</title>
<script src="libs/presenta.min.js"></script>
<script src="libs/presenta-module-highlightjs.min.js"></script>
<script src="libs/presenta-block-youtube.min.js"></script>
<script src="libs/presenta-block-chartjs.min.js"></script>
<script src="libs/presenta-block-flowchartjs.min.js"></script>
<script src="libs/presenta-block-fitty.min.js"></script>
<script src="libs/presenta-block-vegalite.min.js"></script>
<script src="libs/presenta-block-modelviewer.min.js"></script>
<script src="libs/presenta-controller-styles.min.js"></script>
<script src="libs/presenta-controller-markdown.min.js"></script>
<script src="libs/presenta-controller-console-notes.min.js"></script>
<script src="libs/presenta-controller-swiper.min.js"></script>
<script src="libs/md2pjson.min.js"></script>
<style>
*{
box-sizing: border-box;
}
html, body{
width: 100%;
height: 100%;
overflow: hidden;
padding: 0;
margin: 0;
}
body{
display: flex;
flex-direction: column;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
background-color: black;
}
.header{
padding: .5rem;
display: flex;
justify-content: space-between;
color: white;
font-size:2rem;
}
.header a{
color: white;
}
.columns{
display: flex;
height: 100%;
overflow: hidden;
padding-top:10px;
}
.columns > div{
width: 50%;
padding-top: 5px;
}
.columns .left{
flex:2;
padding: 0 .25rem;
}
.columns .right{
padding: 0 .25rem;
flex:1;
height: 100%;
overflow-y: auto;
scroll-behavior:smooth;
}
.wrapper{
width: 100%;
margin-bottom:10px;
outline: 2px solid white;
display: block;
}
#notes{
font-size:2rem;
padding: .5rem;
color:white;
}
.preview{
height: 400%;
}
#app{
outline: 2px solid white;
}
</style>
</head>
<body>
<div class="header">
<div class="left">
<a id="prev" href="">«</a>
<span id="pagenum"></span>
<a id="next" href="">»</a>
</div>
<div class="right">
<span id="timer">00:00:00</span>
</div>
</div>
<div class="columns">
<div class="left">
<div id="app"></div>
<div id="notes"></div>
</div>
<div class="right">
<div class="preview"></div>
</div>
</div>
<script>
const path = location.href.split('?name=')
const doc = path[1]
const pathParts = doc.split('/')
pathParts.splice(pathParts.length-1, 1)
let base = pathParts.join(',').replace(/\,/mig, '/')
base = base.length > 0 ? base + '/' : ''
fetch(doc + '?t=' + Math.random())
.then(res => res.text())
.then(raw => {
const config = md2pjson.parse(raw)
const pagenum = document.querySelector('#pagenum')
const noteCont = document.querySelector('#notes')
const container = document.querySelector('.preview')
config.transition = null
// first, let's disable some controllers that don't make sense in this context
if (!config.controllers) config.controllers = {}
config.controllers.progressbar = false
config.controllers.arrows = false
config.controllers.keyboard = false
config.controllers.pagenum = false
config.controllers.limitswitch = false
config.controllers.fullscreen = false
config.controllers.focus = false
config.controllers.rsync = true
config.controllers.baseurl = base
let router = null
// this is the main preview of the presentation
new Presenta('#app', config).then(p => {
// let's exploit the internal router for the sync feature
router = p.router
const prev = () => {
router.prev()
}
const next = () => {
router.next()
}
document.querySelector('#prev').addEventListener('click', e => {
prev()
e.preventDefault()
})
document.querySelector('#next').addEventListener('click', e => {
next()
e.preventDefault()
})
window.addEventListener('keyup', e => {
if (e.key === 'ArrowLeft') prev()
if (e.key === 'ArrowRight') next()
})
router.on('indexChanged', e => {
const scene = config.scenes[e.currentIndex]
// speaker notes
const notes = scene.notes || ''
noteCont.innerHTML = notes
// pagenum
pagenum.innerHTML = `${e.currentIndex + 1} / ${e.totalScenes}`
// sidebar scroll sync
const href = location.href
const parts = href.split('#')
location.href = parts[0] + '#s' + (e.currentIndex + 1)
// const all = [].slice.call(document.querySelectorAll('.wrapper'))
// all.forEach(e => e.classList.remove('selected'))
// const s = document.querySelector(`.wrapper:nth-child(${e.currentIndex + 1})`)
// s.classList.add('selected')
})
})
config.scenes.forEach((s, i) => {
const wrapper = document.createElement('a')
wrapper.setAttribute('id', 's' + i)
wrapper.setAttribute('href', '#s' + (i + 1))
wrapper.classList.add('wrapper')
container.appendChild(wrapper)
wrapper.addEventListener('click', () => {
router.goto(i)
})
// here the trick, clone the main config in order to use it for each scene
const configCloned = JSON.parse(JSON.stringify(config))
configCloned.mode = 'preview'
configCloned.scenes = [s]
configCloned.controllers.rsync = false
configCloned.controllers.baseurl = ''
new Presenta(wrapper, configCloned)
})
})
.catch(err => {
document.body.innerHTML = 'There is an error. Maybe you are not running a local webserver. In this case, open the README.md to learn more.'
})
</script>
</body>
</html>