diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index 76ecde01..2a0a8b35 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -35,7 +35,7 @@ var CodeOceanEditor = { lastCopyText: null, autosaveTimer: null, - autosaveLabel: $("#autosave-label span"), + autosaveLabel: "#autosave-label span", ENTER_KEY_CODE: 13, @@ -189,9 +189,10 @@ var CodeOceanEditor = { autosave: function () { var date = new Date(); - this.autosaveLabel.parent().css("visibility", "visible"); - this.autosaveLabel.text(date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds()); - this.autosaveLabel.text(date.toLocaleTimeString()); + var autosaveLabel = $(this.autosaveLabel); + autosaveLabel.parent().css("visibility", "visible"); + autosaveLabel.text(date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds()); + autosaveLabel.text(date.toLocaleTimeString()); this.autosaveTimer = null; this.createSubmission($('#autosave'), null); }, diff --git a/app/assets/javascripts/editor/evaluation.js.erb b/app/assets/javascripts/editor/evaluation.js.erb index 4e19bc9a..2235e137 100644 --- a/app/assets/javascripts/editor/evaluation.js.erb +++ b/app/assets/javascripts/editor/evaluation.js.erb @@ -138,13 +138,13 @@ CodeOceanEditorEvaluation = { }, killWebsocketAndContainer: function () { - if (this.websocket.readyState != WebSocket.OPEN) { + if (this.websocket.getReadyState() != WebSocket.OPEN) { return; } this.websocket.send(JSON.stringify({cmd: 'exit'})); - this.websocket.flush(); - this.websocket.close(); + this.websocket.killWebSocket(); + this.hideSpinner(); this.running = false; this.toggleButtonStates(); diff --git a/app/assets/javascripts/editor/websocket.js.erb b/app/assets/javascripts/editor/websocket.js.erb index 4c3f9787..e4c45e24 100644 --- a/app/assets/javascripts/editor/websocket.js.erb +++ b/app/assets/javascripts/editor/websocket.js.erb @@ -88,3 +88,18 @@ CommandSocket.prototype.executeCommand = function(cmd) { CommandSocket.prototype.send = function(data) { this.websocket.send(data); }; + +/** + * Returns the ready state of the socket. + */ +CommandSocket.prototype.getReadyState = function() { + return this.websocket.readyState; +}; + +/** + * Closes the websocket. + */ +CommandSocket.prototype.killWebSocket = function() { + this.websocket.flush(); + this.websocket.close(); +}; \ No newline at end of file