@@ -2,11 +2,11 @@ import React from 'react';
22import ReactDOM from 'react-dom' ;
33import $ from 'jquery' ;
44
5- import ComplieButton from './components/ComplieButton .jsx' ;
5+ import CompileButton from './components/CompileButton .jsx' ;
66import Editor from './components/Editor.jsx' ;
77import BottomBox from './components/BottomBox.jsx' ;
88
9- const COMPLIER_SITE = 'https://paiza.io/api/projects.json' ;
9+ const COMPILER_SITE = 'https://paiza.io/api/projects.json' ;
1010var data = {
1111 project : {
1212 language : 'cpp' ,
@@ -35,7 +35,7 @@ class App extends React.Component
3535 } ;
3636
3737 this . onChangeEditor = this . onChangeEditor . bind ( this ) ;
38- this . onClickComplieButton = this . onClickComplieButton . bind ( this ) ;
38+ this . onClickCompileButton = this . onClickCompileButton . bind ( this ) ;
3939 this . onChangeSTDIN = this . onChangeSTDIN . bind ( this ) ;
4040 }
4141
@@ -48,24 +48,33 @@ class App extends React.Component
4848 } ) ;
4949 }
5050
51- onClickComplieButton ( e )
51+ onClickCompileButton ( e )
5252 {
5353 data . project . source_files . push ( {
5454 filename : 'Main.cpp' ,
5555 body : this . state . editor . value
5656 } ) ;
5757 data . project . input = this . state . bottomBox . stdin ;
5858
59+ this . setState ( {
60+ bottomBox : {
61+ debug : 'Compiling'
62+ }
63+ } ) ;
64+ $ ( '.tab-content > *' ) . hide ( ) ;
65+ $ ( '.content-debug' ) . show ( ) ;
66+ $ ( '.myButton' ) . attr ( 'disabled' , 'disabled' ) ;
67+
5968 $ . ajax ( {
60- url : COMPLIER_SITE ,
69+ url : COMPILER_SITE ,
6170 headers : {
6271 'Content-Type' : 'application/json' ,
6372 } ,
6473 method : 'POST' ,
6574 data : JSON . stringify ( data ) ,
6675 success : function ( rs ) {
6776 // console.log(this.state.editor.value);
68- if ( rs . build_exit_code !== 0 )
77+ if ( rs . build_exit_code !== 0 || rs . build_stderr !== "" )
6978 {
7079 var build_errors = rs . build_stderr . split ( '\n' ) ;
7180 if ( build_errors . length < 3 )
@@ -92,20 +101,26 @@ class App extends React.Component
92101 build_errors [ i + 1 ] ,
93102 build_errors [ i + 2 ]
94103 ] ;
95- annotations . push ( {
104+ /* annotations.push({
96105 row: parseInt(err_split[1]),
97106 column: parseInt(err_split[2]),
98107 type: 'error',
99108 text: text.join('\n'),
109+ });*/
110+ this . setState ( {
111+ editor : {
112+ value : this . state . editor . value ,
113+ annotations : [
114+ {
115+ row : parseInt ( err_split [ 1 ] ) ,
116+ column : parseInt ( err_split [ 2 ] ) ,
117+ type : 'error' ,
118+ text : text . join ( '\n' ) ,
119+ }
120+ ]
121+ }
100122 } ) ;
101123 }
102- /*this.setState({
103- editor: {
104- value: this.state.editor.value,
105- annotations: annotations
106- }
107- });*/
108- console . log ( this . state . editor . annotations ) ;
109124 }
110125 this . setState ( {
111126 bottomBox : {
@@ -117,14 +132,13 @@ class App extends React.Component
117132 {
118133 this . setState ( {
119134 bottomBox : {
120- debug : rs . stdout
135+ debug : [ /* rs.stderr, */ rs . stdout ] . join ( '\n' )
121136 }
122137 } ) ;
123138 }
124139 } . bind ( this ) ,
125140 complete : function ( rs ) {
126- $ ( '.tab-content > *' ) . hide ( ) ;
127- $ ( '.content-debug' ) . show ( ) ;
141+ $ ( '.myButton' ) . removeAttr ( 'disabled' ) ;
128142 }
129143 } ) ;
130144
@@ -153,9 +167,9 @@ class App extends React.Component
153167 stdin = { this . state . bottomBox . stdin }
154168 onChangeSTDIN = { this . onChangeSTDIN }
155169 />
156- < ComplieButton
170+ < CompileButton
157171 editorValue = { this . state . editor . value }
158- onClick = { this . onClickComplieButton }
172+ onClick = { this . onClickCompileButton }
159173 />
160174 </ div >
161175 ) ;
0 commit comments