Open Render in new Tab with timeout (to resolve issue with Safari)

This commit is contained in:
Sebastian Serth
2022-09-23 21:06:41 +02:00
parent 150df3d219
commit b4ab807ef0

View File

@ -139,17 +139,21 @@ CodeOceanEditorSubmissions = {
const active_file = CodeOceanEditor.active_file.filename.replace(/#$/,''); // remove # if it is the last character, this is not part of the filename and just an anchor const active_file = CodeOceanEditor.active_file.filename.replace(/#$/,''); // remove # if it is the last character, this is not part of the filename and just an anchor
const desired_file = response.render_url.filter(hash => hash.filepath === active_file); const desired_file = response.render_url.filter(hash => hash.filepath === active_file);
const url = desired_file[0].url; const url = desired_file[0].url;
var pop_up_window = window.open(url, '_blank'); // Allow to open the new tab even in Safari.
if (pop_up_window) { // See: https://stackoverflow.com/a/70463940
pop_up_window.onerror = function (message) { setTimeout(() => {
this.clearOutput(); var pop_up_window = window.open(url, '_blank');
this.printOutput({ if (pop_up_window) {
stderr: message pop_up_window.onerror = function (message) {
}, true, 0); this.clearOutput();
this.sendError(message, response.id); this.printOutput({
this.showOutputBar(); stderr: message
}; }, true, 0);
} this.sendError(message, response.id);
this.showOutputBar();
};
}
})
}); });
} }
}, },