From 82cab390ad8bbb0dae44a39df83dcc70ad150e06 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Sun, 10 Oct 2021 12:11:26 +0200 Subject: [PATCH] Remove outdated run method from turtle.js --- app/assets/javascripts/turtle.js | 79 -------------------------------- 1 file changed, 79 deletions(-) diff --git a/app/assets/javascripts/turtle.js b/app/assets/javascripts/turtle.js index 1563d299..d3066e54 100644 --- a/app/assets/javascripts/turtle.js +++ b/app/assets/javascripts/turtle.js @@ -205,82 +205,3 @@ Turtle.prototype.css = function (key, value) { this.canvas.css(key, value); } }; - -function run(launchmsg) { - var i, turtlescreen, msg, result, cmd; - $('#assess').empty(); - - turtlescreen = new Turtle(); - - output = $('#output'); - output.empty(); - if (typeof pipeurl === 'undefined') { - if (wp_port === '443') { - pipeurl = 'wss://'+wp_hostname+'/pipe'; - } else { - pipeurl = 'ws://'+wp_hostname+':'+wp_port+'/pipe'; - } - } - saveFile(); - output.pipe = new WebSocket(pipeurl); - output.pipe.onopen = function () { - output.pipe.send(JSON.stringify(launchmsg)); - }; - output.pipe.onmessage = function (response) { - msg = JSON.parse(response.data); - if (msg.cmd === 'input') { - output.inputelem = $('',{'size':40}); - submit = $('',{'type':'submit'}); - submit.click(function (){ - text = output.inputelem.val(); - output.input.replaceWith($('', {text:text+'\n'})); - output.pipe.send(JSON.stringify({'cmd':'inputresult', - 'data':text})); - }); - output.inputelem.keydown(function(event){ - if(event.keyCode === 13){ - submit.click(); - } - }); - output.append($('', {text:msg.data})); - output.input = $('').append(output.inputelem).append(submit); - output.append(output.input); - output.inputelem.focus(); - } else if (msg.cmd === 'stop') { - if (launchmsg.cmd === 'runscript') { - if (msg.timedout) { - output.append('
Dein Programm hat zu lange gerechnet und wurde beendet.'); - } else { - output.append('
Dein Progamm wurde beendet'); - } - } - output.pipe.close(); - } else if (msg.cmd === 'passed') { - $('#assess').html("Herzlich Glückwunsch! Dein Programm funktioniert korrekt."); - } else if (msg.cmd === 'failed') { - $('#assess').html(msg.data); - } else if (msg.cmd === 'turtle') { - if (msg.action in turtlescreen) { - result = turtlescreen[msg.action].apply(turtlescreen, msg.args); - output.pipe.send(JSON.stringify({cmd:'result', 'result':result})); - } else { - output.pipe.send(JSON.stringify({cmd:'exception', exception:'AttributeError', - message:msg.action})); - } - } else if (msg.cmd === 'turtlebatch') { - for (i=0; i < msg.batch.length; i += 1) { - cmd = msg.batch[i]; - turtlescreen[cmd[0]].apply(turtlescreen, cmd[1]); - } - } else { - if(msg.stream === 'internal') { - output.append('
Interner Fehler (bitte melden):\n'); - } - else if (msg.stream === 'stderr') { - showConsole(); - $('#consoleradio').prop('checked', 'checked'); - } - output.append($('',{text:msg.data, 'class':msg.stream})); - } - }; -}