From b2e76c280d1f5a884e8e3c578c67a098239e45c0 Mon Sep 17 00:00:00 2001 From: Hauke D Date: Tue, 9 Oct 2018 16:50:30 +0200 Subject: [PATCH] Moved setup of input files to function --- web/democode/perleditor.html | 44 ++++++++++++++++++++++++++---------- web/democode/perlrunner.html | 4 ++++ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/web/democode/perleditor.html b/web/democode/perleditor.html index 4bd48be..ae5b0bc 100644 --- a/web/democode/perleditor.html +++ b/web/democode/perleditor.html @@ -184,6 +184,36 @@ function setupOutputFile (fn, text) { cm.setValue( text ? text : '' ); } +function setupInputFile (inp) { + var fn; + if (inp["fn"]) fn = inp.fn; + else { // autogenerate a filename + for (var i=1; i<1000; i++) { + var testfn = "input"+i+".txt"; + var found = $('div.inputs>.filename') + .filter(function(){ return $(this).text() == testfn }); + if (!found.length) { + fn = testfn; + break } + } + if (!fn) { + $('#runnererrors>pre').text('Too many input files'); + $('#runnererrors').show(); + throw 'Too many input files'; + } + } + var div = $('
',{class:"codewithfn inputs"}); + div.append( $('
',{class:"filename",text:fn}) ); + var ta = $('