augmentStacktraceInOutput no longer duplicates results
This commit is contained in:
@ -36,7 +36,7 @@ var CodeOceanEditor = {
|
||||
fileTypeURL: "<%= file_types_path %>",
|
||||
|
||||
|
||||
configureEditors: function () {
|
||||
configureEditors: function () {
|
||||
_.each(['modePath', 'themePath', 'workerPath'], function (attribute) {
|
||||
ace.config.set(attribute, this.ACE_FILES_PATH);
|
||||
}.bind(this));
|
||||
@ -59,7 +59,7 @@ configureEditors: function () {
|
||||
confirmResetActiveFile: function (event) {
|
||||
event.preventDefault();
|
||||
let message = $('#start-over-active-file').data('message-confirm');
|
||||
message = message.replace('%{filename}', CodeOceanEditor.active_file.filename.replace(/#$/,''))
|
||||
message = message.replace('%{filename}', CodeOceanEditor.active_file.filename.replace(/#$/, ''))
|
||||
if (confirm(message)) {
|
||||
this.resetCode(true); // delete only active file
|
||||
}
|
||||
@ -99,13 +99,13 @@ configureEditors: function () {
|
||||
}
|
||||
},
|
||||
|
||||
showOutput: function(event) {
|
||||
showOutput: function (event) {
|
||||
event.preventDefault();
|
||||
this.showOutputBar();
|
||||
$('body').scrollTo($(event.target).attr('href'));
|
||||
},
|
||||
|
||||
renderProgressBar: function(score, maximum_score) {
|
||||
renderProgressBar: function (score, maximum_score) {
|
||||
var percentage = score / maximum_score * 100;
|
||||
var progress_bar = $('#score .progress-bar');
|
||||
progress_bar.removeClass().addClass(this.getProgressBarClass(percentage));
|
||||
@ -118,7 +118,7 @@ configureEditors: function () {
|
||||
},
|
||||
|
||||
// The event ready.jstree is fired too early and thus doesn't work.
|
||||
selectFileInJsTree: function(filetree, file_id) {
|
||||
selectFileInJsTree: function (filetree, file_id) {
|
||||
if (!filetree.is(':visible'))
|
||||
// The left sidebar is not shown and thus the filetree is not rendered.
|
||||
return;
|
||||
@ -131,7 +131,7 @@ configureEditors: function () {
|
||||
}
|
||||
},
|
||||
|
||||
showFirstFile: function() {
|
||||
showFirstFile: function () {
|
||||
var frame = $('.frame[data-role="main_file"]').isPresent() ? $('.frame[data-role="main_file"]') : $('.frame').first();
|
||||
var file_id = frame.find('.editor').data('file-id');
|
||||
this.setActiveFile(frame.data('filename'), file_id);
|
||||
@ -141,7 +141,7 @@ configureEditors: function () {
|
||||
this.toggleButtonStates();
|
||||
},
|
||||
|
||||
showFrame: function(frame) {
|
||||
showFrame: function (frame) {
|
||||
this.active_frame = frame;
|
||||
$('.frame').hide();
|
||||
frame.show();
|
||||
@ -194,14 +194,14 @@ configureEditors: function () {
|
||||
},
|
||||
|
||||
|
||||
resizeAceEditors: function (){
|
||||
resizeAceEditors: function () {
|
||||
$('.editor').each(function (index, element) {
|
||||
this.resizeParentOfAceEditor(element);
|
||||
}.bind(this));
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
},
|
||||
|
||||
resizeParentOfAceEditor: function (element){
|
||||
resizeParentOfAceEditor: function (element) {
|
||||
// calculate needed size: window height - position of top of ACE editor - height of autosave label below editor - 5 for bar margins
|
||||
var windowHeight = window.innerHeight - $(element).offset().top - $('#autosave-label').height() - 5;
|
||||
$(element).parent().height(windowHeight);
|
||||
@ -215,7 +215,7 @@ configureEditors: function () {
|
||||
this.resizeParentOfAceEditor(element);
|
||||
|
||||
// Resize frame on window size change
|
||||
$(window).resize(function(){
|
||||
$(window).resize(function () {
|
||||
this.resizeParentOfAceEditor(element);
|
||||
}.bind(this));
|
||||
|
||||
@ -246,9 +246,8 @@ configureEditors: function () {
|
||||
editor.setTheme(this.THEME);
|
||||
|
||||
|
||||
|
||||
// set options for autocompletion
|
||||
if($(element).data('allow-auto-completion')){
|
||||
if ($(element).data('allow-auto-completion')) {
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: false,
|
||||
@ -338,13 +337,13 @@ configureEditors: function () {
|
||||
$('#request-for-comments').on('click', this.requestComments.bind(this));
|
||||
},
|
||||
|
||||
initializeSideBarCollapse: function() {
|
||||
$('#sidebar-collapse-collapsed').on('click',this.handleSideBarToggle.bind(this));
|
||||
$('#sidebar-collapse').on('click',this.handleSideBarToggle.bind(this))
|
||||
$('#sidebar').on('transitionend',this.resizeAceEditors.bind(this));
|
||||
initializeSideBarCollapse: function () {
|
||||
$('#sidebar-collapse-collapsed').on('click', this.handleSideBarToggle.bind(this));
|
||||
$('#sidebar-collapse').on('click', this.handleSideBarToggle.bind(this))
|
||||
$('#sidebar').on('transitionend', this.resizeAceEditors.bind(this));
|
||||
},
|
||||
|
||||
handleSideBarToggle: function() {
|
||||
handleSideBarToggle: function () {
|
||||
$('#sidebar').toggleClass('sidebar-col').toggleClass('sidebar-col-collapsed');
|
||||
$('#sidebar-collapsed').toggleClass('d-none');
|
||||
$('#sidebar-uncollapsed').toggleClass('d-none');
|
||||
@ -384,14 +383,14 @@ configureEditors: function () {
|
||||
});
|
||||
|
||||
$('#askForCommentsButton').on('click', this.requestComments.bind(this));
|
||||
$('#closeAskForCommentsButton').on('click', function(){
|
||||
$('#closeAskForCommentsButton').on('click', function () {
|
||||
$('#comment-modal').modal('hide');
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
button.prop('disabled', false);
|
||||
button.tooltip('show');
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
button.tooltip('hide');
|
||||
}, this.REQUEST_TOOLTIP_TIME);
|
||||
}.bind(this), this.REQUEST_FOR_COMMENTS_DELAY);
|
||||
@ -466,7 +465,7 @@ configureEditors: function () {
|
||||
},
|
||||
|
||||
publishCodeOceanEvent: function (payload) {
|
||||
if(this.sendEvents){
|
||||
if (this.sendEvents) {
|
||||
$.ajax(this.eventURL, {
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
@ -520,19 +519,22 @@ configureEditors: function () {
|
||||
|
||||
augmentStacktraceInOutput: function () {
|
||||
if (this.tracepositions_regex) {
|
||||
var element = $('#output>pre');
|
||||
var text = element.text();
|
||||
$('#output>pre').each($.proxy(function(index, element) {
|
||||
element = $(element)
|
||||
const text = element.text();
|
||||
element.on("click", "a", this.jumpToSourceLine.bind(this));
|
||||
|
||||
var matches;
|
||||
let matches;
|
||||
|
||||
while (matches = this.tracepositions_regex.exec(text)) {
|
||||
var frame = $('div.frame[data-filename="' + matches[1] + '"]')
|
||||
const frame = $('div.frame[data-filename="' + matches[1] + '"]')
|
||||
|
||||
if (frame.length > 0) {
|
||||
element.html(text.replace(matches[0], "<a href='#' data-file='" + matches[1] + "' data-line='" + matches[2] + "'>" + matches[0] + "</a>"));
|
||||
element.html(text.replace(new RegExp(matches[0], 'g'), "<a href='#' data-file='" + matches[1] + "' data-line='" + matches[2] + "'>" + matches[0] + "</a>"));
|
||||
}
|
||||
}
|
||||
|
||||
}, this));
|
||||
}
|
||||
},
|
||||
|
||||
@ -558,12 +560,12 @@ configureEditors: function () {
|
||||
};
|
||||
},
|
||||
|
||||
showSpinner: function(initiator) {
|
||||
showSpinner: function (initiator) {
|
||||
$(initiator).find('i.fa').hide();
|
||||
$(initiator).find('i.fa-spin').show();
|
||||
},
|
||||
|
||||
showStatus: function(output) {
|
||||
showStatus: function (output) {
|
||||
if (output.status === 'timeout') {
|
||||
this.showTimeoutMessage();
|
||||
} else if (output.status === 'container_depleted') {
|
||||
@ -577,14 +579,14 @@ configureEditors: function () {
|
||||
}
|
||||
},
|
||||
|
||||
clearHints: function() {
|
||||
clearHints: function () {
|
||||
var container = $('#error-hints');
|
||||
container.find('ul.body > li.hint').remove();
|
||||
container.fadeOut();
|
||||
},
|
||||
|
||||
showHint: function(message) {
|
||||
var template = function(description, hint) {
|
||||
showHint: function (message) {
|
||||
var template = function (description, hint) {
|
||||
return '\
|
||||
<li class="hint">\
|
||||
<div class="description">\
|
||||
@ -601,21 +603,21 @@ configureEditors: function () {
|
||||
container.fadeIn();
|
||||
},
|
||||
|
||||
showContainerDepletedMessage: function() {
|
||||
showContainerDepletedMessage: function () {
|
||||
$.flash.danger({
|
||||
icon: ['fa', 'fa-clock-o'],
|
||||
text: $('#editor').data('message-depleted')
|
||||
});
|
||||
},
|
||||
|
||||
showTimeoutMessage: function() {
|
||||
showTimeoutMessage: function () {
|
||||
$.flash.info({
|
||||
icon: ['fa', 'fa-clock-o'],
|
||||
text: $('#editor').data('message-timeout')
|
||||
});
|
||||
},
|
||||
|
||||
showWebsocketError: function(error) {
|
||||
showWebsocketError: function (error) {
|
||||
if (window.navigator.userAgent.indexOf('Edge') > -1 || window.navigator.userAgent.indexOf('Trident') > -1) {
|
||||
// Mute errors in Microsoft Edge and Internet Explorer
|
||||
return;
|
||||
@ -627,42 +629,42 @@ configureEditors: function () {
|
||||
Sentry.captureException(JSON.stringify(error));
|
||||
},
|
||||
|
||||
showFileDialog: function(event) {
|
||||
showFileDialog: function (event) {
|
||||
event.preventDefault();
|
||||
this.createSubmission('#create-file', null, function(response) {
|
||||
this.createSubmission('#create-file', null, function (response) {
|
||||
$('#code_ocean_file_context_id').val(response.id);
|
||||
$('#modal-file').modal('show');
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
initializeOutputBarToggle: function() {
|
||||
$('#toggle-sidebar-output').on('click',this.hideOutputBar.bind(this));
|
||||
$('#toggle-sidebar-output-collapsed').on('click',this.showOutputBar.bind(this));
|
||||
$('#output_sidebar').on('transitionend',this.resizeAceEditors.bind(this));
|
||||
initializeOutputBarToggle: function () {
|
||||
$('#toggle-sidebar-output').on('click', this.hideOutputBar.bind(this));
|
||||
$('#toggle-sidebar-output-collapsed').on('click', this.showOutputBar.bind(this));
|
||||
$('#output_sidebar').on('transitionend', this.resizeAceEditors.bind(this));
|
||||
},
|
||||
|
||||
showOutputBar: function() {
|
||||
showOutputBar: function () {
|
||||
$('#output_sidebar_collapsed').addClass('d-none');
|
||||
$('#output_sidebar_uncollapsed').removeClass('d-none');
|
||||
$('#output_sidebar').removeClass('output-col-collapsed').addClass('output-col');
|
||||
},
|
||||
|
||||
hideOutputBar: function() {
|
||||
hideOutputBar: function () {
|
||||
$('#output_sidebar_collapsed').removeClass('d-none');
|
||||
$('#output_sidebar_uncollapsed').addClass('d-none');
|
||||
$('#output_sidebar').removeClass('output-col').addClass('output-col-collapsed');
|
||||
},
|
||||
|
||||
initializeSideBarTooltips: function() {
|
||||
initializeSideBarTooltips: function () {
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
},
|
||||
|
||||
initializeDescriptionToggle: function() {
|
||||
initializeDescriptionToggle: function () {
|
||||
$('#exercise-headline').on('click', this.toggleDescriptionCard.bind(this));
|
||||
$('a#toggle').on('click', this.toggleDescriptionCard.bind(this));
|
||||
},
|
||||
|
||||
toggleDescriptionCard: function() {
|
||||
toggleDescriptionCard: function () {
|
||||
$('#description-card').toggleClass('description-card-collapsed').toggleClass('description-card');
|
||||
$('#description-symbol').toggleClass('fa-chevron-down').toggleClass('fa-chevron-right');
|
||||
var toggle = $('a#toggle');
|
||||
@ -674,11 +676,15 @@ configureEditors: function () {
|
||||
/**
|
||||
* interventions
|
||||
* */
|
||||
initializeInterventionTimer: function() {
|
||||
initializeInterventionTimer: function () {
|
||||
|
||||
if ($('#editor').data('rfc-interventions') || $('#editor').data('break-interventions')) { // split in break or rfc intervention
|
||||
window.onblur = function() { window.blurred = true; };
|
||||
window.onfocus = function() { window.blurred = false; };
|
||||
window.onblur = function () {
|
||||
window.blurred = true;
|
||||
};
|
||||
window.onfocus = function () {
|
||||
window.blurred = false;
|
||||
};
|
||||
|
||||
var delta = 100; // time in ms to wait for window event before time gets stopped
|
||||
var tid;
|
||||
@ -706,10 +712,12 @@ configureEditors: function () {
|
||||
var timeUntilIntervention = Math.max(percentile75 - accumulatedWorkTimeUser, minTimeIntervention);
|
||||
}
|
||||
|
||||
tid = setInterval(function() {
|
||||
if ( window.blurred ) { return; }
|
||||
tid = setInterval(function () {
|
||||
if (window.blurred) {
|
||||
return;
|
||||
}
|
||||
timeUntilIntervention -= delta;
|
||||
if ( timeUntilIntervention <= 0 ) {
|
||||
if (timeUntilIntervention <= 0) {
|
||||
clearInterval(tid);
|
||||
// timeUntilIntervention passed
|
||||
if ($('#editor').data('break-interventions')) {
|
||||
@ -722,7 +730,7 @@ configureEditors: function () {
|
||||
type: 'POST',
|
||||
url: $('#editor').data('intervention-save-url')
|
||||
});
|
||||
} else if ($('#editor').data('rfc-interventions')){
|
||||
} else if ($('#editor').data('rfc-interventions')) {
|
||||
var button = $('#requestComments');
|
||||
// only show intervention if user did not requested for a comment already
|
||||
if (!button.prop('disabled')) {
|
||||
@ -745,8 +753,8 @@ configureEditors: function () {
|
||||
}
|
||||
},
|
||||
|
||||
initializeSearchButton: function(){
|
||||
$('#btn-search-col').button().click(function(){
|
||||
initializeSearchButton: function () {
|
||||
$('#btn-search-col').button().click(function () {
|
||||
var search = $('#search-input-text').val();
|
||||
var course_token = $('#editor').data('course_token')
|
||||
var save_search_url = $('#editor').data('search-save-url')
|
||||
@ -758,14 +766,15 @@ configureEditors: function () {
|
||||
},
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
url: save_search_url});
|
||||
url: save_search_url
|
||||
});
|
||||
})
|
||||
|
||||
$('#sidebar-search-collapsed').on('click',this.handleSideBarToggle.bind(this));
|
||||
$('#sidebar-search-collapsed').on('click', this.handleSideBarToggle.bind(this));
|
||||
},
|
||||
|
||||
|
||||
initializeEverything: function() {
|
||||
initializeEverything: function () {
|
||||
this.initializeRegexes();
|
||||
this.initializeCodePilot();
|
||||
$('.score, #development-environment').show();
|
||||
|
Reference in New Issue
Block a user