sub preview

This commit is contained in:
j 2017-10-05 20:57:12 +02:00
parent 2a66932bff
commit 0afd7362d6
2 changed files with 28 additions and 7 deletions

View file

@ -1 +1,9 @@
<style>
body {
font-family: sans-serif;
font-size: 32px;
text-align: center;
margin-top: 32px;
}
</style>
<script src="subtitles.js"></script>

View file

@ -12,25 +12,38 @@ app.render = function() {
var html = ''
html += 'Current Time: ' + app.status.currentTime + '<br>'
//html += 'Current Time: ' + app.status.currentTime + '<br>'
//
var showNext = 0
var update = false
if (app.status.subtitles[app.status.current]) {
app.status.subtitles[app.status.current].forEach(function(sub) {
if (app.status.currentTime >= sub['in'] && app.status.currentTime < sub.out) {
html += '<br><br><b>' + sub['in'] + ' ' + sub.out + ': ' + sub.value + '</b>'
} else {
html += '<br><br>' + sub['in'] + ' ' + sub.out + ': ' + sub.value
//html += '<br><br><b>' + sub['in'] + ' ' + sub.out + ': ' + sub.value + '</b>'
html += '<br><br><b>' + sub.value + '</b>'
showNext = 10
update = true
} else if (showNext) {
//html += '<br><br>' + sub['in'] + ' ' + sub.out + ': ' + sub.value
html += '<br><br>' + sub.value
showNext -= 1
}
})
}
if (app.status.subtitles[app.status.next]) {
html += '<br><br>Next: '
app.status.subtitles[app.status.next].forEach(function(sub) {
html += '<br><br>' + sub['in'] + ' ' + sub.out + ': ' + sub.value
if (showNext) {
//html += '<br><br>' + sub['in'] + ' ' + sub.out + ': ' + sub.value
html += '<br><br>' + sub.value
showNext -= 1
}
})
}
if (update) {
document.body.innerHTML = html
}
}
app.connectWS = function() {
app.ws = new WebSocket('ws://' + document.location.host + '/ws/')