From d36e6fd99155b9c83e3be1d3b9a4c699e5935053 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Wed, 16 Dec 2015 16:14:28 +0100 Subject: [PATCH] Implement play button behavior --- .../javascripts/submission_statistics.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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();