From: Marius Gavrilescu Date: Thu, 16 Apr 2015 12:22:15 +0000 (+0300) Subject: Simplify divine-format and add golfscript X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=502d9da0a5843c9ecef1a6226f98ed3d5a233dbc;p=gruntmaster-page.git Simplify divine-format and add golfscript --- diff --git a/js/90-divine-format.js b/js/90-divine-format.js index 5369b74..e44bf90 100644 --- a/js/90-divine-format.js +++ b/js/90-divine-format.js @@ -1,50 +1,40 @@ +var ext_table = { + 'c' : 'C', + + 'cc' : 'CPP', + 'cpp' : 'CPP', + 'cxx' : 'CPP', + 'C' : 'CPP', + + 'go' : 'GOLANG', + + 'gs' : 'GOLFSCRIPT', + + 'hs' : 'HASKELL', + 'lhs' : 'HASKELL', + + 'lisp': 'SBCL', + 'lsp' : 'SBCL', + 'cl' : 'SBCL', + 'l' : 'SBCL', + + 'java': 'JAVA', + + 'pas' : 'PASCAL', + + 'pl' : 'PERL', + + 'py' : 'PYTHON', + + 'rb' : 'RUBY' +} + function divine_format() { var filename = $('#prog')[0].value; var ext = /\.([^.]*)$/.exec(filename)[1]; - var format; - - switch(ext) { - case 'c': - format = 'C'; - break; - case 'cc': - case 'cpp': - case 'cxx': - case 'C': - format = 'CPP'; - break; - case 'go': - format = 'GOLANG'; - break; - case 'hs': - case 'lhs': - format = 'HASKELL'; - break; - case 'lisp': - case 'lsp': - case 'cl': - case 'l': - format = 'SBCL'; - break; - case 'java': - format = 'JAVA'; - break; - case 'pas': - format = 'PASCAL'; - break; - case 'pl': - format = 'PERL'; - break; - case 'py': - format = 'PYTHON'; - break; - case 'rb': - format = 'RUBY'; - break; - } - - if(format) - $('#prog_format')[0].value = format; + + if(ext_table[ext]) + $('#prog_format')[0].value = ext_table[ext]; } $(function() {