diff --git a/app/assets/javascripts/submission_statistics.js b/app/assets/javascripts/submission_statistics.js index 75fe42cd..5bf5e76c 100644 --- a/app/assets/javascripts/submission_statistics.js +++ b/app/assets/javascripts/submission_statistics.js @@ -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();