Skip to content

Commit fa6016a

Browse files
Added a feature to copy input directly by clicking on example number
1 parent acc7f33 commit fa6016a

File tree

7 files changed

+61
-20
lines changed

7 files changed

+61
-20
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ oj l https://codeforces.com/
3939

4040
## Guide
4141
- Set your preferences in settings of the package, in advance
42+
- Click on Refresh button to refresh the standing
4243
- Click on your standing to minimize problems view
4344
- Click on your profile picture to refresh problems
45+
- Click on an example number to copy its input data
4446

4547
## Limitations
4648
- Currently, test and run code option is only available for python users
49+
- I will try to remove the dependency of online-judge-tools for non-python users in future updates
4750

4851
<br>
4952

lib/view/actions.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
'use babel';
22

33
import React from 'react';
4+
import copy from "copy-to-clipboard";
45

56
export default class Actions extends React.PureComponent {
67
constructor(props){
78
super(props);
89
this.state = {
910
prob: props.prob,
11+
inputs: props.inputs,
1012
outputs: props.outputs,
1113
tests: props.tests,
1214
runexamples: props.runexamples,
@@ -17,6 +19,7 @@ export default class Actions extends React.PureComponent {
1719
componentWillReceiveProps(nextProps) {
1820
this.setState({
1921
prob: nextProps.prob,
22+
inputs: nextProps.inputs,
2023
outputs: nextProps.outputs,
2124
tests: nextProps.tests,
2225
runexamples: nextProps.runexamples,
@@ -71,6 +74,16 @@ export default class Actions extends React.PureComponent {
7174
}
7275
}
7376

77+
copyinput(ele){
78+
var i = ele.target.innerText.split(" ")[1];
79+
copy(this.state.inputs[i-1])
80+
ele.target.classList.add("copied")
81+
const exm = ele.target
82+
setTimeout(()=>{
83+
exm.classList.remove("copied")
84+
},300)
85+
}
86+
7487
render(){
7588
return (
7689
<div className="actions">
@@ -101,7 +114,7 @@ export default class Actions extends React.PureComponent {
101114
else moredetails = null
102115
}
103116
return(<div className="verdict" key={Math.floor(Math.random()*1000000)}>
104-
<div className="show-verdict" onClick={this.toggleverdict}><span>example {test.n+1}</span> <i className={"icon-"+test.icon}></i></div>
117+
<div className="show-verdict" onClick={this.toggleverdict}><span onClick={this.copyinput.bind(this)}>example {test.n+1}</span> <i className={"icon-"+test.icon}></i></div>
105118
{moredetails}
106119
</div>)
107120
})}

lib/view/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export default class Root extends React.PureComponent {
3030

3131
// this.state = {
3232
// desc: "codeforces div 2",
33-
// id: 1388,
33+
// id: 1401,
3434
// finished: 0,
3535
// changed: 2,
3636
// createnv: false,
37-
// timeremaining: 84600,
37+
// timeremaining: 0,
3838
// profimg: "//templates.joomla-monster.com/joomla30/jm-news-portal/components/com_djclassifieds/assets/images/default_profile.png"
3939
// };
4040
}

lib/view/problems.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -311,20 +311,15 @@ export default class Problems extends React.PureComponent {
311311
var i = 0
312312
for (var prob of this.state.probs) {
313313
probs.push(prob)
314-
if(prob.verdict=="OK") continue
315-
314+
probs[i].verdict = "NONE"
316315
for (var action of this.state.actions) {
317316
if(action.index==prob.index){
318-
if(action.verdict=="OK"){
319-
probs[i].verdict = "OK"
320-
probs[i].testset = action.testset
321-
probs[i].errtest = action.errtest
322-
break
323-
}else if(prob.verdict=="NONE"){
324-
probs[i].verdict = action.verdict
325-
probs[i].testset = action.testset
326-
probs[i].errtest = action.errtest
317+
if(action.verdict!="OK" && probs[i].verdict!="NONE" ){
318+
continue
327319
}
320+
probs[i].verdict = action.verdict
321+
probs[i].testset = action.testset
322+
probs[i].errtest = action.errtest
328323
}
329324
}
330325
i++;
@@ -470,6 +465,7 @@ export default class Problems extends React.PureComponent {
470465
</div>
471466
{this.state.probs.length ? <Actions
472467
prob={this.state.probs[this.state.curr]}
468+
inputs={this.state.allinputs[this.state.probs[this.state.curr].index]}
473469
outputs={this.state.alloutputs[this.state.probs[this.state.curr].index]}
474470
tests={this.state.allverdicts[this.state.probs[this.state.curr].index]}
475471
runexamples ={this.runexamples.bind(this)}

package-lock.json

Lines changed: 13 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"axios": "^0.19.2",
1717
"cheerio": "^1.0.0-rc.3",
1818
"child_process": "^1.0.2",
19+
"copy-to-clipboard": "^3.3.1",
1920
"fs": "0.0.1-security",
2021
"path": "^0.12.7",
2122
"pretty-error": "^2.1.1",

styles/codeblue.less

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,5 +605,25 @@
605605
height: 30px !important;
606606
font-size: 1em !important;
607607
margin: 0;
608-
transform: translate(120px,-30px);
608+
transform: translate(120px,-42px);
609+
}
610+
611+
.copied {
612+
animation: pop 0.3s linear;
613+
transition: 0.3s;
614+
615+
}
616+
617+
@keyframes pop {
618+
0% {
619+
transform: scale(1) translateZ(0);
620+
}
621+
622+
50% {
623+
transform: scale(1.1) translateZ(0);
624+
}
625+
626+
100% {
627+
transform: scale(1) translateZ(0);
628+
}
609629
}

0 commit comments

Comments
 (0)