Try to divine file format from file extension
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 10 Jan 2015 18:12:24 +0000 (20:12 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 10 Jan 2015 18:12:24 +0000 (20:12 +0200)
MANIFEST
js/90-divine-format.js [new file with mode: 0644]

index b702b0741defcee96f5cc23c17c65111a26b6de4..14f50e6ac7d10ec664b3d0bc4ca91afdd78cf161 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -15,6 +15,7 @@ js/01-zepto-jquery.js
 js/10-bootstrap-dropdown.js
 js/10-bootstrap-modal.js
 js/90-autoresize.js
+js/90-divine-format.js
 js/90-form.js
 js/90-themes.js
 js/90-nav.js
diff --git a/js/90-divine-format.js b/js/90-divine-format.js
new file mode 100644 (file)
index 0000000..5a1a7d6
--- /dev/null
@@ -0,0 +1,47 @@
+(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);
+       });
+})();
This page took 0.01209 seconds and 4 git commands to generate.