|
|
@ -20,6 +20,7 @@ const mapStateToProps = (state) => ({
|
|
|
|
isPosting: state.ui.isPosting,
|
|
|
|
isPosting: state.ui.isPosting,
|
|
|
|
isRunning: state.pretest.isRunning,
|
|
|
|
isRunning: state.pretest.isRunning,
|
|
|
|
isWaiting: state.ui.isWaiting,
|
|
|
|
isWaiting: state.ui.isWaiting,
|
|
|
|
|
|
|
|
waitSec: state.ui.waitSec,
|
|
|
|
editorLang: state.editor.lang,
|
|
|
|
editorLang: state.editor.lang,
|
|
|
|
editorCode: state.editor.code,
|
|
|
|
editorCode: state.editor.code,
|
|
|
|
pretestInput: state.pretest.input,
|
|
|
|
pretestInput: state.pretest.input,
|
|
|
@ -66,10 +67,9 @@ const mapDispatchToProps = (dispatch) => ({
|
|
|
|
payload: request.get(UiContext.getSubmissionsUrl),
|
|
|
|
payload: request.get(UiContext.getSubmissionsUrl),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
endWaiting() {
|
|
|
|
tick() {
|
|
|
|
dispatch({
|
|
|
|
dispatch({
|
|
|
|
type: 'SCRATCHPAD_WAITING_END',
|
|
|
|
type: 'SCRATCHPAD_WAITING_TICK',
|
|
|
|
payload: 0,
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -84,7 +84,6 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
super(props);
|
|
|
|
this.state = { waitSec: -1 };
|
|
|
|
|
|
|
|
if (!availableLangs[this.props.editorLang]) {
|
|
|
|
if (!availableLangs[this.props.editorLang]) {
|
|
|
|
// preference not allowed
|
|
|
|
// preference not allowed
|
|
|
|
const key = keys.find((i) => availableLangs[i].pretest === this.props.editorLang);
|
|
|
|
const key = keys.find((i) => availableLangs[i].pretest === this.props.editorLang);
|
|
|
@ -97,18 +96,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate() {
|
|
|
|
componentDidUpdate() {
|
|
|
|
if (this.props.isWaiting) {
|
|
|
|
if (this.props.waitSec > 0) setTimeout(() => this.props.tick(), 1000);
|
|
|
|
const { waitSec } = this.state;
|
|
|
|
|
|
|
|
if (waitSec < 0) this.setState({ waitSec: 5 });
|
|
|
|
|
|
|
|
if (waitSec === 0) {
|
|
|
|
|
|
|
|
this.setState({ waitSec: waitSec - 1 });
|
|
|
|
|
|
|
|
this.props.endWaiting();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
|
|
this.setState({ waitSec: waitSec - 1 });
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
@ -131,9 +119,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
|
|
|
|
{' '}
|
|
|
|
{' '}
|
|
|
|
{i18n('Run Pretest')}
|
|
|
|
{i18n('Run Pretest')}
|
|
|
|
{' '}
|
|
|
|
{' '}
|
|
|
|
(F9)
|
|
|
|
{this.props.isWaiting ? `(${this.props.waitSec}s)` : '(F9)'}
|
|
|
|
{' '}
|
|
|
|
|
|
|
|
{this.props.isWaiting && `(${this.state.waitSec}s)`}
|
|
|
|
|
|
|
|
</ToolbarButton>
|
|
|
|
</ToolbarButton>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
<ToolbarButton
|
|
|
|
<ToolbarButton
|
|
|
@ -147,9 +133,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
|
|
|
|
{' '}
|
|
|
|
{' '}
|
|
|
|
{i18n('Submit Solution')}
|
|
|
|
{i18n('Submit Solution')}
|
|
|
|
{' '}
|
|
|
|
{' '}
|
|
|
|
(F10)
|
|
|
|
{this.props.isWaiting ? `(${this.props.waitSec}s)` : '(F10)'}
|
|
|
|
{' '}
|
|
|
|
|
|
|
|
{this.props.isWaiting && `(${this.state.waitSec}s)`}
|
|
|
|
|
|
|
|
</ToolbarButton>
|
|
|
|
</ToolbarButton>
|
|
|
|
<ToolbarButton
|
|
|
|
<ToolbarButton
|
|
|
|
data-global-hotkey="alt+q"
|
|
|
|
data-global-hotkey="alt+q"
|
|
|
|