Implement play button behavior

This commit is contained in:
Maximilian Grundke
2015-12-16 16:14:28 +01:00
parent 6609a5d1ec
commit d36e6fd991

View File

@ -55,6 +55,8 @@ $(function() {
var submissions = $('#data').data('submissions');
var files = $('#data').data('files');
var filetypes = $('#data').data('file-types');
var playButton = $('#play-button');
var playInterval = undefined;
editor = ace.edit('current-file');
editor.setShowPrintMargin(false);
@ -88,6 +90,23 @@ $(function() {
showActiveFile();
});
playButton.on('click', function(event) {
if (playInterval == undefined) {
playInterval = setInterval(function() {
if ($.isController('exercises') && $('#timeline').isPresent() && slider.val() < submissions.length - 1) {
slider.val(parseInt(slider.val()) + 1);
slider.change()
} else {
clearInterval(playInterval);
}
}, 5000);
playButton.find('span.glyphicon').removeClass('glyphicon-play').addClass('glyphicon-pause')
} else {
clearInterval(playInterval);
playButton.find('span.glyphicon').removeClass('glyphicon-pause').addClass('glyphicon-play')
}
});
active_file = files[0][0]
initializeFileTree();
showActiveFile();