Skip to content
This repository was archived by the owner on Dec 24, 2018. It is now read-only.

Commit e4ca99c

Browse files
committed
Result fix
1 parent 0e89f81 commit e4ca99c

File tree

4 files changed

+43
-23
lines changed

4 files changed

+43
-23
lines changed

src/css/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ body {
4848

4949
.content-debug {
5050
padding: 0 5px;
51+
overflow-x: auto;
5152
}
5253
.myButton {
5354
-moz-box-shadow:inset 0px 1px 0px 0px #54a3f7;
@@ -90,3 +91,8 @@ body {
9091
position:relative;
9192
top:1px;
9293
}
94+
.myButton:disabled {
95+
background: #eee;
96+
box-shadow: none;
97+
border: #ccc 1px solid;
98+
}

src/js/components/BottomBox.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class BottomBox extends React.Component
3939
<div className="bottom-box">
4040
<ul className="tab-nav">
4141
<li><a name="tab-stdin" onClick={this.onClickTabNav}>STDIN</a></li>
42-
<li><a name="tab-debug" onClick={this.onClickTabNav}>Debug</a></li>
42+
<li><a name="tab-debug" onClick={this.onClickTabNav}>Result</a></li>
4343
</ul>
4444
<div className="tab-content">
4545
<div className="content-stdin" style={{display: 'block'}}>

src/js/components/ComplieButton.jsx renamed to src/js/components/CompileButton.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Editor from './Editor.jsx';
33
import $ from 'jquery'
44

55

6-
class ComplieButton extends React.Component
6+
class CompileButton extends React.Component
77
{
88
constructor(props)
99
{
@@ -24,10 +24,10 @@ class ComplieButton extends React.Component
2424
className="myButton"
2525
onClick={this.onClick}
2626
>
27-
Complie
27+
Compile
2828
</button>
2929
);
3030
}
3131
}
3232

33-
export default ComplieButton;
33+
export default CompileButton;

src/js/main.jsx

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import React from 'react';
22
import ReactDOM from 'react-dom';
33
import $ from 'jquery';
44

5-
import ComplieButton from './components/ComplieButton.jsx';
5+
import CompileButton from './components/CompileButton.jsx';
66
import Editor from './components/Editor.jsx';
77
import 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';
1010
var 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

Comments
 (0)