X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=js%2F90-divine-format.js;h=a842de1353c790ea649ba05cdfff7ce53f67a178;hb=dee46c5bb42f8fdaa70e70d6bdd4da5072a99ecd;hp=5a1a7d69c6440efea73f9b0d37114dd53c228e1a;hpb=cb84f1235ad2e9b8ff24aee8dd1b71b0192b4e0b;p=plack-app-gruntmaster.git diff --git a/js/90-divine-format.js b/js/90-divine-format.js index 5a1a7d6..a842de1 100644 --- a/js/90-divine-format.js +++ b/js/90-divine-format.js @@ -1,47 +1,40 @@ -(function(){ - 'use strict'; - - function divine_format() { - var filename = $('#prog').val(); - 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 'java': - format = 'JAVA'; - break; - case 'pas': - format = 'PASCAL'; - break; - case 'pl': - format = 'PERL'; - break; - case 'py': - format = 'PYTHON'; - break; - } - - if(format) - $('#prog_format').val(format); - } - - $( document ).ready(function() { - $('#prog').on('change', divine_format); - }); -})(); +const 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() { + const filename = q('#prog').value; + const ext = /\.([^.]*)$/.exec(filename)[1]; + + if(ext_table[ext]) + q('#prog_format').value = ext_table[ext]; +} + +$(() => $('#prog').on('change', divine_format));