From 1833435268b4637cb57827fe9e28adf7e827e0b0 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Wed, 5 Dec 2018 13:46:44 +0100 Subject: [PATCH] Use CodeOceanEditor.active_file to access file selected in JSFileTree --- app/assets/javascripts/editor/submissions.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/editor/submissions.js b/app/assets/javascripts/editor/submissions.js index 4dae40b5..f55bdbb5 100644 --- a/app/assets/javascripts/editor/submissions.js +++ b/app/assets/javascripts/editor/submissions.js @@ -85,7 +85,7 @@ CodeOceanEditorSubmissions = { destroyFile: function() { this.createSubmission($('#destroy-file'), function(files) { return _.reject(files, function(file) { - return file.file_id === active_file.id; + return file.file_id === CodeOceanEditor.active_file.id; }); }, window.CodeOcean.refresh); }, @@ -124,7 +124,7 @@ CodeOceanEditorSubmissions = { event.preventDefault(); if ($('#render').is(':visible')) { this.createSubmission('#render', null, function (response) { - var url = response.render_url.replace(this.FILENAME_URL_PLACEHOLDER, this.active_file.filename.replace(/#$/,'')); // remove # if it is the last character, this is not part of the filename and just an anchor + var url = response.render_url.replace(this.FILENAME_URL_PLACEHOLDER, CodeOceanEditor.active_file.filename.replace(/#$/,'')); // remove # if it is the last character, this is not part of the filename and just an anchor var pop_up_window = window.open(url); if (pop_up_window) { pop_up_window.onerror = function (message) { @@ -157,7 +157,7 @@ CodeOceanEditorSubmissions = { this.showSpinner($('#run')); $('#score_div').addClass('d-none'); this.toggleButtonStates(); - var url = submission.run_url.replace(this.FILENAME_URL_PLACEHOLDER, this.active_file.filename.replace(/#$/,'')); // remove # if it is the last character, this is not part of the filename and just an anchor + var url = submission.run_url.replace(this.FILENAME_URL_PLACEHOLDER, CodeOceanEditor.active_file.filename.replace(/#$/,'')); // remove # if it is the last character, this is not part of the filename and just an anchor this.initializeSocketForRunning(url); }, @@ -176,7 +176,7 @@ CodeOceanEditorSubmissions = { this.createSubmission('#test', null, function(response) { this.showSpinner($('#test')); $('#score_div').addClass('d-none'); - var url = response.test_url.replace(this.FILENAME_URL_PLACEHOLDER, this.active_file.filename.replace(/#$/,'')); // remove # if it is the last character, this is not part of the filename and just an anchor + var url = response.test_url.replace(this.FILENAME_URL_PLACEHOLDER, CodeOceanEditor.active_file.filename.replace(/#$/,'')); // remove # if it is the last character, this is not part of the filename and just an anchor this.initializeSocketForTesting(url); }.bind(this)); }