@@ -50,15 +50,15 @@ onload = function() {
5050 let editors = [ ] ;
5151
5252 for ( let langName of [
53- 'Bash' , 'Haskell' , 'J' , 'JavaScript' , 'Julia' , 'Lisp' ,
54- 'Lua' , ' Perl', 'Perl 6' , 'PHP' , 'Python' , 'Ruby' ,
53+ 'Bash' , 'C' , ' Haskell', 'J' , 'JavaScript' , 'Julia' , 'Lisp' , 'Lua ',
54+ 'Perl' , 'Perl 6' , 'PHP' , 'Python' , 'Ruby' ,
5555 ] ) {
5656 let lang = langName . replace ( / / , '' ) . toLowerCase ( ) ;
5757
5858 let editor = CodeMirror ( wrapper , {
5959 lineNumbers : true ,
6060 lineWrapping : true ,
61- mode : { name : lang , startOpen : true } ,
61+ mode : { name : lang === 'c' ? 'clike' : lang , startOpen : true } ,
6262 value : data . hasOwnProperty ( lang ) ? data [ lang ] : '' ,
6363 } ) ;
6464
@@ -94,18 +94,24 @@ onload = function() {
9494
9595 ( onhashchange = function ( ) {
9696 // Kick 'em to Perl 6 if we don't know the chosen language.
97- if ( ! / ^ # (?: b a s h | h a s k e l l | j | j a v a s c r i p t | j u l i a | l i s p | l u a | p e r l 6 ? | p h p | p y t h o n | r u b y ) $ / . exec ( location . hash ) )
97+ if ( ! / ^ # (?: b a s h | c | h a s k e l l | j | j a v a s c r i p t | j u l i a | l i s p | l u a | p e r l 6 ? | p h p | p y t h o n | r u b y ) $ / . exec ( location . hash ) )
9898 location . hash = 'perl6' ;
9999
100100 let lang = location . hash . slice ( 1 ) ;
101101
102102 localStorage . setItem ( hole , lang ) ;
103103
104- for ( let editor of editors )
105- if ( editor . options . mode . name === lang )
104+ for ( let editor of editors ) {
105+ let mode = editor . options . mode . name ;
106+
107+ if ( mode === 'clike' )
108+ mode = 'c' ;
109+
110+ if ( mode === lang )
106111 ( activeEditor = editor ) . display . wrapper . style . display = '' ;
107112 else
108113 editor . display . wrapper . style . display = 'none' ;
114+ }
109115
110116 for ( let info of document . querySelectorAll ( '.info' ) )
111117 info . style . display = info . classList . contains ( lang ) ? 'block' : '' ;
@@ -118,13 +124,14 @@ onload = function() {
118124 status . style . display = 'none' ;
119125 this . classList . add ( 'on' ) ;
120126
121- const res = await fetch ( '/solution' , {
127+ const mode = activeEditor . options . mode . name ;
128+ const res = await fetch ( '/solution' , {
122129 credentials : 'include' ,
123130 method : 'POST' ,
124131 body : JSON . stringify ( {
125132 Code : activeEditor . getValue ( ) ,
126133 Hole : hole ,
127- Lang : activeEditor . options . mode . name ,
134+ Lang : mode === 'clike' ? 'c' : mode ,
128135 } ) ,
129136 } ) ;
130137
0 commit comments