Update editor content on submission selection
This commit is contained in:
32
app/assets/javascripts/submission_statistics.js
Normal file
32
app/assets/javascripts/submission_statistics.js
Normal file
@ -0,0 +1,32 @@
|
||||
$(function() {
|
||||
|
||||
if ($.isController('exercises') && $('#timeline').isPresent()) {
|
||||
|
||||
var editors = $('.editor');
|
||||
var slider = $('#slider>input');
|
||||
var submissions = $('#data').data('submissions');
|
||||
var files = $('#data').data('files');
|
||||
|
||||
editors.each(function(index, editor) {
|
||||
currentEditor = ace.edit(editor);
|
||||
currentEditor.$blockScrolling = Infinity;
|
||||
currentEditor.setReadOnly(true);
|
||||
});
|
||||
|
||||
slider.on('change', function(event) {
|
||||
var currentSubmission = slider.val();
|
||||
var currentFiles = JSON.parse(files[currentSubmission]);
|
||||
|
||||
editors.each(function(index, editor) {
|
||||
currentEditor = ace.edit(editor);
|
||||
fileContent = "";
|
||||
if (currentFiles[index]) {
|
||||
fileContent = currentFiles[index].content
|
||||
}
|
||||
currentEditor.getSession().setValue(fileContent);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
Reference in New Issue
Block a user