Repository navigation
Expand file tree
/
Copy pathexplain.html
More file actions
97 lines (91 loc) · 3.08 KB
/
Copy pathexplain.html
File metadata and controls
97 lines (91 loc) · 3.08 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
<html>
<head>
<style>
body {
margin: 0;
}
.box {
display:inline-block;
padding: 0;
}
.deck {
width: 60%;
}
.source {
width: 38%;
border-left: 4px dashed #ccc;
}
</style>
</head>
<body>
<div class="box deck">
<iframe
id="deck"
src="index.html?in_explain"
style="border: 0;"
frameborder="0"
scrolling="no" height="100%" width="100%" align="left" ></iframe>
</div>
<div class="box source">
<iframe
id="source"
src="slides.combined.md.txt"
frameborder="0"
height="100%" width="100%" align="left" ></iframe>
</div>
<script>
var deck = document.getElementById('deck');
var source = document.getElementById('source');
var split_source = function(doc) {
// console.log(doc);
var myText = doc.getElementsByTagName("pre")[0];
// console.log(myText);
var lines = myText.innerHTML.split("\n");
var numLines = lines.length;
var i;
var currentSection = undefined;
var header = false;
window.sections = Array();
for (i = 0; i < numLines; i++) {
var line = lines[i];
// console.log("line: " + line);
if (line.indexOf('---') == 0) {
header = !header;
continue;
}
if (header) {
continue;
}
if (line.indexOf('# ') == 0) {
if (currentSection) {
window.sections.push(currentSection.join("\n"));
}
// console.log("slide header found: " + line);
currentSection = Array();
currentSection.push('<pre>');
currentSection.push(line);
} else {
if (currentSection) {
currentSection.push(line);
}
}
}
window.sections.push(currentSection.join("\n"));
console.log(window.sections);
}
document.getElementById('deck').onload = function(event) {
var sourceDoc = source.contentDocument;
split_source(sourceDoc.documentElement);
var deckWindow = deck.contentWindow;
var update_source = function() {
// console.log("updating source view");
var slideNr = deckWindow.Reveal.getIndices().h;
source.contentDocument.documentElement.innerHTML = '<div style="padding-left: 1em; position: relative; top: 50%; transform: translateY(-50%);"><em>slide source</em></br></br>' + window.sections[slideNr] + "</div>";
};
update_source();
deckWindow.Reveal.addEventListener('slidechanged', update_source);
deckWindow.focus();
};
</script>
</body>
</html>