@@ -3,7 +3,7 @@ author: André Dietrich
33
44email: LiaScript@web.de
55
6- version: 0.0.3
6+ version: 0.0.4
77
88language: en
99
@@ -17,6 +17,7 @@ window.CodeRunner = {
1717 error: "",
1818 url: "",
1919 firstConnection: true,
20+ pingTimer: null,
2021
2122 init(url, step = 0) {
2223 this.url = url
@@ -39,11 +40,10 @@ window.CodeRunner = {
3940 this.ws.onopen = function () {
4041 clearTimeout(connectionTimeout);
4142 self.log("connections established");
42-
4343 self.connected = true
44-
45- setInterval(function() {
46- self.ws.send("ping")
44+ if (self.pingTimer) clearInterval(self.pingTimer)
45+ self.pingTimer = setInterval(function() {
46+ try { self.ws.send("ping") } catch (_) {}
4747 }, 15000);
4848 }
4949 this.ws.onmessage = function (e) {
@@ -61,16 +61,17 @@ window.CodeRunner = {
6161 }
6262 this.ws.onclose = function () {
6363 clearTimeout(connectionTimeout);
64+ if (self.pingTimer) { clearInterval(self.pingTimer); self.pingTimer = null }
6465 self.connected = false
6566 self.warn("connection closed ... reconnecting")
66-
6767 setTimeout(function(){
6868 console.warn("....", step+1)
6969 self.init(url, step+1)
7070 }, 1000)
7171 }
7272 this.ws.onerror = function (e) {
7373 clearTimeout(connectionTimeout);
74+ if (self.pingTimer) { clearInterval(self.pingTimer); self.pingTimer = null }
7475 self.warn("an error has occurred")
7576 }
7677 },
@@ -2215,29 +2216,54 @@ window.CodeRunner = {
22152216}
22162217
22172218//window.CodeRunner.init("wss://coderunner.informatik.tu-freiberg.de/")
2218- //window.CodeRunner.init("ws://127.0.0.1:8000 /")
2219+ //window.CodeRunner.init("ws://localhost:4000 /")
22192220window.CodeRunner.init("wss://ancient-hollows-41316.herokuapp.com/")
22202221@end
22212222
22222223
22232224@LIA.ada: @LIA.eval(`["main.ada"]`, `gnatmake main.ada`, `./main`)
2225+ @LIA.algol: @LIA.eval(`["main.alg"]`, `none`, `a68g main.alg`)
2226+ @LIA.apl: @LIA.eval(`["main.apl"]`, `none`, `dyalog -script main.apl`)
2227+ @LIA.awk: @LIA.eval(`["main.awk"]`, `none`, `awk -f main.awk`)
2228+ @LIA.basic: @LIA.eval(`["main.bas"]`, `none`, `bwbasic main.bas`)
22242229@LIA.c: @LIA.eval(`["main.c"]`, `gcc -Wall main.c -o a.out`, `./a.out`)
22252230@LIA.clojure: @LIA.eval(`["main.clj"]`, `none`, `clojure -M main.clj`)
22262231@LIA.clojure_withShell: @LIA.eval(`["main.clj"]`, `none`, `clojure -M -i main.clj -r`)
22272232@LIA.cpp: @LIA.eval(`["main.cpp"]`, `g++ main.cpp -o a.out`, `./a.out`)
2233+ @LIA.cobol: @LIA.eval(`["main.cob"]`, `cobc -x --free main.cob`, `./main`)
2234+ @LIA.coq: @LIA.eval(`["file.v"]`, `coqc file.v`, `coqtop -lv file.v`)
2235+ @LIA.d: @LIA.eval(`["main.d"]`, `gdc main.d`, `./a.out`)
22282236@LIA.elixir: @LIA.eval(`["main.exs"]`, `none`, `elixir main.exs`)
22292237@LIA.elixir_withShell: @LIA.eval(`["main.exs"]`, `none`, `iex main.exs`)
2238+ @LIA.erlang: @LIA.eval(`["hello.erl"]`, `erlc hello.erl`, `erl -noshell -s hello hello -s init stop`)
2239+ @LIA.erlang_withShell: @LIA.eval(`["hello.erl"]`, `erlc hello.erl`, `erl -noshell -s hello hello`)
2240+ @LIA.forth: @LIA.eval(`["main.fs"]`, `none`, `gforth main.fs -e BYE`)
2241+ @LIA.forth_withShell: @LIA.eval(`["main.fs"]`, `none`, `gforth main.fs`)
2242+ @LIA.fortran: @LIA.eval(`["main.f90"]`, `gfortran main.f90 -o a.out`, `./a.out`)
22302243@LIA.go: @LIA.eval(`["main.go"]`, `go build main.go`, `./main`)
2244+ @LIA.groovy: @LIA.eval(`["main.groovy"]`, `none`, `groovy main.groovy`)
22312245@LIA.haskell: @LIA.eval(`["main.hs"]`, `ghc main.hs -o main`, `./main`)
22322246@LIA.haskell_withShell: @LIA.eval(`["main.hs"]`, `none`, `ghci main.hs`)
2247+ @LIA.haxe: @LIA.eval(`["Main.hx"]`, `none`, `haxe -main Main --interp`)
2248+ @LIA.inform: @LIA.eval(`["main.inf"]`, `inform -o main.inf > compile.log && [ -f "main.z5" ] || { cat compile.log >&2; exit 1; }`, `/usr/games/dfrotz main.z5`)
2249+ @LIA.io: @LIA.eval(`["main.io"]`, `none`, `io main.io`)
2250+ @LIA.io_withShell: @LIA.eval(`["main.io"]`, `none`, `io -i main.io`)
22332251@LIA.java: @LIA.eval(`["@0.java"]`, `javac @0.java`, `java @0`)
22342252@LIA.julia: @LIA.eval(`["main.jl"]`, `none`, `julia main.jl`)
22352253@LIA.julia_withShell: @LIA.eval(`["main.jl"]`, `none`, `julia -i main.jl`)
2254+ @LIA.kotlin: @LIA.eval(`["main.kt"]`, `kotlinc main.kt -include-runtime -d main.jar`, `java -jar main.jar`)
2255+ @LIA.lua: @LIA.eval(`["main.lua"]`, `none`, `lua main.lua`)
22362256@LIA.mono: @LIA.eval(`["main.cs"]`, `mcs main.cs`, `mono main.exe`)
22372257@LIA.nasm: @LIA.eval(`["main.asm"]`, `nasm -felf64 main.asm && ld main.o`, `./a.out`)
22382258@LIA.nim: @LIA.eval(`["main.nim"]`, `nim c main.nim`, `./main`)
2259+ @LIA.nodejs: @LIA.eval(`["main.js"]`, `none`, `node main.js`)
2260+ @LIA.ocaml: @LIA.eval(`["main.ml"]`, `none`, `ocaml main.ml`)
22392261@LIA.perl: @LIA.eval(`["main.pl"]`, `perl -c main.pl`, `perl main.pl`)
22402262@LIA.perl_withShell: @LIA.eval(`["main.pl"]`, `perl -c main.pl`, `perl -d main.pl`)
2263+ @LIA.php: @LIA.eval(`["main.php"]`, `none`, `php main.php`)
2264+ @LIA.postscript: @LIA.eval(`["input.ps"]`, `none`, `gs -sDEVICE=png16m -r300 -o output.png input.ps`)
2265+ @LIA.prolog: @LIA.eval(`["main.pl"]`, `none`, `swipl -s main.pl -g @0 -t halt`)
2266+ @LIA.prolog_withShell: @LIA.eval(`["main.pl"]`, `none`, `swipl -s main.pl`)
22412267@LIA.python: @LIA.python3
22422268@LIA.python_withShell: @LIA.python3_withShell
22432269@LIA.python2: @LIA.eval(`["main.py"]`, `python2.7 -m compileall .`, `python2.7 main.pyc`)
@@ -2246,11 +2272,19 @@ window.CodeRunner.init("wss://ancient-hollows-41316.herokuapp.com/")
22462272@LIA.python3_withShell: @LIA.eval(`["main.py"]`, `none`, `python3 -i main.py`)
22472273@LIA.r: @LIA.eval(`["main.R"]`, `none`, `Rscript main.R`)
22482274@LIA.r_withShell: @LIA.eval(`["main.R"]`, `none`, `sh -c "cat main.R - | R --interactive"`)
2275+ @LIA.racket: @LIA.eval(`["main.rkt"]`, `none`, `racket main.rkt`)
22492276@LIA.ruby: @LIA.eval(`["main.rb"]`, `none`, `ruby main.rb`)
22502277@LIA.ruby_withShell: @LIA.eval(`["main.rb"]`, `none`, `irb --nomultiline -r ./main.rb`)
22512278@LIA.rust: @LIA.eval(`["main.rs"]`, `rustc main.rs`, `./main`)
2279+ @LIA.scala: @LIA.eval(`["@0.scala"]`, `scalac @0.scala`, `scala @0`)
2280+ @LIA.scheme: @LIA.eval(`["main.scm"]`, `none`, `guile --no-auto-compile main.scm`)
2281+ @LIA.selectscript: @LIA.eval(`["main.s2"]`, `none`, `S2c -x main.s2`)
2282+ @LIA.smalltalk: @LIA.eval(`["main.st"]`, `none`, `gst main.st`)
2283+ @LIA.tcl: @LIA.eval(`["main.tcl"]`, `none`, `tclsh main.tcl`)
22522284@LIA.v: @LIA.eval(`["main.v"]`, `v main.v`, `./main`)
22532285@LIA.v_withShell: @LIA.eval(`["main.v"]`, `none`, `sh -c "cat main.v - | v repl"`)
2286+ @LIA.verilog: @LIA.eval(`["main.v"]`, `iverilog -o main.vvp main.v`, `vvp main.vvp`)
2287+ @LIA.vhdl: @LIA.eval(`["@0.vhdl"]`, `ghdl -a @0.vhdl && ghdl -e @0`, `ghdl -r @0`)
22542288@LIA.zig: @LIA.eval(`["main.zig"]`, `zig build-exe ./main.zig -O ReleaseSmall`, `./main`)
22552289
22562290@LIA.dotnet
@@ -2282,6 +2316,18 @@ window.CodeRunner.init("wss://ancient-hollows-41316.herokuapp.com/")
22822316@LIA .eval(` ["Program.fs", "project.fsproj"] ` , ` dotnet build -nologo ` , ` dotnet run ` )
22832317@end
22842318
2319+ @LIA .qsharp
2320+ ``` xml -project.csproj
2321+ <Project Sdk =" Microsoft.Quantum.Sdk/0.28.302812" >
2322+ <PropertyGroup >
2323+ <OutputType >Exe</OutputType >
2324+ <TargetFramework >net8.0</TargetFramework >
2325+ </PropertyGroup >
2326+ </Project >
2327+ ```
2328+ @LIA .eval(` ["Program.qs", "project.csproj"] ` , ` dotnet build -nologo ` , ` dotnet run ` )
2329+ @end
2330+
22852331@LIA .eval: @LIA .eval_ (false,` @0 ` ,@1 ,@2 ,@3 )
22862332
22872333@LIA .evalWithDebug: @LIA .eval_ (true,` @0 ` ,@1 ,@2 ,@3 )
@@ -2393,6 +2439,13 @@ CodeRunner.handle(uid, function (msg) {
23932439 }
23942440 }
23952441
2442+ if (msg .videos ) {
2443+ for (let i = 0 ; i < msg .videos .length ; i++ ) {
2444+ console .html (" <hr/>" , msg .videos [i].file )
2445+ console .html (" <video controls style='width:100%' title='" + msg .videos [i].file + " ' src='" + msg .videos [i].data + " '></video>" )
2446+ }
2447+ }
2448+
23962449 if (msg .files ) {
23972450 let str = " <hr/>"
23982451 for (let i = 0 ; i < msg .files .length ; i++ ) {
0 commit comments