Merge pull request #223 from openHPI/jg/fix-editor-active-file

Jg/fix editor active file
This commit is contained in:
rteusner
2018-10-19 15:45:34 +02:00
committed by GitHub
4 changed files with 25 additions and 10 deletions

View File

@@ -269,11 +269,11 @@ configureEditors: function () {
initializeFileTree: function () {
$('#files').jstree($('#files').data('entries'));
$('#files').on('click', 'li.jstree-leaf', function (event) {
active_file = {
filename: $(event.target).parent().text(),
id: parseInt($(event.target).parent().attr('id'))
};
var frame = $('[data-file-id="' + active_file.id + '"]').parent();
this.setActiveFile(
$(event.target).parent().text(),
parseInt($(event.target).parent().attr('id'))
);
var frame = $('[data-file-id="' + this.active_file.id + '"]').parent();
this.showFrame(frame);
this.toggleButtonStates();
}.bind(this));

View File

@@ -2,8 +2,9 @@ CodeOceanEditorWebsocket = {
websocket: null,
createSocketUrl: function(url) {
var sockURL = new URL(window.location);
sockURL.pathname = url;
var sockURL = new URL(url, window.location);
// not needed any longer, we put it directly into the url: sockURL.pathname = url;
// sanitize socket protocol string, strip trailing slash and other malicious chars if they are there
sockURL.protocol = '<%= DockerClient.config['ws_client_protocol']&.match(/(\w+):*\/*/)&.to_a&.at(1) %>:';