Update editor content on submission selection

This commit is contained in:
Maximilian Grundke
2015-11-26 16:25:59 +01:00
parent bd9118328f
commit baf33419cf
2 changed files with 37 additions and 1 deletions

View 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);
});
});
}
});