4
0
Fork 0

Update templates

This commit is contained in:
Alex Myasoedov 2017-03-02 22:16:49 -05:00
parent 2b5394336a
commit 7de98eeea6
No known key found for this signature in database
GPG key ID: D261413C245982F0
2 changed files with 43 additions and 44 deletions

View file

@ -1,54 +1,51 @@
$(function() { $(function() {
function slideSeparatorLines(text) { function slideSeparatorLines(text) {
var lines = text.split('\n'); var lines = text.split('\n');
var separatorLineNumbers = []; var separatorLineNumbers = [];
for (i = 0; i < lines.length; i++) { for (i = 0; i < lines.length; i++) {
var line = lines[i]; var line = lines[i];
if (line === '---') { if (line === '---') {
separatorLineNumbers.push(i); separatorLineNumbers.push(i);
} }
}
return separatorLineNumbers;
} }
return separatorLineNumbers; function currentCursorSlide(cursorLine) {
} var text = ace.edit("editor").getValue();
var separatorPositions = slideSeparatorLines(text);
var slideNumber = separatorPositions.length;
separatorPositions.every(function(pos, num) {
if (pos >= cursorLine) {
slideNumber = num;
return false;
}
return true;
});
return slideNumber;
}
function currentCursorSlide(cursorLine) {
var text = ace.edit("editor").getValue(); var editor = ace.edit("editor");
var separatorPositions = slideSeparatorLines(text); editor.setTheme("ace/theme/chrome");
var slideNumber = separatorPositions.length; editor.getSession().setMode("ace/mode/markdown");
separatorPositions.every(function(pos, num) { editor.getSession().setUseWrapMode(true);
if (pos >= cursorLine) { editor.setShowPrintMargin(true);
slideNumber = num;
return false; $.get('/slides.md', function(data) {
} editor.setValue(data, -1);
return true;
}); });
return slideNumber;
}
ace.edit('editor').getSession().selection.on('changeCursor', function(e) {
var editor = ace.edit("editor"); var cursorRow = ace.edit('editor').getCursorPosition().row;
editor.setTheme("ace/theme/chrome"); var currentSlide = currentCursorSlide(cursorRow);
editor.getSession().setMode("ace/mode/markdown"); $('#slides-frame')[0].contentWindow.postMessage(JSON.stringify({
editor.getSession().setUseWrapMode(true); method: 'slide',
editor.setShowPrintMargin(true); args: [currentSlide]
}), window.location.origin);
$.get('/slides.md', function(data) { });
editor.setValue(data, -1);
});
ace.edit('editor').getSession().selection.on('changeCursor', function(e) {
var cursorRow = ace.edit('editor').getCursorPosition().row;
var currentSlide = currentCursorSlide(cursorRow);
$('#slides-frame')[0].contentWindow.postMessage(JSON.stringify({
method: 'slide',
args: [currentSlide]
}), window.location.origin);
});
}); });

View file

@ -36,6 +36,8 @@
</head> </head>
<body> <body>
<select id="themes" hidden="true" style="float:right;">
</select>
<div class="reveal"> <div class="reveal">
<div class="slides"></div> <div class="slides"></div>
</div> </div>