Merge remote-tracking branch 'origin/master' into rt/comments
This commit is contained in:
@ -11,6 +11,7 @@ $(function() {
|
||||
var FILENAME_URL_PLACEHOLDER = '{filename}';
|
||||
var SUCCESSFULL_PERCENTAGE = 90;
|
||||
var THEME = 'ace/theme/textmate';
|
||||
var AUTOSAVE_INTERVAL = 15 * 1000;
|
||||
|
||||
var editors = [];
|
||||
var active_file = undefined;
|
||||
@ -341,6 +342,23 @@ $(function() {
|
||||
$('button i.fa-spin').hide();
|
||||
};
|
||||
|
||||
var autosaveTimer;
|
||||
var autosaveLabel = $("#autosave-label span");
|
||||
|
||||
var resetSaveTimer = function(){
|
||||
clearTimeout(autosaveTimer);
|
||||
autosaveTimer = setTimeout(autosave, AUTOSAVE_INTERVAL);
|
||||
};
|
||||
|
||||
var autosave = function(){
|
||||
var date = new Date();
|
||||
autosaveLabel.parent().css("visibility", "visible");
|
||||
autosaveLabel.text(date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds());
|
||||
autosaveLabel.text(date.toLocaleTimeString());
|
||||
autosaveTimer = null;
|
||||
createSubmission($('#autosave'), null);
|
||||
}
|
||||
|
||||
var initializeEditors = function() {
|
||||
$('.editor').each(function(index, element) {
|
||||
var editor = ace.edit(element);
|
||||
@ -350,6 +368,12 @@ $(function() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// listener for autosave
|
||||
editor.getSession().on("change", function (deltaObject) {
|
||||
resetSaveTimer();
|
||||
});
|
||||
|
||||
var document = editor.getSession().getDocument();
|
||||
// insert pre-existing code into editor. we have to use insertLines, otherwise the deltas are not properly added
|
||||
var file_id = $(element).data('file-id');
|
||||
@ -875,12 +899,14 @@ $(function() {
|
||||
icon: ['fa', 'fa-bug'],
|
||||
text: $('#run').data('message-failure')
|
||||
});
|
||||
} else {
|
||||
}
|
||||
/* do not show the success message any longer, puzzles and distracts users.
|
||||
else {
|
||||
$.flash.success({
|
||||
icon: ['fa', 'fa-check'],
|
||||
text: $('#run').data('message-success')
|
||||
});
|
||||
}
|
||||
} */
|
||||
};
|
||||
|
||||
var showContainerDepletedMessage = function() {
|
||||
@ -1020,6 +1046,13 @@ $(function() {
|
||||
}
|
||||
}
|
||||
|
||||
$(window).on("beforeunload", function() {
|
||||
if(autosaveTimer){
|
||||
autosave();
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
if ($('#editor').isPresent()) {
|
||||
if (isBrowserSupported()) {
|
||||
initializeCodePilot();
|
||||
|
Reference in New Issue
Block a user