├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── img ├── code.gif ├── codeblue.gif ├── error.png ├── face.png ├── game.png ├── mle.png ├── run.png ├── tle.png └── work.png ├── keymaps └── codeblue.json ├── lib ├── codeblue-view.js ├── codeblue.js ├── config.js └── view │ ├── actions.js │ ├── index.js │ ├── judge.js │ ├── play.js │ ├── problem.js │ ├── problems.js │ ├── quotes.json │ ├── recentsubmissions.js │ ├── setup.js │ ├── standings.js │ └── tiktac.js ├── menus └── codeblue.json ├── package-lock.json ├── package.json ├── spec ├── codeblue-spec.js └── codeblue-view-spec.js └── styles └── codeblue.less /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | main.py 5 | backup.js 6 | todo.txt 7 | rough.js 8 | rough1.js 9 | rough2.js 10 | rough3.js 11 | codeforces-scraper.js 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # codeblue package for Atom text editor 2 | 3 | [![APM version](https://img.shields.io/apm/v/codeblue?style=flat-square)](https://atom.io/packages/codeblue) 4 | [![APM downloads](https://img.shields.io/apm/dm/codeblue?style=flat-square)](https://atom.io/packages/codeblue) 5 | [![APM Licence](https://img.shields.io/badge/licence-MIT-orange?style=flat-square)](https://opensource.org/licences/MIT) 6 | [![Follow me](https://img.shields.io/github/followers/blueedgetechno?label=follow%20me&style=social)](https://github.com/blueedgetechno) 7 | 8 | [![forthebadge made-by-hipster](https://forthebadge.com/images/badges/built-by-hipsters.svg)](https://www.javascript.com/) 9 | [![ForTheBadge built-with-love](http://ForTheBadge.com/images/badges/built-with-love.svg)](https://github.com/blueedgetechno) 10 | 11 | ## An Atom package for all your competitive coding needs 12 | 13 | A codeforces helper that can test, run, present and submit solutions on codeforces 14 |
15 | 16 | ![overview](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/codeblue.gif) 17 | 18 | ### Installation 19 | Step 1. 20 | ``` 21 | apm install codeblue 22 | ``` 23 | Step 2. 24 | ``` 25 | pip install online-judge-tools 26 | ``` 27 | Step 3. 28 | ``` 29 | oj l https://codeforces.com/ 30 | ``` 31 | 32 | ## Features 33 | 34 | - Fetch and load details of a live codeforces contest ⚡ 35 | - Automatically create an environment for contest including working files 💻 36 | - Run code with official sample cases of any particular problem 🔭 37 | - Compare your output with expected output in a elegant manner 📺 38 | - Get your code verdicts like OK ✅, Wrong answer ❌, TLE 🕒, MLE 🛢, Runtime error or Compilation error ⚠, Queue ⏳, Hacked ☠️ 39 | - Submit 🏳‍🌈 your code from your favorite text editor 40 | - Get your official standing of the live contest 👥 41 | - Play minigames while you wait for the contest 🎮 42 | 43 | ## Updates 44 | - Option to detect and login from the plugin itself 45 | - Now you can change working directory by right clicking in the tree view 46 | 47 | ## Guide 48 | - Set your preferences in settings of the package, in advance 49 | - Delete the folders and files of working directory before contest and check the create environment 50 | - Click on Refresh button to refresh the standings 51 | - Click on the yellow user icon to minimize/maximize friends standing view 52 | - Click on your profile picture to refresh problems 53 | - Click on an example number to copy its input data 54 | 55 | ## Limitations 56 | - I will try to remove the dependency of online-judge-tools for non-python users in future updates 57 | 58 | - While running C or C++ files, it sometimes run the previously compiled file and shows the same verdict. Incase of that delete the previously compiled file and run the code again 59 | 60 | - Not tested for linux or macOs 61 | 62 | ##### Any feedback will be highly appreciable 63 | 64 |
65 | 66 | ![overview](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/face.png) 67 | 68 | 69 | ![work](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/work.png) 70 |
71 | 72 | # Play while you wait 73 | 74 | ![game](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/game.png) 75 |
76 | 77 | # Detailed and concise error presentation 78 | 79 | ![error](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/error.png) 80 |
81 | 82 | # Wrong answer ? 83 | 84 | ![Wrong answer](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/run.png) 85 |
86 | 87 | # * Ain't Nobody Got Time For That * 88 | ![TLE](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/tle.png) 89 |
90 | 91 | # MLE - Its a thing too 92 | ![TLE](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/mle.png) 93 | -------------------------------------------------------------------------------- /img/code.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueedgetechno/codeblue/3e90c97ebac5e2a73575aeb8b1e6fa2ac005ae17/img/code.gif -------------------------------------------------------------------------------- /img/codeblue.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueedgetechno/codeblue/3e90c97ebac5e2a73575aeb8b1e6fa2ac005ae17/img/codeblue.gif -------------------------------------------------------------------------------- /img/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueedgetechno/codeblue/3e90c97ebac5e2a73575aeb8b1e6fa2ac005ae17/img/error.png -------------------------------------------------------------------------------- /img/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueedgetechno/codeblue/3e90c97ebac5e2a73575aeb8b1e6fa2ac005ae17/img/face.png -------------------------------------------------------------------------------- /img/game.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueedgetechno/codeblue/3e90c97ebac5e2a73575aeb8b1e6fa2ac005ae17/img/game.png -------------------------------------------------------------------------------- /img/mle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueedgetechno/codeblue/3e90c97ebac5e2a73575aeb8b1e6fa2ac005ae17/img/mle.png -------------------------------------------------------------------------------- /img/run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueedgetechno/codeblue/3e90c97ebac5e2a73575aeb8b1e6fa2ac005ae17/img/run.png -------------------------------------------------------------------------------- /img/tle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueedgetechno/codeblue/3e90c97ebac5e2a73575aeb8b1e6fa2ac005ae17/img/tle.png -------------------------------------------------------------------------------- /img/work.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueedgetechno/codeblue/3e90c97ebac5e2a73575aeb8b1e6fa2ac005ae17/img/work.png -------------------------------------------------------------------------------- /keymaps/codeblue.json: -------------------------------------------------------------------------------- 1 | { 2 | "atom-workspace": { 3 | "ctrl-alt-k": "codeblue:toggle" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/codeblue-view.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import React from 'react'; 4 | import ReactDOM from 'react-dom'; 5 | import Root from './view/index' 6 | 7 | export default class CodeblueView { 8 | 9 | constructor(serializedState) { 10 | // Create root element 11 | this.element = document.createElement('div'); 12 | 13 | this.element.classList.add('codeblue'); 14 | 15 | ReactDOM.render(
, this.element); 16 | } 17 | 18 | serialize() {} 19 | 20 | destroy() { 21 | this.element.remove(); 22 | } 23 | 24 | getElement() { 25 | return this.element; 26 | } 27 | 28 | getTitle() { 29 | return 'CodeForces'; 30 | } 31 | 32 | getURI() { 33 | return 'atom://codeblue'; 34 | } 35 | 36 | getDefaultLocation() { 37 | return 'right'; 38 | } 39 | 40 | getAllowedLocations() { 41 | return ['left', 'right']; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /lib/codeblue.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import CodeblueView from './codeblue-view'; 4 | import { 5 | CompositeDisposable, 6 | Disposable 7 | } from 'atom'; 8 | import config from './config' 9 | 10 | export default { 11 | 12 | subscriptions: null, 13 | config, 14 | treeView: null, 15 | 16 | activate(state) { 17 | this.subscriptions = null 18 | this.addSubscriptions() 19 | }, 20 | 21 | addSubscriptions(){ 22 | this.subscriptions = new CompositeDisposable( 23 | atom.workspace.addOpener(uri => { 24 | if (uri === 'atom://codeblue') 25 | return new CodeblueView(); 26 | }), 27 | 28 | atom.commands.add('atom-workspace', { 29 | 'codeblue:toggle': () => this.toggle(), 30 | 'codeblue:set-working-directory': () => this.setWorkingDirectory() 31 | }), 32 | 33 | new Disposable(() => { 34 | atom.workspace.getPaneItems().forEach(item => { 35 | if (item instanceof CodeblueView) { 36 | item.destroy(); 37 | } 38 | }) 39 | }) 40 | ); 41 | }, 42 | 43 | deactivate() { 44 | this.subscriptions.dispose(); 45 | }, 46 | 47 | consumeTreeView(treeView) { 48 | this.treeView = treeView; 49 | }, 50 | 51 | toggle() { 52 | atom.workspace.toggle('atom://codeblue'); 53 | }, 54 | 55 | setWorkingDirectory(){ 56 | if (!this.treeView) return; 57 | const paths = this.treeView.selectedPaths(); 58 | if (!paths || paths.length !== 1) return; 59 | var path = paths[0]; 60 | if (!path) return; 61 | 62 | console.log("setting ",path," as working directory"); 63 | atom.config.set("codeblue.workingDirectory", path); 64 | } 65 | }; 66 | -------------------------------------------------------------------------------- /lib/config.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | export default { 4 | codeforcesHandle: { 5 | title: 'Codeforces Handle (required)', 6 | order: 1, 7 | type: 'string', 8 | default: 'blue_edge' 9 | }, 10 | 11 | codeforcesPassword: { 12 | title: 'Account password (optional)', 13 | order: 2, 14 | description: 'If you wish to login from the plugin itself', 15 | type: 'string', 16 | default: 'thisIsAstringPassword' 17 | }, 18 | 19 | programmingLanguage: { 20 | title: 'Programming Language', 21 | order: 3, 22 | description: 'The chosen language will only be used for submitting a source file.', 23 | type: 'integer', 24 | default: 31, 25 | enum: [{ 26 | value: 43, 27 | description: 'GNU GCC C11 5.1.0' 28 | }, 29 | { 30 | value: 54, 31 | description: 'GNU G++17 7.3.0' 32 | }, 33 | { 34 | value: 31, 35 | description: 'Python 3.7.2' 36 | }, 37 | { 38 | value: 41, 39 | description: 'PyPy 3.6 (7.2.0)' 40 | } 41 | ] 42 | }, 43 | 44 | refreshinterval: { 45 | title: 'Autorefresh interval', 46 | order: 4, 47 | description: 'Refresh interval of standings and submission', 48 | type: 'integer', 49 | default: 5 50 | }, 51 | 52 | workingDirectory: { 53 | title: 'Working directory', 54 | order: 5, 55 | description: 'Where your source files will be stored during contest', 56 | type: 'string', 57 | default: '/' 58 | }, 59 | 60 | beautifyboolean: { 61 | title: 'Beautify log error', 62 | order: 6, 63 | description: 'Enable to display nice and concise log error', 64 | type: 'boolean', 65 | default: true 66 | }, 67 | 68 | friends: { 69 | title: 'Codeforces friends for live standings', 70 | order: 7, 71 | description: 'Add their codeforces id', 72 | type: 'array', 73 | default: ['blue_edge','eugalt','manish.17','anishde85','kim123','sujal123'], 74 | items:{ 75 | type: "string" 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/view/actions.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import React from 'react'; 4 | import copy from "copy-to-clipboard"; 5 | 6 | export default class Actions extends React.PureComponent { 7 | constructor(props){ 8 | super(props); 9 | this.state = { 10 | prob: props.prob, 11 | inputs: props.inputs, 12 | outputs: props.outputs, 13 | tests: props.tests, 14 | runexamples: props.runexamples, 15 | submitsolution: props.submitsolution, 16 | changeignorevalue: props.changeignorevalue 17 | } 18 | } 19 | 20 | componentWillReceiveProps(nextProps) { 21 | this.setState({ 22 | prob: nextProps.prob, 23 | inputs: nextProps.inputs, 24 | outputs: nextProps.outputs, 25 | tests: nextProps.tests, 26 | runexamples: nextProps.runexamples, 27 | submitsolution: nextProps.submitsolution, 28 | changeignorevalue: nextProps.changeignorevalue 29 | }); 30 | } 31 | 32 | change(){ 33 | var ele = this.refs.chevronbutton 34 | ele.classList.toggle("icon-chevron-right") 35 | ele.classList.toggle("icon-chevron-down") 36 | var val = this.refs.down.style.display 37 | if(val=="flex"){ 38 | this.refs.down.style.display = "none"; 39 | }else{ 40 | this.refs.down.style.display = "flex"; 41 | } 42 | } 43 | 44 | togglesubmit(ele){ 45 | if(ele.target.classList.length>1){ 46 | if(ele.target.classList[1]=="realsubmit"){ 47 | this.state.submitsolution() 48 | } 49 | } 50 | var parent = ele.target.parentElement 51 | if(parent==null) return 52 | for (var i = 1; i < parent.children.length; i++) { 53 | var child = parent.children[i] 54 | var val = child.style.display 55 | if(val=="block"){ 56 | child.style.display = "none"; 57 | }else{ 58 | child.style.display = "block"; 59 | } 60 | } 61 | } 62 | 63 | toggleverdict(ele){ 64 | var sb = ele.target.nextElementSibling 65 | if(sb==null) return 66 | if(sb.classList[0]!="comparision" && sb.classList[0]!="errordetails") return 67 | var val = sb.style.display 68 | if(val!="none"){ 69 | sb.style.display = "none" 70 | }else{ 71 | if(sb.classList[0]=="comparision"){ 72 | sb.style.display = "flex" 73 | }else{ 74 | sb.style.display = "block" 75 | } 76 | } 77 | } 78 | 79 | copyinput(ele){ 80 | var i = ele.target.innerText.split(" ")[1]; 81 | copy(this.state.inputs[i-1]+"\n") 82 | ele.target.classList.add("copied") 83 | const exm = ele.target 84 | setTimeout(()=>{ 85 | exm.classList.remove("copied") 86 | },300) 87 | } 88 | 89 | render(){ 90 | return ( 91 |
92 |

{this.state.prob.index} - {this.state.prob.name}

93 |
94 |
95 | 96 | Ignore case 97 |
98 |
99 |
100 |
101 |
102 | Examples 103 | 112 |
113 |
114 | {this.state.tests && this.state.tests.map(test=>{ 115 | if(test.error){ 116 | if(test.stdout.length>0 && test.stderr.length>0) moredetails =
{test.stdout}
{test.stderr}
117 | else if(test.stdout.length>0 || test.stderr.length>0) moredetails =
{test.stdout}{test.stderr}
118 | else moredetails = null 119 | }else{ 120 | if(test.icon=="x") moredetails = ( 121 |
122 |
123 |
expected
{this.state.outputs[test.n]}
124 |
125 |
126 |
output
{test.stdout}
127 |
128 |
129 | ) 130 | else moredetails = null 131 | } 132 | return(
133 |
example {test.n+1}
134 | {moredetails} 135 |
) 136 | })} 137 |
138 |
139 |
140 |
141 | Submissions 142 | {this.props.isLoggedIn==0?:null} 143 | 144 | 145 | 146 |
147 |
148 |
149 |
150 | ) 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /lib/view/index.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import React from 'react'; 4 | import Problems from './problems'; 5 | import config from '../config' 6 | import cheerio from 'cheerio' 7 | import Play from './play' 8 | import TikTac from './tiktac' 9 | 10 | import { exec } from 'child_process' 11 | 12 | function couple(x) { 13 | if(x<10){ 14 | return "0"+x 15 | }else{ 16 | return x; 17 | } 18 | } 19 | 20 | export default class Root extends React.PureComponent { 21 | constructor(props){ 22 | super(props); 23 | this.state = { 24 | desc: "", 25 | id: "", 26 | finished: 0, 27 | changed: 0, 28 | createnv: false, 29 | openinbrowser: false, 30 | timeremaining: 0, 31 | currentgame: 0, 32 | isLoggedIn: 2, 33 | profimg: "//imgbin.com/png/LGzVdNb1/computer-icons-avatar-user-login-png" 34 | }; 35 | 36 | // this.state = { 37 | // desc: "codeforces div 2", 38 | // id: 1451, 39 | // finished: 0, 40 | // changed: 2, 41 | // createnv: false, 42 | // openinbrowser: false, 43 | // currentgame: 0, 44 | // timeremaining: 0, 45 | // isLoggedIn: 2, 46 | // profimg: "//templates.joomla-monster.com/joomla30/jm-news-portal/components/com_djclassifieds/assets/images/default_profile.png" 47 | // }; 48 | } 49 | 50 | timesolver(s){ 51 | var t = 0 52 | s = s.split(":") 53 | t+=3600*parseInt(s[0]) 54 | t+=60*parseInt(s[1]) 55 | t+=parseInt(s[2]) 56 | return t 57 | } 58 | 59 | setcontest(contests){ 60 | for (var contest of contests) { 61 | if(contest.id==this.state.id){ 62 | this.setState({desc: contest.name}) 63 | if(contest.phase=="BEFORE"){ 64 | this.setState({timeremaining: -1*contest.relativeTimeSeconds}) 65 | }else{ 66 | if(contest.phase!="CODING"){ 67 | this.setState({timeremaining: 1, finished: 1}) 68 | }else{ 69 | this.setState({timeremaining: 1}) 70 | } 71 | } 72 | break; 73 | } 74 | } 75 | } 76 | 77 | fetchtimeremaining(){ 78 | var url = "https://codeforces.com/api/contest.list" 79 | fetch(url) 80 | .then(res=>res.json()) 81 | .then(res=> this.setcontest(res.result)) 82 | .catch(err=>console.log(err)) 83 | 84 | // this.setState({currentgame: this.state.currentgame^1}) 85 | } 86 | 87 | togglegame(i){ 88 | this.setState({currentgame: i}) 89 | } 90 | 91 | display(){ 92 | this.setState({changed: 1}) 93 | this.fetchtimeremaining() 94 | var repeat = setInterval(()=>{ 95 | this.setState({timeremaining: this.state.timeremaining-1}) 96 | if(this.state.timeremaining==0){ 97 | this.setState({changed: 2}) 98 | clearInterval(repeat) 99 | } 100 | 101 | this.setState({timeremaining: Math.max(this.state.timeremaining, 0)}) 102 | },1000) 103 | } 104 | 105 | Timer({sec}){ 106 | return( 107 |
108 | Before contest 109 | 110 | {couple(Math.floor(sec/3600))} :{' '} 111 | {couple(Math.floor((sec%3600)/60))} :{' '} 112 | {couple(Math.floor((sec%3600)%60))} 113 |
114 | ) 115 | } 116 | 117 | fetchinput(event){ 118 | if(event.target){ 119 | this.setState({id: event.target.value}); 120 | } 121 | } 122 | 123 | backspace(){ 124 | var s = this.state.id 125 | if(s.length){ 126 | this.setState({id: s.slice(0,-1)}) 127 | } 128 | } 129 | 130 | fetchenvalue(ele){ 131 | if(ele.target){ 132 | if(ele.target.id=="check"){ 133 | this.setState({createnv: ele.target.checked}); 134 | } 135 | if(ele.target.id=="open"){ 136 | this.setState({openinbrowser: ele.target.checked}); 137 | } 138 | } 139 | } 140 | 141 | fetchprofileimage(){ 142 | var url = "https://codeforces.com/api/user.info?handles="+atom.config.get("codeblue.codeforcesHandle") 143 | fetch(url) 144 | .then(res=> res.json()) 145 | .then(res=> this.setState({profimg: res.result[0].titlePhoto})) 146 | .catch(err => console.log(err)) 147 | } 148 | 149 | LoginCodeforces(){ 150 | console.log("Login Initiated"); 151 | var handle = atom.config.get("codeblue.codeforcesHandle"), 152 | password = atom.config.get("codeblue.codeforcesPassword") 153 | 154 | if(handle==null || password==null) return 155 | 156 | var cmd = "oj login https://codeforces.com -u "+handle+" -p "+password; 157 | exec(cmd,(error, stdout, stderr)=>{ 158 | this.setState({isLoggedIn: (error == null)}) 159 | if(error!=null){ 160 | atom.notifications.addWarning("Login Failed, check you password in settings > packages > codeblue") 161 | } 162 | }) 163 | } 164 | 165 | checkLogin(){ 166 | var cmd = "oj login --check https://codeforces.com"; 167 | exec(cmd,{ 168 | timeout: 2500, 169 | maxBuffer: 1024*32 170 | },(error, stdout, stderr)=>{ 171 | this.setState({isLoggedIn: (error == null), loginSuccess: (error==null)}) 172 | if(error!=null){ 173 | // console.log(error.code); 174 | // atom.notifications.addWarning("Login Check failed, check installation of online-judge-tools or your internet connection") 175 | } 176 | }) 177 | } 178 | 179 | componentWillMount(){ 180 | this.fetchprofileimage() 181 | this.checkLogin() 182 | } 183 | 184 | render() { 185 | var handle = atom.config.get("codeblue.codeforcesHandle") 186 | 187 | return ( 188 |
189 |
190 |
191 |
192 | 193 |
194 | {handle} 195 |
196 |
197 | {this.state.isLoggedIn==1 && this.state.changed!=2? 198 | Logged In:null} 199 | {this.state.isLoggedIn==0 && this.state.changed!=2? 200 | :null} 201 | 202 |
203 |
204 | 205 | {this.state.changed ?

{this.state.desc}

: null} 206 | 207 | {this.state.changed==0 ? ( 208 |
209 |
210 | ContestId 211 | 212 | 213 |
214 |
215 |
216 | 217 | Create environment 218 |
219 |
220 | 221 | Open problemset 222 |
223 |
224 | 225 |
226 |

Tips

227 |
    228 |
  • Set your working directory in the package settings to avoid 229 | any rushing.
  • 230 |
  • Make sure to download online-judge-tools if you wish to submit 231 | from plugin.
  • 232 |
  • Set your password in the package settings if you wish to login 233 | from the plugin itself.
  • 234 |
  • You can click on the yellow user icon to expand the standing 235 | view of you and your friends, again set their userIds in the 236 | package settings.
  • 237 |
  • You can also setup your working directory the middle of the 238 | contest by clicking on your profile picture.
  • 239 |
240 |
241 |
242 | ) : null} 243 | 244 | {this.state.changed==1 ? ( 245 |
246 | 247 | 248 | {this.state.timeremaining>4?( 249 |
250 | {this.togglegame(0)}}>Slide 251 | {this.togglegame(1)}}>TikTac 252 |
253 | ):null} 254 | 255 | {this.state.timeremaining>4 && this.state.currentgame==0 ?:null} 256 | {this.state.timeremaining>4 && this.state.currentgame==1 ?:null} 257 |
258 | ):null} 259 | 260 | {this.state.changed==2 ? ( 261 | 262 | ):null} 263 | 264 |
265 | ); 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /lib/view/judge.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | class Judge { 4 | constructor() { 5 | this.ignorewhitespace = true; 6 | } 7 | 8 | clearstring(s) { 9 | s = s.trim() 10 | s = s.split("\n") 11 | for (var i = 0; i < s.length; i++) { 12 | s[i] = s[i].trim() 13 | } 14 | return s.join("\n") 15 | } 16 | 17 | verify(exp, out, ig) { 18 | exp = this.clearstring(exp) 19 | out = this.clearstring(out) 20 | if (ig) { 21 | exp = exp.toUpperCase() 22 | out = out.toUpperCase() 23 | } 24 | return exp == out 25 | } 26 | 27 | beautify(err) { 28 | try { 29 | var dupli = err; 30 | err = err.trim() 31 | err = err.split("\n") 32 | var tmp = [] 33 | for (var i = 1; i < err.length; i++) { 34 | if (err[i].length) { 35 | if (err[i].includes("File")) { 36 | err[i] = err[i].split(",")[1] 37 | } 38 | tmp.push(err[i].trim()) 39 | } 40 | } 41 | 42 | var sol = [] 43 | for (var i = 0; i < tmp.length; i++) { 44 | if (i & 1 ^ 1) { 45 | sol.push(tmp[i]) 46 | } else { 47 | sol[sol.length - 1] += " : " + tmp[i] 48 | } 49 | } 50 | 51 | var toreturn = [] 52 | 53 | for (var i = sol.length - 1; i >= 0; i--) { 54 | toreturn.push(sol[i]) 55 | } 56 | 57 | return toreturn.join("\n"); 58 | } catch (e) { 59 | return dupli; 60 | } 61 | } 62 | 63 | beautifycpp(err, fname) { 64 | try { 65 | var dupli = err; 66 | const path = require('path'); 67 | err = err.trim() 68 | err = err.split("\n") 69 | var tmp = [] 70 | for (var i = 1; i < err.length; i++) { 71 | if (err[i].length && err[i].includes("In function") == false) { 72 | err[i] = err[i].trim() 73 | var idx = err[i].indexOf(fname) 74 | if (idx == 0) { 75 | err[i] = err[i].replace(fname, path.basename(fname)) 76 | var errarray = err[i].split(":") 77 | if (errarray[2].trim() != "note") { 78 | errarray[1] = "Line " + errarray[1] 79 | tmp.push(errarray.slice(1, ).join(":").trim()) 80 | } 81 | } 82 | } 83 | } 84 | return tmp.join("\n") 85 | }catch (e) { 86 | return dupli; 87 | } 88 | } 89 | } 90 | 91 | export default new Judge(); 92 | -------------------------------------------------------------------------------- /lib/view/play.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import React from 'react'; 4 | 5 | export default class Play extends React.PureComponent { 6 | constructor(props) { 7 | super(props); 8 | this.state = { 9 | a: [ 10 | [1, 2, 3], 11 | [4, 5, 6], 12 | [7, 8, 9] 13 | ], 14 | done: false, 15 | image: "", 16 | loading: true 17 | } 18 | 19 | } 20 | 21 | mix(){ 22 | var a = [ 23 | [1,2,3], 24 | [4,5,6], 25 | [7,8,9] 26 | ] 27 | 28 | var d = [[0,1],[0,-1],[1,0],[-1,0]] 29 | 30 | var n = 100 31 | var x = 2, y = 2 32 | var b = 0 33 | 34 | while(n){ 35 | b = Math.floor(Math.random()*4) 36 | if(this.isvalid(x+d[b][0],y+d[b][1])){ 37 | a[x][y] = a[x+d[b][0]][y+d[b][1]] 38 | a[x+d[b][0]][y+d[b][1]] = 9 39 | x+=d[b][0] 40 | y+=d[b][1] 41 | n-- 42 | } 43 | } 44 | 45 | this.setState({a:a}) 46 | } 47 | 48 | componentWillReceiveProps(nextProps) { 49 | this.setState({}); 50 | } 51 | 52 | reset(ele){ 53 | this.setState({done:false, image: "",loading: true}) 54 | var puzzle = ele.target.parentElement.children[1]; 55 | puzzle.style.display = "flex"; 56 | var finalimage = puzzle.parentElement.children[0]; 57 | finalimage.hidden = true; 58 | this.fetchimage() 59 | this.mix() 60 | this.refs.nextbutton.style.display = "none"; 61 | } 62 | 63 | fetchimage(){ 64 | fetch("https://source.unsplash.com/random/280x280").then(res=>{ 65 | this.setState({image: res.url, loading: false}) 66 | this.refs.nextbutton.style.display = "initial"; 67 | }).catch(err=> { 68 | this.setState({image: "https://images.unsplash.com/photo-1595496710086-d69bff2ccb19?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=280&ixlib=rb-1.2.1&q=80&w=280"}) 69 | this.refs.nextbutton.style.display = "initial"; 70 | }) 71 | } 72 | 73 | componentWillMount(){ 74 | this.fetchimage() 75 | this.mix() 76 | } 77 | 78 | isvalid(x,y){ 79 | return x >= 0 && x < 3 && y >= 0 && y < 3; 80 | } 81 | 82 | giveninth(ele){ 83 | var parent = ele.target.parentElement 84 | for (var piece of parent.children) { 85 | if(piece.classList[1]=="p9"){ 86 | return piece 87 | } 88 | } 89 | } 90 | 91 | check(ele) { 92 | var a = this.state.a; 93 | var res = true; 94 | for (var i = 0; i < 3; i++) { 95 | for (var j = 0; j < 3; j++) { 96 | if (a[i][j] != i * 3 + j + 1) { 97 | res = false; 98 | break 99 | } 100 | } 101 | } 102 | 103 | if (res) { 104 | this.setState({done:true}) 105 | var puzzle = ele.target.parentElement; 106 | puzzle.style.display = "none"; 107 | var finalimage = puzzle.parentElement.children[0]; 108 | finalimage.hidden = false; 109 | } 110 | } 111 | 112 | move(ele) { 113 | var a = this.state.a; 114 | var done = this.state.done; 115 | var pie = ele.target; 116 | var cl = pie.classList[1]; 117 | var p = cl[1]; 118 | 119 | if (p == 9 || done) { 120 | return 121 | } 122 | 123 | var x = 0; 124 | var y = 0; 125 | var d = [ 126 | [1, 0], 127 | [-1, 0], 128 | [0, 1], 129 | [0, -1] 130 | ]; 131 | 132 | for (var i = 0; i < 3; i++) { 133 | for (var j = 0; j < 3; j++) { 134 | if (a[i][j] == p) { 135 | x = i; 136 | y = j; 137 | break; 138 | } 139 | } 140 | } 141 | 142 | for (var i = 0; i < d.length; i++) { 143 | var x1 = d[i][0]; 144 | var y1 = d[i][1]; 145 | if (this.isvalid(x1 + x, y1 + y)) { 146 | if (a[x1 + x][y1 + y] == 9) { 147 | a[x1 + x][y1 + y] = parseInt(p); 148 | a[x][y] = 9; 149 | var ninth = this.giveninth(ele) 150 | pie.classList.toggle("p9"); 151 | pie.classList.toggle(cl); 152 | ninth.classList.toggle("p9"); 153 | ninth.classList.toggle(cl); 154 | break; 155 | } 156 | } 157 | } 158 | 159 | this.setState({a:a}) 160 | 161 | this.check(ele) 162 | } 163 | 164 | render() { 165 | return ( 166 |
167 |
168 | {this.state.loading?
:( 169 |
170 | 173 |
174 | {this.state.a && this.state.a.map(row=>{ 175 | return row.map(piece=>{ 176 | return
181 | }) 182 | })} 183 |
184 | 185 |
186 | ) 187 | } 188 | 189 |
190 | ) 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /lib/view/problem.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import React from 'react'; 4 | 5 | const Problem = ({prob,changer})=>{ 6 | if(prob.verdict=="OK"){ 7 | if(prob.testset == "TESTS"){ 8 | currentstate =
Accepted
9 | }else{ 10 | currentstate =
Pre pass
11 | } 12 | }else if (prob.verdict=="WRONG_ANSWER") { 13 | currentstate =
Wrong on {prob.errtest}
14 | }else if (prob.verdict=="CHALLENGED") { 15 | currentstate =
HACKED
16 | }else if(prob.verdict=="TIME_LIMIT_EXCEEDED"){ 17 | currentstate =
TLE on {prob.errtest}
18 | }else if(prob.verdict=="TESTING"){ 19 | currentstate =
20 | }else if (prob.verdict=="MEMORY_LIMIT_EXCEEDED") { 21 | currentstate =
MLE on {prob.errtest}
22 | }else if(prob.verdict=="RUNTIME_ERROR" || prob.verdict=="COMPILATION_ERROR"){ 23 | currentstate =
RE on {prob.errtest}
24 | }else{ 25 | currentstate =
26 | } 27 | return ( 28 |
29 | {prob.index} - {prob.name} 30 | {prob.sub} 31 | {currentstate} 32 |
33 | ) 34 | } 35 | 36 | export default Problem; 37 | -------------------------------------------------------------------------------- /lib/view/problems.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import React from 'react' 4 | import Problem from './problem' 5 | import Actions from './actions' 6 | import request from 'request' 7 | import cheerio from 'cheerio' 8 | import RecentSubmissions from './recentsubmissions' 9 | import Judge from './judge' 10 | import Standings from './standings' 11 | 12 | export default class Problems extends React.PureComponent { 13 | constructor(props){ 14 | super(props); 15 | this.state = { 16 | contestId: props.contest.id, 17 | temp: 0, 18 | curr: 0, 19 | createnv: props.contest.createnv, 20 | isLoggedIn: props.contest.isLoggedIn, 21 | restartenv: 0, 22 | mystanding: -1, 23 | probs: [], 24 | noftests: [], 25 | allverdicts: {}, 26 | allinputs: {}, 27 | alloutputs: {}, 28 | actions: [] 29 | }; 30 | } 31 | 32 | componentWillReceiveProps(nextProps) { 33 | this.setState({ 34 | isLoggedIn: nextProps.contest.isLoggedIn 35 | }); 36 | } 37 | 38 | openWorkFile(i){ 39 | const path = require('path') 40 | 41 | var wd = atom.config.get("codeblue.workingDirectory") 42 | var langcode = atom.config.get("codeblue.programmingLanguage") 43 | var ext = "" 44 | if(langcode==43) ext=".c" 45 | else if(langcode==54) ext=".cpp" 46 | else ext=".py" 47 | 48 | var prob = this.state.probs[i] 49 | 50 | var towhere = path.join(wd,prob.index) 51 | var tofile = path.join(towhere,prob.index+ext) 52 | tofile = path.resolve(tofile) 53 | 54 | try{ 55 | atom.workspace.open(tofile) 56 | }catch(err){ 57 | 58 | } 59 | 60 | } 61 | 62 | changecurr(ele){ 63 | var hd = ele.target.innerText 64 | hd = hd.split(" ") 65 | var id = hd[0]; 66 | var i=0 67 | 68 | while(this.state.probs[i]!=null){ 69 | if(this.state.probs[i].index == id){ 70 | this.setState({curr: i}) 71 | this.openWorkFile(i) 72 | break; 73 | } 74 | i++; 75 | } 76 | } 77 | 78 | changeignorevalue(){ 79 | var probs = this.state.probs 80 | probs[this.state.curr].ignorecase^=1 81 | this.setState({probs: probs}) 82 | this.setState({temp: this.state.temp^1}) 83 | } 84 | 85 | runtestpy (i){ 86 | console.log("Running python"); 87 | const path = require('path'); 88 | var prob = this.state.probs[this.state.curr] 89 | var langcode = atom.config.get("codeblue.programmingLanguage") 90 | var ext = ".py" 91 | var wd = atom.config.get("codeblue.workingDirectory") 92 | var towhere = path.join(wd,prob.index) 93 | var torun = path.join(towhere,prob.index+ext) 94 | var inputfile = path.join(towhere,"examples/input"+i+".in") 95 | 96 | var allverdicts = this.state.allverdicts 97 | const { exec } = require('child_process'); 98 | 99 | cmd = "python "+ torun +" < " + inputfile 100 | 101 | var res = {n: i-1, error: false, verdict: "none", icon: "hourglass"} 102 | allverdicts[prob.index][i-1] = res 103 | this.setState({allverdicts: allverdicts}) 104 | this.setState({temp: this.state.temp^1}) 105 | 106 | exec(cmd,{ 107 | timeout: 2500, 108 | maxBuffer: 1024*32, 109 | },(error, stdout, stderr)=>{ 110 | // var res = {n: i-1, error: false, verdict: "none", icon: "none"} 111 | res.stdout = stdout.trim("\n") 112 | if(error !== null){ 113 | res.error = true 114 | if(atom.config.get("codeblue.beautifyboolean")){ 115 | stderr = Judge.beautify(stderr) 116 | } 117 | if(error.killed){ 118 | res.verdict = "TIME_LIMIT_EXCEEDED" 119 | res.icon = "clock" 120 | }else if(error.code=="ERR_CHILD_PROCESS_STDIO_MAXBUFFER"){ 121 | res.verdict = "MEMORY_LIMIT_EXCEEDED" 122 | res.icon = "database" 123 | }else{ 124 | res.verdict = "RUNTIME_ERROR" 125 | res.icon = "alert" 126 | } 127 | }else{ 128 | if(Judge.verify(res.stdout,this.state.alloutputs[prob.index][i-1],prob.ignorecase)){ 129 | res.verdict="OK" 130 | res.icon="check" 131 | }else{ 132 | res.verdict="WRONG_ANSWER" 133 | res.icon="x" 134 | } 135 | } 136 | res.stderr = stderr 137 | allverdicts[prob.index][i-1] = res 138 | this.setState({allverdicts: allverdicts}) 139 | this.setState({temp: this.state.temp^1}) 140 | }) 141 | } 142 | 143 | runtestcpp (i){ 144 | console.log("Running cpp or c"); 145 | const path = require('path'); 146 | var prob = this.state.probs[this.state.curr] 147 | var langcode = atom.config.get("codeblue.programmingLanguage") 148 | var ext = "" 149 | if(langcode==43) ext=".c" 150 | else if(langcode==54) ext=".cpp" 151 | 152 | if(ext=="") return 153 | 154 | var wd = atom.config.get("codeblue.workingDirectory") 155 | var towhere = path.join(wd,prob.index) 156 | const fname = prob.index+ext 157 | var torun = path.join(towhere,fname) 158 | var tout = path.join(towhere,prob.index) 159 | var inputfile = path.join(towhere,"examples/input"+i+".in") 160 | 161 | var allverdicts = this.state.allverdicts 162 | 163 | const { exec } = require('child_process'); 164 | 165 | var soft="" 166 | if(langcode==54){ 167 | soft="g++ " 168 | }else if (langcode==43) { 169 | soft="gcc " 170 | } 171 | 172 | if(soft=="") return 173 | var cmd = soft+torun+" -o "+tout+" -fno-show-column -fno-diagnostics-show-caret" 174 | var cmd2 = tout+" < "+inputfile 175 | 176 | exec(cmd,{ 177 | timeout: 2500, 178 | maxBuffer: 1024*32 179 | },(error, stdout, stderr)=>{ 180 | // console.log("What"); 181 | if(error !== null){ 182 | var res = {n: i-1, error: true, verdict: "COMPILATION_ERROR", icon: "alert"} 183 | if(atom.config.get("codeblue.beautifyboolean")){ 184 | stderr = Judge.beautifycpp(stderr,torun) 185 | } 186 | res.stderr = stderr 187 | res.stdout = stdout.trim() 188 | allverdicts[prob.index][i-1] = res 189 | this.setState({allverdicts: allverdicts}) 190 | this.setState({temp: this.state.temp^1}) 191 | }else{ 192 | exec(cmd2,{ 193 | timeout: 5000, 194 | maxBuffer: 1024*32 195 | },(error, stdout, stderr)=>{ 196 | // console.log("The hell"); 197 | var res = {n: i-1, error: false, verdict: "none", icon: "none"} 198 | res.stdout = stdout.trim() 199 | if(error !== null){ 200 | res.error = true; 201 | if(error.killed){ 202 | // console.log("tle"); 203 | res.verdict = "TIME_LIMIT_EXCEEDED" 204 | res.icon = "clock" 205 | }else if(error.code=="ERR_CHILD_PROCESS_STDIO_MAXBUFFER"){ 206 | // console.log("mle"); 207 | res.verdict = "MEMORY_LIMIT_EXCEEDED" 208 | res.icon = "database" 209 | }else{ 210 | // console.log("runtime"); 211 | res.verdict = "RUNTIME_ERROR" 212 | res.icon = "alert" 213 | stderr = "Runtime error\nexit code : "+error.code 214 | } 215 | }else{ 216 | if(Judge.verify(res.stdout,this.state.alloutputs[prob.index][i-1],prob.ignorecase)){ 217 | res.verdict="OK" 218 | res.icon="check" 219 | }else{ 220 | res.verdict="WRONG_ANSWER" 221 | res.icon="x" 222 | } 223 | } 224 | res.stderr = stderr 225 | allverdicts[prob.index][i-1] = res 226 | this.setState({allverdicts: allverdicts}) 227 | this.setState({temp: this.state.temp^1}) 228 | }) 229 | } 230 | }) 231 | 232 | } 233 | 234 | runexamples(){ 235 | console.log("Running tests"); 236 | var langcode = atom.config.get("codeblue.programmingLanguage") 237 | if(langcode==31 || langcode==41){ 238 | for (var i = 0; i < this.state.noftests[this.state.curr]; i++) { 239 | this.runtestpy(i+1) 240 | } 241 | } 242 | 243 | if(langcode==43 || langcode==54){ 244 | for (var i = 0; i < this.state.noftests[this.state.curr]; i++) { 245 | this.runtestcpp(i+1) 246 | } 247 | } 248 | 249 | } 250 | 251 | submitsolution(){ 252 | console.log("Submitting solution"); 253 | const path = require('path'); 254 | var prob = this.state.probs[this.state.curr] 255 | var langcode = atom.config.get("codeblue.programmingLanguage") 256 | var ext = "" 257 | if(langcode==43) ext=".c" 258 | else if(langcode==54) ext=".cpp" 259 | else ext=".py" 260 | var wd = atom.config.get("codeblue.workingDirectory") 261 | var towhere = path.join(wd,prob.index) 262 | var tosub = path.join(towhere,prob.index+ext) 263 | var proburl = "https://codeforces.com/contest/"+ this.state.contestId +"/problem/" + prob.index 264 | 265 | cmd = "oj s " + proburl + " " + tosub + " --wait=0 --yes --no-open -l "+langcode 266 | 267 | const { exec } = require('child_process'); 268 | exec(cmd,(error, stdout, stderr)=>{ 269 | if(error !== null){ 270 | console.log(error); 271 | atom.notifications.addError("Error occured while submitting") 272 | }else{ 273 | this.loadsubmissions() 274 | } 275 | 276 | }) 277 | } 278 | 279 | fetch(url){ 280 | return new Promise((resolve, reject) => { 281 | request(url, (error, response, body) => { 282 | if (!error && response.statusCode == 200) { 283 | resolve(body) 284 | } else { 285 | reject({ 286 | reason: 'Unable to download page' 287 | }) 288 | } 289 | }) 290 | }) 291 | } 292 | 293 | createnv(){ 294 | var pr = 1 295 | for (var x of this.state.noftests) { 296 | pr*=x; 297 | if(pr==0){ 298 | return 299 | } 300 | } 301 | 302 | this.setState({createnv: 0}) 303 | 304 | const setup = require('./setup'); 305 | var wd = atom.config.get("codeblue.workingDirectory") 306 | 307 | var i = 0 308 | console.log("Setup initiated"); 309 | var langcode = atom.config.get("codeblue.programmingLanguage") 310 | var ext = "" 311 | if(langcode==43) ext=".c" 312 | else if(langcode==54) ext=".cpp" 313 | else ext=".py" 314 | 315 | for (var prob of this.state.probs) { 316 | setup(wd, { 317 | alpha: prob.index, 318 | tot: this.state.noftests[i]} , 319 | ext, 320 | this.state.allinputs[prob.index], 321 | this.state.alloutputs[prob.index]) 322 | i++ 323 | } 324 | } 325 | 326 | scrapetests(html, index){ 327 | if(html==null) return 328 | $ = cheerio.load(html) 329 | var i = 0 330 | var noftests = this.state.noftests 331 | var allinputs = this.state.allinputs 332 | var alloutputs = this.state.alloutputs 333 | var allverdicts = this.state.allverdicts 334 | var verdicts = [] 335 | var inputs = [] 336 | var outputs = [] 337 | while(true){ 338 | var io = $(`#pageContent > div.problemindexholder > div > div > div.sample-tests > div.sample-test > div:nth-child(${i+1}) > pre`).html() 339 | if(io){ 340 | io = io.trim().split("
").join("\n").trim() 341 | if(i&1){ 342 | outputs.push(io) 343 | }else{ 344 | inputs.push(io) 345 | verdicts.push({n: Math.floor(i/2), error:false, verdict: "none", icon: "none", stdout: "", stderr: "" }) 346 | } 347 | }else{ 348 | noftests[index] = Math.floor(i/2) 349 | allinputs[this.state.probs[index].index] = inputs 350 | alloutputs[this.state.probs[index].index] = outputs 351 | allverdicts[this.state.probs[index].index] = verdicts 352 | break 353 | } 354 | i++ 355 | } 356 | this.setState({ 357 | noftests: noftests, 358 | allinputs: allinputs, 359 | alloutputs: alloutputs, 360 | allverdicts: allverdicts},()=>{ 361 | if(this.state.createnv || this.state.restartenv){ 362 | this.createnv() 363 | } 364 | }) 365 | // console.log(this.state.allverdicts); 366 | } 367 | 368 | loadsamplecases(i){ 369 | var url = "https://codeforces.com/contest/"+this.state.contestId+"/problem/"+this.state.probs[i].index 370 | this.fetch(url).then((html) => { 371 | return this.scrapetests(html,i); 372 | }).catch((error) => { 373 | console.log(error); 374 | }) 375 | } 376 | 377 | loadallsamplecases(){ 378 | var i = 0 379 | var noftests = [] 380 | for (var i = 0; i < this.state.noftests.length; i++) { 381 | this.loadsamplecases(i) 382 | } 383 | } 384 | 385 | scrape(html){ 386 | if(html==null) return 387 | $ = cheerio.load(html) 388 | var probs = this.state.probs 389 | 390 | for (var i = 2; i < probs.length+2; i++) { 391 | var sub = $(`#pageContent > div.datatable > div:nth-child(6) > table > tbody > tr:nth-child(${i}) > td > a`).text().trim().substring(2) 392 | if(sub.length==0){ 393 | continue 394 | }else{ 395 | sub = sub.trim() 396 | probs[i-2].sub = sub 397 | } 398 | } 399 | this.setState({probs: probs}) 400 | this.setState({temp: this.state.temp^1}) 401 | } 402 | 403 | loadmystanding(){ 404 | // console.log("Loading my standing"); 405 | var url = "https://codeforces.com/api/contest.standings?contestId="+ this.state.contestId +"&from=1&handles=" + atom.config.get("codeblue.codeforcesHandle") 406 | fetch(url) 407 | .then(res=> res.json()) 408 | .then(res=> { 409 | if(res.result.rows[0]){ 410 | this.setState({mystanding: res.result.rows[0].rank}) 411 | } 412 | }) 413 | .catch(err =>{ 414 | console.log(err) 415 | }) 416 | } 417 | 418 | loadsubmissions(){ 419 | console.log("Refreshing"); 420 | var url = "https://codeforces.com/contest/"+this.state.contestId 421 | this.fetch(url).then((html) => { 422 | this.scrape(html); 423 | }).catch((error) => { 424 | atom.notifications.addWarning(error.reason) 425 | }) 426 | this.loadmystanding() 427 | this.fetchactions() 428 | } 429 | 430 | fetchproblems(problems){ 431 | // console.log("Fetching problems", problems); 432 | var probs = [] 433 | var noftests = [] 434 | var allinputs = {} 435 | var alloutputs = {} 436 | var allverdicts = {} 437 | for (var problem of problems) { 438 | probs.push({ 439 | index: problem.index, 440 | name: problem.name, 441 | verdict: "NONE", 442 | testset: "NONE", 443 | errtest: 0, 444 | ignorecase: 0, 445 | sub: 0}) 446 | allinputs[problem.index] = [] 447 | alloutputs[problem.index] = [] 448 | allverdicts[problem.index] = [] 449 | noftests.push(0) 450 | } 451 | this.setState({ 452 | probs: probs, 453 | noftests: noftests, 454 | allinputs: allinputs, 455 | alloutputs: alloutputs, 456 | allverdicts: allverdicts 457 | },()=>{ 458 | this.loadsubmissions() 459 | this.loadallsamplecases() 460 | this.fetchactions() 461 | }) 462 | } 463 | 464 | updateactions(){ 465 | var probs = [] 466 | var i = 0 467 | for (var prob of this.state.probs) { 468 | probs.push(prob) 469 | probs[i].verdict = "NONE" 470 | for (var action of this.state.actions) { 471 | if(action.index==prob.index){ 472 | if(action.verdict!="OK" && probs[i].verdict!="NONE" ){ 473 | continue 474 | } 475 | probs[i].verdict = action.verdict 476 | probs[i].testset = action.testset 477 | probs[i].errtest = action.errtest 478 | } 479 | } 480 | i++; 481 | } 482 | this.setState({probs: probs}) 483 | } 484 | 485 | reloadactions(res){ 486 | if(res==null) return 487 | var actions = [] 488 | for (var action of res) { 489 | var icon = "" 490 | if(action.verdict=="OK") icon="check" 491 | else if(action.verdict=="WRONG_ANSWER") icon="x" 492 | else if(action.verdict=="TIME_LIMIT_EXCEEDED") icon="clock" 493 | else if(action.verdict=="RUNTIME_ERROR") icon="stop" 494 | else if(action.verdict=="COMPILATION_ERROR") icon="alert" 495 | else if(action.verdict=="MEMORY_LIMIT_EXCEEDED") icon="database" 496 | else if(action.verdict=="CHALLENGED") icon="flame" 497 | else icon = "hourglass" 498 | 499 | actions.push({ 500 | index: action.problem.index, 501 | verdict: action.verdict, 502 | testset: action.testset, 503 | errtest: action.passedTestCount+1, 504 | icon: icon, 505 | time: action.timeConsumedMillis, 506 | memory: action.memoryConsumedBytes/1000 507 | }) 508 | } 509 | this.setState({actions: actions}) 510 | this.updateactions() 511 | } 512 | 513 | fetchactions(){ 514 | // console.log("Loading my actions"); 515 | var url = "https://codeforces.com/api/contest.status?contestId="+ this.state.contestId +"&handle="+ atom.config.get("codeblue.codeforcesHandle") 516 | fetch(url) 517 | .then(res=> res.json()) 518 | .then(res=> this.reloadactions(res.result)) 519 | .catch(err => console.log(err)) 520 | } 521 | 522 | restart(){ 523 | this.setState({restartenv: 1}) 524 | var url = "https://codeforces.com/api/contest.standings?contestId="+this.state.contestId+"&from=1&count=1" 525 | fetch(url) 526 | .then(res=>res.json()) 527 | .then(res=> this.fetchproblems(res.result.problems)) 528 | .catch(err=>{ 529 | console.log(err) 530 | atom.notifications.addWarning("Error while fetching problems") 531 | }) 532 | } 533 | 534 | componentWillMount(){ 535 | var url = "https://codeforces.com/api/contest.standings?contestId="+this.state.contestId+"&from=1&count=1" 536 | fetch(url) 537 | .then(res=>res.json()) 538 | .then(res=> this.fetchproblems(res.result.problems)) 539 | .catch(err=>{ 540 | console.log(err) 541 | atom.notifications.addWarning("Error while fetching problems") 542 | }) 543 | 544 | var intervaltime = atom.config.get("codeblue.refreshinterval") 545 | 546 | if(this.props.contest.finished==0 && intervaltime>0){ 547 | setInterval(()=>{this.loadsubmissions()},intervaltime*1000) 548 | } 549 | 550 | if(this.props.contest.openinbrowser){ 551 | const { exec } = require('child_process'); 552 | var cmd = "start "+"https://codeforces.com/contest/"+this.state.contestId+"/problems" 553 | exec(cmd,(error, stdout, stderr)=>{ 554 | if(error==null){ 555 | console.log("Opened in browser"); 556 | } 557 | }) 558 | } 559 | } 560 | 561 | changeproblem(activepath){ 562 | if(activepath==null) return 563 | 564 | const path = require('path') 565 | 566 | var wd = atom.config.get("codeblue.workingDirectory") 567 | var langcode = atom.config.get("codeblue.programmingLanguage") 568 | var ext = "" 569 | if(langcode==43) ext=".c" 570 | else if(langcode==54) ext=".cpp" 571 | else ext=".py" 572 | 573 | var i=0 574 | activepath = path.resolve(activepath) 575 | 576 | for (var prob of this.state.probs) { 577 | var towhere = path.join(wd,prob.index) 578 | var tofile = path.join(towhere,prob.index+ext) 579 | tofile = path.resolve(tofile) 580 | if(tofile==activepath){ 581 | this.setState({curr: i}) 582 | break 583 | } 584 | i++; 585 | } 586 | } 587 | 588 | componentDidMount() { 589 | atom.workspace.observeActiveTextEditor(editor=>{ 590 | if (editor){ 591 | this.changeproblem(editor.getPath()) 592 | } 593 | }) 594 | setTimeout(()=>{ 595 | this.loadsubmissions() 596 | },2000) 597 | } 598 | 599 | hide(){ 600 | var tohide = document.getElementById('standingview') 601 | var val = tohide.style.display 602 | if(val!="none"){ 603 | tohide.style.display = "none"; 604 | }else{ 605 | tohide.style.display = "block"; 606 | } 607 | } 608 | 609 | render(){ 610 | return ( 611 |
612 | 613 | {this.state.probs.length ? 614 |
615 | {this.state.mystanding} 616 |
617 | : null } 618 | {this.state.probs.length ? 619 | 625 | : null} 626 |
627 | {this.state.probs.length ? this.state.probs.map(prob=>{ 628 | return 629 | }) : ( 630 |
631 | ) 632 | } 633 |
634 | {this.state.probs.length ? : null } 645 | {this.state.probs.length ? : null } 646 |
647 | )} 648 | } 649 | -------------------------------------------------------------------------------- /lib/view/quotes.json: -------------------------------------------------------------------------------- 1 | { 2 | "data" : [ 3 | "Life is too short for finding matching socks. Albert Einstein", 4 | "Change your thoughts and you change your world. Norman Vincent Peale", 5 | "Those who realize their folly are not true fools. Zhuangzi", 6 | "Life is too important to be taken seriously. Oscar Wilde", 7 | "Life can only be understood backwards; but it must be lived forwards. Soren Kierkegaard", 8 | "It always seems impossible until it's done. Nelson Mandela", 9 | "Keep your eyes on the stars and your feet on the ground. Theodore Roosevelt", 10 | "It's better to be a lion for a day than a sheep all your life. Elizabeth Kenny", 11 | "Life is a question and how we live it is our answer. Gary Keller", 12 | "Keep looking up that's the secret of life. Snoopy", 13 | "It is better to be hated for what you are than to be loved for what you are not. Andre Gide", 14 | "My life is my message. Mahatma Gandhi", 15 | "Not how long, but how well you have lived is the main thing. Seneca", 16 | "I love those who can smile in trouble. Leonardo da Vinci", 17 | "Be happy for this moment. This moment is your life. Omar Khayyam", 18 | "Life is what happens when you're busy making other plans. John Lennon", 19 | "You've gotta dance like there's nobody watching. William W. Purkey", 20 | "Believe that life is worth living and your belief will help create the fact. William James", 21 | "Do not take life too seriously. You will never get out of it alive. Elbert Hubbard", 22 | "Don't search for the meaning of life. Simply be present for the people you love. Maxime Lagac", 23 | "The heart, like the stomach, wants a varied diet. Gustave Flaubert", 24 | "I tell you, in this world being a little crazy helps to keep you sane. Zsa Zsa Gabor", 25 | "The trick in life is learning how to deal with it. Helen Mirren", 26 | "Get busy living or get busy dying. Stephen King", 27 | "Don't gain the world and lose your soul, wisdom is better than silver or gold. Bob Marley", 28 | "To live is the rarest thing in the world. Most people exist, that is all. Oscar Wilde", 29 | "Anyone who lives within their means suffers from a lack of imagination. Oscar Wilde", 30 | "Don't cry because it's over, smile because it happened. Ludwig Jacobowski", 31 | "Life is either a daring adventure or nothing at all. Helen Keller", 32 | "Tis better to have loved and lost than never to have loved at all. St. Augustine", 33 | "You only live once, but if you do it right, once is enough. Mae West", 34 | "The mind is everything. What you think you become.", 35 | "The journey of a thousand miles begins with one step. Lao Tzu", 36 | "The unexamined life is not worth living. Socrates", 37 | "You must be the change you wish to see in the world. Mahatma Gandhi", 38 | "The best way out is always through. Robert Frost", 39 | "Success is how high you bounce when you hit bottom. George S. Patton", 40 | "Our life is frittered away by detail. Simplify, simplify. Henry David Thoreau", 41 | "Life isn't about finding yourself. Life is about creating yourself. George Bernard Shaw", 42 | "Good friends, good books, and a sleepy conscience: this is the ideal life. Mark Twain", 43 | "Life is really simple, but we insist on making it complicated. Confucius", 44 | "If you want to live a happy life, tie it to a goal, not to people or things.", 45 | "Look deep into nature, and then you will understand everything better. Albert Einstein", 46 | "Never let the fear of striking out keep you from playing the game. Babe Ruth", 47 | "Love the life you live. Live the life you love. Bob Marley", 48 | "Keep calm and carry on. Winston Churchill", 49 | "Love all, trust a few, do wrong to none. William Shakespeare", 50 | "Life is ours to be spent, not to be saved. D. H. Lawrence", 51 | "Life is short, death is forever. Chuck Palahniuk", 52 | "In three words I can sum up everything I've learned about life: It goes on. Robert Frost", 53 | "Life is short but it is wide. This too shall pass. Rebecca Wells", 54 | "The greatest pleasure of life is love. Euripides", 55 | "Life can be simple and beautiful. Focus on the good things. Maxime Lagac", 56 | "Life is a long lesson in humility. James M. Barrie", 57 | "It's better to dance than to march through life. Yoko Ono", 58 | "We are who we choose to be. Green Goblin", 59 | "I'm always doing things I can't do. That's how I get to do them. Pablo Picasso", 60 | "Life is short, and it is up to you to make it sweet. Sarah Louise Delany", 61 | "The only impossible journey is the one you never begin. Tony Robbins", 62 | "Doing is a quantum leap from imagining. Barbara Sher", 63 | "Be so good they can't ignore you. Steve Martin", 64 | "All our dreams can come true if we have the courage to pursue them. Walt Disney", 65 | "We are all in the gutter, but some of us are looking at the stars. Oscar Wilde", 66 | "If you say you can or you can't you are right either way. Henry Ford", 67 | "Perpetual optimism is a force multiplier. Colin Powell", 68 | "The dreamers are the saviors of the world. James Allen", 69 | "Everything has its beauty, but not everyone see its. Confucius", 70 | "In the midst of winter, I found there was within me an invincible summer. Albert Camus", 71 | "There is no education like adversity. Benjamin Disraeli", 72 | "I will go anywhere as long as it's forward. David Livingston", 73 | "Find ecstasy in life; the mere sense of living is joy enough. Emily Dickinson", 74 | "In the middle of a difficulty lies opportunity. Albert Einstein", 75 | "Life doesn't require that we be the best, only that we try our best. H. Jackson Brown Jr.", 76 | "May you live all the days of your life. Jonathan Swift", 77 | "Happiness is the absence of the striving for happiness. Zhuangzi", 78 | "Defeat is simply a signal to press onward. Helen Keller", 79 | "I've failed over and over and over again in my life. And that is why I succeed. Michael Jordan", 80 | "Discouragement and failure are two of the surest stepping stones to success. Dale Carnegie", 81 | "The purpose of our lives is to be happy. Dalai Lama", 82 | "Once you choose hope, anything's possible. Christopher Reeve", 83 | "There is only one happiness in life to love and to be loved. George Sand", 84 | "Rise above the storm and you will find the sunshine. Mario Fernandez", 85 | "Some people never go crazy. What truly horrible lives they must lead. Charles Bukowski", 86 | "Those who believe in telekinetics, raise my hand. Kurt Vonnegut", 87 | "All you need is love. But a little chocolate now and then doesn't hurt. Charles Schulz", 88 | "Accept who you are. Unless you're a serial killer. Ellen DeGeneres", 89 | "All generalizations are false, including this one.", 90 | "When angry, count to four; when very angry, swear. Mark Twain", 91 | "When life gives you lemons, squirt someone in the eye. Cathy Guisewite", 92 | "Life is pain. Anyone who says otherwise is selling something. William Goldman", 93 | "A woman's mind is cleaner than a man's: She changes it more often. Oliver Herford", 94 | "I can resist everything except temptation. Oscar Wilde", 95 | "The planet is fine. The people are fucked. George Carlin", 96 | "The reason I talk to myself is because I'm the only one whose answers I accept. George Carlin", 97 | "I love deadlines, I like the whooshing sound they make as they fly by. Douglas Adams", 98 | "If you're too open-minded; your brains will fall out. Lawrence Ferlinghetti", 99 | "Behind every great man is a woman rolling her eyes. Jim Carrey", 100 | "Life is so short. I would rather sing one song than interpret the thousand. Jack London", 101 | "Life is made of ever so many partings welded together. Charles Dickens", 102 | "The flavor of life is on the edge. Naval Ravikant", 103 | "We are evolved to search for meaning but ultimately life has none. Naval Ravikant", 104 | "This is your life and it's ending one minute at a time. Tyler Durden (Fight Club)", 105 | "The shortness of life, so often lamented, may be the best thing about it. Arthur Schopenhauer", 106 | "In the book of life, the answers aren't in the back. Charlie Brown", 107 | "We no longer live life. We consume it. Vicki Robin (Your Money Or Your Life)", 108 | "If my life is going to mean anything, I have to live it myself. Rick Riordan", 109 | "Life does not owe you anything because life has already given you everything. Ralph Marston", 110 | "The day you stop racing, is the day you win the race. Bob Marley", 111 | "Maybe that's what life is a wink of the eye and winking stars. Jack Kerouac", 112 | "What do you want a meaning for? Life is a desire, not a meaning. Charlie Chaplin", 113 | "Life's too mysterious to take too serious. Mary Engelbreit", 114 | "The chief danger in life is that you may take too many precautions. Alfred Adler", 115 | "When it hurts observe. Life is trying to teach you something. Anita Krizzan", 116 | "You're never wrong if you love and help people. Maxime Lagac", 117 | "The only beautiful path is the one you create. Maxime Lagac", 118 | "Do what is right, not what is easy nor what is popular. Roy T. Bennett", 119 | "Good judgment comes from experience, and experience comes from bad judgment. Rita Mae Brown", 120 | "Care about what other people think and you will always be their prisoner. Lao Tzu", 121 | "You get in life what you have the courage to ask for. Oprah Winfrey", 122 | "Love is the goal, life is the journey. Osho", 123 | "I think being in love with life is a key to eternal youth. Doug Hutchison", 124 | "Where there is love there is life.", 125 | "If I know what love is, it is because of you. Herman Hesse", 126 | "It is not where we breathe, but where we Love, that we live. Soren Kierkegaard", 127 | "I love you not because of who you are, but because of who I am when I am with you. Roy Croft", 128 | "A drop of love can bring an ocean of tears. Jewish Proverb", 129 | "We are shaped and fashioned by what we love. Johann Wolfgang von Goethe", 130 | "The way to love anything is to realize that it may be lost. Gilbert K. Chesterton", 131 | "Don't brood. Get on with living and loving. You don't have forever. Leo Buscaglia", 132 | "Love is not only something you feel, it is something you do. David Wilkerson", 133 | "Love is a better teacher than duty. Albert Einstein", 134 | "The art of love is largely the art of persistence. Albert Ellis", 135 | "Love does not dominate; it cultivates. Johann Wolfgang von Goethe", 136 | "We are most alive when we're in love. John Updike", 137 | "The giving of love is an education in itself. Eleanor Roosevelt", 138 | "The greatest gift of life is friendship, and I have received it. Hubert H. Humphrey", 139 | "A friend is someone who knows all about you and still loves you. Elbert Hubbard", 140 | "A brother may not be a friend, but a friend will always be a brother.", 141 | "Only a life lived for others is a life worthwhile. Albert Einstein", 142 | "The capacity for friendship is God's way of apologizing for our families. Jay McInerney", 143 | "Happiness is only real when shared. Jon Krakauer", 144 | "There is nothing better than a friend, unless it is a friend with chocolate. Linda Grayson", 145 | "Family is not an important thing. It's everything. Michael J. Fox", 146 | "A happy family is but an earlier heaven. George Bernard Shaw", 147 | "If you're lucky, family members are friends, and friends are family members. Maxime Lagac", 148 | "Make sure they know you love them. Maxime Lagac", 149 | "One father is more than a hundred schoolmasters. George Herbert", 150 | "The strength of a nation derives from the integrity of the home. Confucius", 151 | "Each day of our lives we make deposits in the memory banks of our children. Charles R. Swindoll", 152 | "It is not flesh and blood but the heart which makes us fathers and sons. Johann Schiller", 153 | "Family means no one gets left behind or forgotten. David Ogden Stiers", 154 | "Children are a poor man's riches. English Proverb", 155 | "Other things may change us, but we start and end with the family. Anthony Brandt", 156 | "In family relationships, love is really spelled T.I.M.E. Dieter F. Uchtdorf", 157 | "I have learned that to be with those I like is enough. Walt Whitman", 158 | "Life is trying things to see if they work. Ray Bradbury", 159 | "A man who dares to waste one hour of time has not discovered the value of life. Charles Darwin", 160 | "Success is about creating value. Candice Carpenter", 161 | "The worst part of success is trying to find someone who is happy for you. Bette Midler", 162 | "Try not to become a man of success. Rather become a man of value.", 163 | "It is better to fail in originality than to succeed in imitation. Herman Melville", 164 | "All you need in this life is ignorance and confidence; then success is sure. Mark Twain", 165 | "Good is not enough. You've got to be great. Simon Cowell", 166 | "Success is getting what you want, happiness is wanting what you get. W.P. Kinsella", 167 | "Have no fear of perfection? you'll never reach it. Salvador Dali", 168 | "Choose a job you love, and you will never have to work a day in your life. Confucius", 169 | "Success is stumbling from failure to failure with no loss of enthusiasm. Winston S. Churchill", 170 | "Without the rain there would be no rainbow. Gilbert Chesterton", 171 | "Sometimes life hits you in the head with a brick. Don't lose faith. Steve Jobs", 172 | "All life is an experiment. The more experiments you make the better.", 173 | "You cannot find peace avoiding life. Virginia Woolf", 174 | "Life is like riding a bicycle. To keep your balance, you must keep moving. Albert Einstein", 175 | "Life's under no obligation to give us what we expect. Margaret Mitchell", 176 | "If life were predictable it would cease to be life, and be without flavor. Eleanor Roosevelt", 177 | "Life is a succession of lessons which must be lived to be understood. Ralph Waldo Emerson", 178 | "Obstacles are the cost of greatness. Robin Sharm", 179 | "The question isn't who is doing to let me, it's who is going to stop me. Ayn Rand", 180 | "I wasn't there to compete. I was there to win. Arnold Schwarzenegger", 181 | "All the power is within you. You can do anything. Swami Vivekananda", 182 | "The place between your comfort zone and your dream is where life takes place. Helen Keller", 183 | "Stop whining, start grinding. Eric Thomas", 184 | "Never bend your head. Hold it high. Look the world straight in the eye. Helen Keller", 185 | "What you want exists. Don't settle until you get it. Jay Shetty", 186 | "Work hard, be kind, and amazing things will happen. Conan O'Brien", 187 | "I am not afraid, I was born to do this. Joan of Arc", 188 | "Those who truly want something will keep trying until they die. Maxime Lagac", 189 | "Do what you have to do until you can do what you want to do. Oprah Winfrey", 190 | "If you fell down yesterday, stand up today. H.G. Wells", 191 | "Fall seven times, stand up eight. Japanese proverb", 192 | "The only person you are destined to become is the person you decide to be. Ralph Waldo Emerson", 193 | "Blood, sweat and respect. First two you give. Last one you earn. Dwayne Johnson (The Rock)", 194 | "Conformity gets you nowhere. Neil Strauss", 195 | "Be so good they can't ignore you. Steve Martin", 196 | "Show the world how much you'll fight for the winners circle. Pat Riley", 197 | "Action is the real measure of intelligence. Napoleon Hill", 198 | "Everything you've ever wanted is on the other side of fear. George Addair", 199 | "Make each day your masterpiece. John Wooden", 200 | "Everything you can imagine is real. Pablo Picasso", 201 | "Do not wait to strike till the iron is hot. Make it hot by striking. William Butler Yeats", 202 | "I can't believe that God put us on this earth to be ordinary. Lou Holtz", 203 | "I want the world to be better because I was here. Will Smith", 204 | "The habit of persistence is the habit of victory. Herbert Kaufman", 205 | "Don't be afraid to give up the good to go for the great. John D. Rockefeller", 206 | "Do your duty and a little more and the future will take care of itself. Andrew Carnegie", 207 | "To seek greatness is the only righteous vengeance. Criss Jami", 208 | "It's hard to beat a person who never gives up. Babe Ruth", 209 | "Every strike brings me closer to the next home run. Babe Ruth", 210 | "Do the best you can until you know better. Then when you know better, do better.", 211 | "If you can dream it, you can do it. Walt Disney", 212 | "The way to get started is to quit talking and begin doing. Walt Disney", 213 | "Only those who dare to fail greatly can ever achieve greatly. Robert F. Kennedy", 214 | "Win from within. Usain Bolt", 215 | "Believe you can and you're halfway there. Theodore Roosevelt", 216 | "If you're going through hell, keep going. Winston Churchill", 217 | "Success is walking from failure to failure with no loss of enthusiasm. Winston Churchill", 218 | "Strength does not come from physical capacity. It comes from an indomitable will.", 219 | "Diligence is the mother of good luck. Benjamin Franklin", 220 | "Energy and persistence conquer all things. Benjamin Franklin", 221 | "Don't stop when you're tired; stop when you're done. Marilyn Monroe", 222 | "The only place where success comes before work is in the dictionary. Vince Lombardi", 223 | "Whatever the mind of man can conceive and believe, it can achieve. Napoleon Hill", 224 | "Whether you think you can or you think you can't, you're right. Henry Ford", 225 | "It is not the strength of the body that counts, but the strength of the spirit. J.R.R. Tolkien", 226 | "Life shrinks or expands in proportion to one's courage. Anais Nin", 227 | "I was taught that the way of progress was neither swift nor easy. Marie Curie", 228 | "There is always room at the top. Daniel Webster", 229 | "Action is character. F. Scott Fitzgerald", 230 | "Leap, and the net will appear. John Burroughs", 231 | "Be your own hero. Maxime Lagac", 232 | "I prefer to die trying. Maxime Lagac", 233 | "Wake up determined. Go to bed satisfied. Dwayne Johnson (The Rock)", 234 | "I like getting to that point where it's hard, and then, pushing harder. Zach Miller", 235 | "Light tomorrow with today. Elizabeth Barrett Browning", 236 | "Show them what crazy dreams can do.", 237 | "We must act. Marie Curie", 238 | "Remember why you started. Erin Janus", 239 | "Success is my only option, failure's not. Eminem", 240 | "I am not talented. I am obsessed. Conor McGregor", 241 | "You could be anyone if you put the time. Conor McGregor", 242 | "Nothing is given. Everything is earned. LeBron James", 243 | "If you can't stop thinking about it, don't stop working for it. Unknown", 244 | "I didn't come this far to only go this far. Unknown", 245 | "The moment you want to quit is the moment you need to keep pushing. Unknown", 246 | "One day or day one. It's your choice. Unknown", 247 | "Don't wait for opportunity. Create it. Unknown", 248 | "You are your only limit. Unknown", 249 | "Prove them wrong. Unknown", 250 | "I can and I will. Unknown", 251 | "Don't call it a dream, call it a plan. Unknown", 252 | "What you allow is what will continue. Unknown", 253 | "Don't stop until you're proud. Unknown", 254 | "Don't look back you're not going that way. Unknown", 255 | "You are capable of amazing things. Unknown", 256 | "Better an oops than a what if. Unknown", 257 | "Storms make trees take deeper roots. Unknown", 258 | "Don't wish for it. Work for it. Unknown", 259 | "Will it be easy? No. Will it be worth it? Absolutely. Unknown", 260 | "Strive for progress, not perfection. Unknown", 261 | "Don't wait. The time will never be just right. Napoleon Hill", 262 | "Half-heartedness never won a battle. William McKinley", 263 | "Good is the enemy of great. Jony Ive (Apple)", 264 | "Quality is not an act, it is a habit. Aristotle", 265 | "Aim for the highest. Andrew Carnegie", 266 | "Do your thing and don't care if they like it. Tina Fey", 267 | "What you do today can improve all your tomorrows. Ralph Marston", 268 | "And you ask What if I fall?. Oh, but my darling, What if you fly?. Erin Hanson", 269 | "Nothing happens to anybody which he is not fitted by nature to bear.", 270 | "You don't have to be great to start, but you have to start to be great. Zig Ziglar", 271 | "What's the tiniest step you can take? Do that first. Maxime Lagac", 272 | "Become the best in the world at what you do. Keep redefining what you do until this is true.", 273 | "I am not what happened to me. I am what I choose to become. Unknown", 274 | "Strength grows in the moments you can't go on, but you keep going anyway. Unknown", 275 | "I'm not here to be average. I'm here to be awesome. Unknown", 276 | "Your potential is endless. Go do what you were created to do. Unknown", 277 | "Start where you are. Use what you have. Do what you can. Arthur Ashe", 278 | "If you want to lift yourself up, lift up someone else. Booker T. Washington", 279 | "We're not playing solitaire out here. Bill Parcells", 280 | "The ultimate inspiration is the deadline. Nolan Bushnell", 281 | "Expect problems and eat them for breakfast. Alfred A. Montapert", 282 | "Don't worry about looking good worry about achieving your goals. Ray Dalio", 283 | "Doing nothing is very hard to do you never know when you're finished. Leslie Nielsen", 284 | "There are seven days in a week and someday isn't one of them. Unknown", 285 | "Only dead fish go with the flow. Unknown", 286 | "Big shots are only little shots who keep shooting. Christopher Morley", 287 | "You miss 100% of the shots you don't take. Wayne Gretzky", 288 | "Dream as if you'll live forever. Live as if you'll die today. James Dean", 289 | "Aim for the moon. If you miss, you may hit a star. W. Clement Stone", 290 | "A quitter never wins and a winner never quits. Napoleon Hill", 291 | "If life gives you lemons, make lemonade. Unknown", 292 | "Live every day like it's your last. Unknown", 293 | "Be like a postage stamp stick to one thing until you get there. Unknown", 294 | "You can't make a rainbow without a little rain. Unknown", 295 | "Don't watch the clock; do what it does. Keep going. Sam Levenson", 296 | "Either you run the day or the day runs you. Jim Rohn", 297 | "Sweat is the cologne of accomplishment. Heywood Hale Broun", 298 | "Whenever I feel the need to exercise I lie down until it goes away. Paul Terry", 299 | "Even if you fall on your face you're still moving forward. Victor Kiam", 300 | "If your only goal is to become rich, you will never achieve it. John D. Rockefeller", 301 | "It's never too late to go back to bed. Unknown", 302 | "It is what it is. And it's not good. Unknown", 303 | "I do marathons, on Netflix. Unknown", 304 | "Work hard. Complain harder. Unknown", 305 | "Procrastinate now. Don't put it off. Ellen DeGeneres", 306 | "There are four basic human needs; food, sleep, sex and revenge. Banksy", 307 | "What I'm looking for is not out there, it is in me. Helen Keller", 308 | "If you are not doing what you love, you are wasting your time. Billy Joel", 309 | "It is never too late to be what you might have been. George Eliot", 310 | "Hardships often prepare ordinary people for an extraordinary destiny. C.S. Lewis", 311 | "Remember that not getting what you want is sometimes a wonderful stroke of luck. Dalai Lama", 312 | "Too many of us are not living our dreams because we are living our fears. Les Brown", 313 | "I have had all of the disadvantages required for success. Larry Ellison (Oracle)", 314 | "A wise man can always be found alone. A weak man can always be found in crowd. Unknown", 315 | "Fear defeats more people than any other one thing in the world.", 316 | "Motivation comes from meaning. Everything comes from meaning. Jay Shetty", 317 | "If you do not conquer self, you will be conquered by self. Napoleon Hill", 318 | "You have to be at your strongest when you're feeling at your weakest. Unknown", 319 | "It doesn't get easier. You get stronger. Unknown", 320 | "Sentiment without action is the ruin of the soul. Edward Abbey", 321 | "Most people fail in life because they major in minor things. Tony Robbins", 322 | "A hero is one who knows how to hang on for one minute longer. Norwegian proverb", 323 | "To avoid criticism, say nothing, do nothing, be nothing. Elbert Hubbard", 324 | "You don't discover your place in the world. You carve it out. Thibaut", 325 | "Winners focus on winning. Losers focus on winners.", 326 | "Winners never quit and quitters never win. Vince Lombardi", 327 | "Failure will never overtake me if my determination to succeed is strong enough. Og Mandino", 328 | "What comes easy won't last. What lasts won't come easy. Unknown", 329 | "Go as far as you can see; when you get there, you'll be able to see further. Thomas Carlyle", 330 | "Don't do what you can do try what you can't do. William Faulkner", 331 | "Embrace bad news to learn where you need the most improvement. Bill Gates", 332 | "A happy life consists not in the absence, but in the mastery of hardships. Helen Keller", 333 | "It is always your next move. Napoleon Hill", 334 | "Part 3. Motivational Quotes About", 335 | "Let your workings remain a mystery. Just show people the results. Lao Tzu", 336 | "The man who has confidence in himself gains the confidence of others. Hasidic proverb", 337 | "Genius begins great works; labor alone finishes them. Joseph Joubert", 338 | "Done is better than perfect. Sheryl Sandberg (Facebook)", 339 | "Even if you on the right track, you'll get run over if you just sit there. Will Rogers", 340 | "Work gives you meaning and purpose, and life is empty without it. Stephen Hawking", 341 | "You get the best out of others when you give the best of yourself. Harvey Firestone", 342 | "Leadership is an action, not a position. Donal McGannon", 343 | "Our work is the presentation of our capabilities. Edward Gibbon", 344 | "We are judged by what we finish, not by what we start. Unknown", 345 | "The ability to concentrate and to use time well is everything. Lee Iacocca (Ford)", 346 | "Management is nothing more than motivating other people. Lee Iacocca", 347 | "The speed of the boss is the speed of the team. Lee Iacocca", 348 | "We are limited, not by our abilities, but by our vision. Kahlil Gibran", 349 | "No man can become rich without himself enriching others. Andrew Carnegie", 350 | "Alone we can do so little; together we can do so much. Helen Keller", 351 | "The greater the difficulty, the greater the glory. Cicero", 352 | "Failure is the condiment that gives success its flavor. Truman Capote", 353 | "Adversity causes some men to break; others to break records. William Arthur Ward", 354 | "Although the world is full of suffering, it is full also of the overcoming of it. Helen Keller", 355 | "Wear your failure as a badge of honor. Sundar Pichai (Google)", 356 | "All my problems bow before my stubbornness. Amit Kalantri", 357 | "If you get tired, learn to rest, not to quit. Banksy", 358 | "Falling down is an accident. Staying down is a choice. Unknown", 359 | "Don't you dare give up on this life. Not tonight. Not tomorrow. Not ever. Unknown", 360 | "I always tried to turn every disaster into an opportunity. John D. Rockefeller", 361 | "First principle: never to let one's self be beaten down by persons or by events. Marie Curie", 362 | "When it's darkest, men see the stars. Ralph Waldo Emerson", 363 | "Some people dream of success, while others wake up and work hard at it. Napoleon Hill", 364 | "The time that leads to mastery is dependent on the intensity of our focus. Robert Greene", 365 | "It takes courage to grow up and become who you really are. E.E. Cummings", 366 | "Success only comes to those who dare to attempt. Mallika Tripathi", 367 | "One important key to success is self-confidence.", 368 | "Doubt kills more dreams than failure ever will. Suzy Kassem", 369 | "Anything that gets your blood racing is probably worth doing. Hunter S. Thompson", 370 | "Victory is always possible for the person who refuses to stop fighting. Napoleon Hill", 371 | "To be successful your focus has to be so intense that others think you're crazy. Unknown", 372 | "You did not wake up today to be mediocre. Unknown", 373 | "Don't tell people your dreams. Show them. Unknown", 374 | "Your imagination is your preview of life's coming attractions. Albert Einstein", 375 | "Obstacles are those frightful things you see when you take your eyes off your goal. Henry Ford", 376 | "The men who have succeeded are men who have chosen one line and stuck to it. Andrew Carnegie", 377 | "Finding an opportunity is a matter of believing it's there. Barbara Corcoran", 378 | "Setting goals is the first step in turning the invisible into the visible. Tony Robbins", 379 | "The path to success is to take massive, determined action. Tony Robbins", 380 | "If you don't risk anything, you risk even more. Erica Jong", 381 | "Opportunities don't happen, you create them. Chris Grosser", 382 | "If you can't change a situation, change your mind. Unknown", 383 | "With the new day comes new strength and new thoughts. Eleanor Roosevelt", 384 | "No matter how hard the past is, you can always begin again. Jack Kornfield", 385 | "Very often a change of self is needed more than a change of scene. Arthur Christopher Benson", 386 | "If you do what you've always done, you'll get what you've always gotten. Tony Robbins", 387 | "We can change our lives. We can do, have, and be exactly what we wish. Tony Robbins", 388 | "All achievements, all earned riches, have their beginning in an idea. Napoleon Hill", 389 | "Some injuries heal more quickly if you keep moving. Nick Vujicic", 390 | "What's dangerous is not to evolve. Jeff Bezos (Amazon)", 391 | "Either I will find a way, or I will make one. Philip Sidney", 392 | "The only way to shut everybody up is to win. Terry Bradshaw", 393 | "It's not whether you get knocked down, it's whether you get up. Vince Lombardi", 394 | "To give anything less than your best is to sacrifice the gift. Steve Prefontaine", 395 | "If you are not willing to risk the usual you will have to settle for the ordinary. Jim Rohn", 396 | "You're never a loser until you quit trying. Mike Ditka", 397 | "Success isn't permanent, and failure isn't fatal. Mike Ditka", 398 | "Don't ever let good enough be good enough. Bill Parcells", 399 | "Individuals play the game, but teams win championships. Bill Parcells", 400 | "Set your goals high, and don't stop till you get there. Bo Jackson", 401 | "When you want to succeed as bad as you want to breathe, then you'll be successful. Eric Thomas", 402 | "In the long run, we only hit what we aim at. Henry David Thoreau", 403 | "The first man gets the oyster, the second man gets the shell. Andrew Carnegie", 404 | "Today I will do what others won't so tomorrow I can do what others can't. Jerry Rice", 405 | "The greatest danger we face is the mind going soft. Robert Greene", 406 | "If you see it in your mind, you will hold it in your hand. Bob Proctor", 407 | "Continuous improvement is better than delayed perfection. Mark Twain", 408 | "Excellence is an art won by training and habituation. Aristotle", 409 | "It is the mind that makes the body rich. Andrew Carnegie", 410 | "Motivation is what gets you started. Habit is what keeps you going. Jim Rohn", 411 | "Lack of emotion causes lack of progress and lack of motivation. Tony Robbins", 412 | "If you can't, you must. If you must, you can. Tony Robbins", 413 | "If you have no destination, you'll never get there. Harvey Mackay", 414 | "Effort is only effort when it begins to hurt. Jos Ortega y Gassett", 415 | "Making excuses burns zero calories per hour. Unknown", 416 | "Without self-discipline, success is impossible. Period. Unknown", 417 | "Don't stop when you're tired. Stop when you are done. Unknown", 418 | "You're only one workout away from a good mood. Unknown", 419 | "Train insane or remain the same. Unknown", 420 | "It does not matter how slowly you go, so long as you do not stop. Confucius", 421 | "Success is measured by your discipline and inner peace. Mike Ditka", 422 | "Look in the mirror, that's your competition. Eric Thomas", 423 | "The most certain way to succeed is always to try just one more time. Thomas A. Edison", 424 | "Do what is right, not what is easy nor what is popular. Roy T. Bennett", 425 | "Nothing great ever came that easy. Kresley Cole", 426 | "Without a struggle, there can be no progress. Frederick Douglass", 427 | "Anything is possible when you are inner peace. Master Shifu (Kung Fun Panda)", 428 | "Successful people ask better questions, and as a result, they get better answers. Tony Robbins", 429 | "The more you give, the more comes back to you. Napoleon Hill", 430 | "I have no special talents. I am only passionately curious.", 431 | "By failing to prepare, you are preparing to fail. Benjamin Franklin", 432 | "There's a way to do it better find it. Thomas A. Edison", 433 | "If you shut the door to all errors, truth will be shut out. Rabindranath Tagore", 434 | "My goal is not to be better than anyone else, but to be better than I used to be. Wayne Dyer", 435 | "Don't ask for what the world needs. Ask what makes you come alive, and go do it. Bren Brown", 436 | "Forget the mistake. Remember the lesson. Unknown", 437 | "Be ready to fail because only then you are ready to succeed. Unknown", 438 | "You were born to be real, not perfect. Unknown", 439 | "Making mistakes is better than faking perfections. Unknown", 440 | "Do something wonderful, people may imitate it. Albert Schweitzer", 441 | "The days you don't want to are the days you have to if you want to reach your goal. Jay Shetty", 442 | "Best lesson I have learned in life came from the worst feeling I ever felt in life. Jay Shetty", 443 | "Who is wise? He that learns from everyone. Benjamin Franklin", 444 | "The expert at anything was once a beginner. Helen Hayes", 445 | "She believed she could so she did. Unknown", 446 | "Life is tough, darling, but so are you. Stephanie Bennett-Henry", 447 | "Have no fear of perfection; you'll never reach it. Marie Curie", 448 | "Only I can change my life. No one can do it for me. Carol Burnett", 449 | "I attribute my success to this: I never gave or took any excuse. Florence Nightingale", 450 | "She remembered who she was and the game changed. Lalah Delia", 451 | "Self-care is how you take your power back. Lalah Delia", 452 | "Choose people who choose you. Jay Shetty", 453 | "A bad day for your ego is a great day for your soul. Jillian Michaels", 454 | "I never dreamed about success. I worked for it. Estee Lauder", 455 | "Everything you've ever wanted is on the other side of fear. George Addair", 456 | "The soul that is within me no man can degrade. Frederick Douglass", 457 | "The world turns aside to let any man pass who knows where he is going. Epictetus", 458 | "He who wishes to be rich in a day will be hanged in a year. Leonardo da Vinci", 459 | "Deep down you know what you want. Deep down you have what it takes. Maxime Lagac", 460 | "Either write something worth reading or do something worth writing. Benjamin Franklin", 461 | "I am not a product of my circumstances. I am a product of my decisions. Stephen Covey", 462 | "The man who moves a mountain begins by carrying away small stones. Confucius", 463 | "Be brave to stand for what you believe in even if you stand alone. Roy T. Bennett", 464 | "We aim above the mark to hit the mark. Ralph Waldo Emerson", 465 | "Definiteness of purpose is the starting point of all achievement. W. Clement Stone", 466 | "Problems are not stop signs, they are guidelines. Robert H. Schuller", 467 | "You will never be able to hit a target that you cannot see. Robin Sharma", 468 | "You don't get any medal for trying something, you get medals for results. Bill Parcells", 469 | "Never let the world define you as less than great. Bill Parcells", 470 | "The worst thing I can be is the same as everybody else. I hate that. Arnold Schwarzenegger", 471 | "Stop being afraid of what could go wrong and think of what could go right. Unknown", 472 | "You'll never get ahead of anyone as long as you try to get even with him. Lou Holtz", 473 | "The real secret to success is enthusiasm. Walter Chrysler", 474 | "Never think there is anything impossible for the soul. Swami Vivekananda", 475 | "One way to keep momentum going is to have constantly greater goals. Michael Korda", 476 | "Make the most of yourself for that is all there is of you. Ralph Waldo Emerson", 477 | "It's what you practice in private that you will be rewarded for in public. Tony Robbins" 478 | ] 479 | } 480 | -------------------------------------------------------------------------------- /lib/view/recentsubmissions.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import React from 'react'; 4 | 5 | const RecentSubmissions = ({actions})=>{ 6 | 7 | const change = (ele)=>{ 8 | ele.target.classList.toggle("icon-chevron-right") 9 | ele.target.classList.toggle("icon-chevron-down") 10 | var val = ele.target.nextElementSibling.style.display 11 | if(val=="flex"){ 12 | ele.target.nextElementSibling.style.display = "none"; 13 | }else{ 14 | ele.target.nextElementSibling.style.display = "flex"; 15 | } 16 | } 17 | 18 | return ( 19 |
20 |

Recent Submissions

21 |
22 |
23 |
24 | {actions && actions.map(action=>{ 25 | return( 26 |
27 | {action.index} 28 | {action.errtest} 29 | {action.time}ms 30 | {action.memory<1000?{action.memory}kb:{Math.floor(action.memory/1000)}mb} 31 |
32 | ) 33 | })} 34 |
35 |
36 |
37 |
38 | ) 39 | } 40 | 41 | export default RecentSubmissions; 42 | 43 | // check 44 | // x 45 | // clock 46 | // alert 47 | -------------------------------------------------------------------------------- /lib/view/setup.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const data = require('./quotes.json'); 4 | 5 | const setup = (wd, prob, ext, inputs, outputs) => { 6 | 7 | var quote = data.data[Math.floor(Math.random() * data.data.length)].trim() 8 | var com = "" 9 | if(ext==".py") com = "# " 10 | if(ext==".c" || ext==".cpp") com = "// " 11 | quote = com + quote + "\n" 12 | if(atom.config.get("codeblue.codeforcesHandle")=="blue_edge"){ 13 | quote += com + "by : Blue Edge - Create some chaos\n\n" 14 | }else{ 15 | quote += "\n" 16 | } 17 | 18 | var dir = path.join(wd, prob.alpha) 19 | var fl = path.join(dir, prob.alpha + ext) 20 | var exp = path.join(dir, "examples") 21 | 22 | var inputpaths = [] 23 | for (var i = 1; i <= prob.tot; i++) { 24 | inputpaths.push({ 25 | dir: path.join(exp, "input" + i + ".in"), 26 | value: inputs[i - 1] 27 | }) 28 | } 29 | 30 | var outputpaths = [] 31 | for (var i = 1; i <= prob.tot; i++) { 32 | outputpaths.push({ 33 | dir: path.join(exp, "output" + i + ".out"), 34 | value: outputs[i - 1] 35 | }) 36 | } 37 | 38 | fs.mkdir(dir, (err) => { 39 | if (err && err.code != 'EEXIST') console.log("Error while creating problem folder", err.code); 40 | else { 41 | fs.writeFile(fl, quote, { 42 | flag: 'wx' 43 | }, (err) => { 44 | if (err) { 45 | if (err.code != 'EEXIST') console.log("Error while creating source file"); 46 | else console.log("Skipping because source file already exist"); 47 | } 48 | }) 49 | 50 | fs.mkdir(exp, (err) => { 51 | if (err && err.code != 'EEXIST') console.log("Error while creating example folder", err); 52 | else { 53 | for (var input of inputpaths) { 54 | fs.writeFile(input.dir, input.value, (err) => { 55 | if (err) console.log("Error while writing input file"); 56 | }) 57 | } 58 | 59 | for (var output of outputpaths) { 60 | fs.writeFile(output.dir, output.value, (err) => { 61 | if (err) console.log("Error while writing output file"); 62 | }) 63 | } 64 | } 65 | }) 66 | } 67 | }) 68 | } 69 | 70 | module.exports = setup 71 | -------------------------------------------------------------------------------- /lib/view/standings.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import React from 'react'; 4 | 5 | export default class Standings extends React.PureComponent { 6 | constructor(props){ 7 | super(props); 8 | this.state = { 9 | contestId: props.contestId, 10 | probs: props.probs, 11 | friends: {}, 12 | order: [], 13 | refreshbutton: props.refreshbutton 14 | } 15 | } 16 | 17 | componentWillReceiveProps(nextProps) { 18 | this.setState({ 19 | probs: nextProps.probs, 20 | refreshbutton: nextProps.refreshbutton 21 | }); 22 | } 23 | 24 | sorting(){ 25 | var friends = this.state.friends 26 | var order = Object.keys(friends) 27 | order.sort((a,b)=> (friends[a].rank>friends[b].rank?1:-1)) 28 | this.setState({order: order}) 29 | } 30 | 31 | async initiateorder(){ 32 | console.log("Its happening"); 33 | var friends = this.state.friends 34 | var friendsarray = Object.keys(friends) 35 | var url = "https://codeforces.com/api/contest.standings?contestId=" 36 | var allfriends = atom.config.get("codeblue.friends"); 37 | for (var friend of allfriends) { 38 | friend = friend.trim() 39 | await fetch(url+this.state.contestId+"&showUnofficial=false&from=1&handles="+friend) 40 | .then(res=> res.json()) 41 | .then(res=> { 42 | if(res.status=="OK" && res.result.rows.length!=0){ 43 | var data = res.result.rows[0] 44 | friends[friend] = {rank: data.rank, problemResults: data.problemResults} 45 | } 46 | }) 47 | } 48 | this.setState({friends: friends},()=>{ 49 | this.sorting() 50 | }) 51 | } 52 | 53 | componentWillMount(){ 54 | this.initiateorder() 55 | } 56 | 57 | render(){ 58 | return ( 59 |
60 | 64 |
65 |
66 |
67 |
#
68 |
Who
69 | {this.state.probs.map(prob=>{ 70 | return
{prob.index}
71 | })} 72 |
73 | 74 | {this.state.order.map(friend=>{ 75 | if(this.state.friends[friend]){ 76 | return ( 77 |
78 |
{this.state.friends[friend].rank}
79 |
{friend}
80 | {this.state.friends[friend].problemResults.map(res=>{ 81 | var ver = "" 82 | var count = "" 83 | if(res.points>0){ 84 | ver = " correct" 85 | count = "+" 86 | if(res.rejectedAttemptCount>0){ 87 | count+=res.rejectedAttemptCount 88 | } 89 | }else{ 90 | if(res.rejectedAttemptCount>0){ 91 | ver = " incorrectattempt" 92 | count="-"+res.rejectedAttemptCount 93 | } 94 | } 95 | return
{count}
96 | })} 97 |
98 | ) 99 | }else{ 100 | return null 101 | } 102 | })} 103 |
104 |
105 |
106 | ) 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /lib/view/tiktac.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import React from 'react'; 4 | 5 | export default class TikTac extends React.PureComponent { 6 | constructor(props) { 7 | super(props); 8 | this.state = { 9 | a: [ 10 | [-1, -1, -1], 11 | [-1, -1, -1], 12 | [-1, -1, -1] 13 | ], 14 | done: false, 15 | turn: 1, 16 | player: 0, 17 | temp: 0, 18 | playerscore: 0, 19 | computerscore: 0 20 | } 21 | } 22 | 23 | max(a){ 24 | var mx = a[0]; 25 | a.map(x=> mx=Math.max(x,mx)) 26 | return mx 27 | } 28 | 29 | min(a){ 30 | var mn = a[0]; 31 | a.map(x=> mn=Math.min(x,mn)) 32 | return mn 33 | } 34 | 35 | reset(){ 36 | var a = [ 37 | [-1, -1, -1], 38 | [-1, -1, -1], 39 | [-1, -1, -1] 40 | ] 41 | 42 | this.setState({ 43 | a: a, 44 | done: false, 45 | turn: this.state.turn^1, 46 | player: Math.floor(Math.random()*2) 47 | },()=>{ 48 | if(this.state.turn){ 49 | this.movecomputer() 50 | } 51 | }) 52 | } 53 | 54 | check(){ 55 | var neg = 0 56 | var a = this.state.a 57 | // console.log(a); 58 | var row = [0,0,0] 59 | var col = [0,0,0] 60 | var d = [0,0] 61 | for (var i = 0; i < 3; i++) { 62 | for (var j = 0; j < 3; j++) { 63 | if(a[i][j]+1==0){ 64 | neg++ 65 | }else{ 66 | row[i]+=2*a[i][j]-1 67 | col[j]+=2*a[i][j]-1 68 | if(i==j) d[0]+=2*a[i][j]-1 69 | if(i+j==2) d[1]+=2*a[i][j]-1 70 | } 71 | } 72 | } 73 | 74 | // console.log(row); 75 | // console.log(col); 76 | // console.log(d); 77 | 78 | var winner = -1 79 | if(this.max(row)==3 || this.max(col)==3 || this.max(d)==3){ 80 | winner = 1 81 | } 82 | 83 | if(this.min(row)==-3 || this.min(col)==-3 || this.max(d)==-3){ 84 | winner = 0 85 | } 86 | 87 | if(winner!=-1){ 88 | return winner 89 | } 90 | if(neg==0){ 91 | return 2 92 | } 93 | else return -1 94 | } 95 | 96 | indexofchildren(ele){ 97 | var parent = ele.target.parentElement 98 | var child = ele.target 99 | var i = 0; 100 | while(parent.children[i]!=child){ 101 | i++; 102 | } 103 | return [Math.floor(i/3),i%3] 104 | } 105 | 106 | movecomputer(){ 107 | if(this.state.done){ 108 | this.reset() 109 | return 110 | } 111 | 112 | var winner = this.check(); 113 | if(winner+1){ 114 | var curr = this.state.player; 115 | if(winner==curr){ 116 | // console.log("Com play"); 117 | this.setState({playerscore: this.state.playerscore+1}) 118 | } 119 | else if(winner==(this.state.player^1)){ 120 | // console.log("Com com"); 121 | this.setState({computerscore: this.state.computerscore+1}) 122 | } 123 | 124 | this.setState({done: true}) 125 | return 126 | } 127 | 128 | var res = [0,0] 129 | var a = this.state.a 130 | var i = 0, j=0, neg=0,x=0,y=0,sym = -1; 131 | var moved = false; 132 | var empty = []; 133 | console.log("Computer move"); 134 | 135 | // self///////// 136 | 137 | var own=0 138 | sym = this.state.player^1 139 | 140 | i = 0 141 | while(i<3){ 142 | j = 0 143 | own = 0 144 | neg = 0 145 | while(j<3){ 146 | if(a[i][j]+1==0){ 147 | neg++ 148 | x=i 149 | y=j 150 | empty.push([x,y]) 151 | } 152 | if(a[i][j]==sym) own++ 153 | j++ 154 | } 155 | if(own==2 && neg){ 156 | a[x][y] = this.state.player^1 157 | moved = true 158 | this.setState({a:a}) 159 | break 160 | } 161 | 162 | i++ 163 | } 164 | 165 | if(moved) return 166 | 167 | j=0 168 | while(j<3){ 169 | i = 0 170 | own = 0 171 | neg = 0 172 | while(i<3){ 173 | if(a[i][j]+1==0){ 174 | neg++ 175 | x=i 176 | y=j 177 | } 178 | if(a[i][j]==sym) own++ 179 | i++ 180 | } 181 | 182 | if(own==2 && neg){ 183 | a[x][y] = this.state.player^1 184 | moved = true 185 | this.setState({a:a}) 186 | break 187 | } 188 | 189 | j++ 190 | } 191 | 192 | if(moved) return 193 | 194 | i = 0 195 | own = 0 196 | neg = 0 197 | while(i<3){ 198 | if(a[i][i]+1==0){ 199 | neg++ 200 | x=i 201 | y=i 202 | } 203 | if(a[i][i]==sym) own++ 204 | i++ 205 | } 206 | 207 | if(own==2 && neg){ 208 | a[x][y] = this.state.player^1 209 | moved = true 210 | this.setState({a:a}) 211 | } 212 | 213 | if(moved) return 214 | 215 | i = 0 216 | own = 0 217 | neg = 0 218 | while(i<3){ 219 | if(a[i][2-i]+1==0){ 220 | neg++ 221 | x=i 222 | y=2-i 223 | } 224 | if(a[i][2-i]==sym) own++ 225 | i++ 226 | } 227 | 228 | if(own==2 && neg){ 229 | a[x][y] = this.state.player^1 230 | moved = true 231 | this.setState({a:a}) 232 | } 233 | 234 | if(moved) return 235 | 236 | 237 | /////opposition//////// 238 | var opp=0 239 | sym = this.state.player 240 | 241 | while(i<3){ 242 | j = 0 243 | opp = 0 244 | neg = 0 245 | while(j<3){ 246 | if(a[i][j]+1==0){ 247 | neg++ 248 | x=i 249 | y=j 250 | } 251 | if(a[i][j]==sym) opp++ 252 | j++ 253 | } 254 | if(opp==2 && neg){ 255 | a[x][y] = this.state.player^1 256 | moved = true 257 | this.setState({a:a}) 258 | break 259 | } 260 | 261 | i++ 262 | } 263 | 264 | if(moved) return 265 | 266 | j=0 267 | while(j<3){ 268 | i = 0 269 | opp = 0 270 | neg = 0 271 | while(i<3){ 272 | if(a[i][j]+1==0){ 273 | neg++ 274 | x=i 275 | y=j 276 | } 277 | if(a[i][j]==sym) opp++ 278 | i++ 279 | } 280 | 281 | if(opp==2 && neg){ 282 | a[x][y] = this.state.player^1 283 | moved = true 284 | this.setState({a:a}) 285 | break 286 | } 287 | 288 | j++ 289 | } 290 | 291 | if(moved) return 292 | 293 | i = 0 294 | opp = 0 295 | neg = 0 296 | while(i<3){ 297 | if(a[i][i]+1==0){ 298 | neg++ 299 | x=i 300 | y=i 301 | } 302 | if(a[i][i]==sym) opp++ 303 | i++ 304 | } 305 | 306 | if(opp==2 && neg){ 307 | a[x][y] = this.state.player^1 308 | moved = true 309 | this.setState({a:a}) 310 | } 311 | 312 | if(moved) return 313 | 314 | i = 0 315 | opp = 0 316 | neg = 0 317 | while(i<3){ 318 | if(a[i][2-i]+1==0){ 319 | neg++ 320 | x=i 321 | y=2-i 322 | } 323 | if(a[i][2-i]==sym) opp++ 324 | i++ 325 | } 326 | 327 | if(opp==2 && neg){ 328 | a[x][y] = this.state.player^1 329 | moved = true 330 | this.setState({a:a}) 331 | } 332 | 333 | if(moved) return 334 | 335 | 336 | /////////random//////// 337 | 338 | var selec = empty[Math.floor(Math.random()*empty.length)] 339 | var x = selec[0], y = selec[1] 340 | a[x][y] = this.state.player^1 341 | 342 | this.setState({a:a}) 343 | } 344 | 345 | move(ele){ 346 | if(this.state.done){ 347 | this.reset() 348 | return 349 | } 350 | 351 | var winner = this.check(); 352 | if(winner+1){ 353 | if(winner==this.state.player){ 354 | // console.log("play play"); 355 | this.setState({playerscore: this.state.playerscore+1}) 356 | } 357 | 358 | if(winner==(this.state.player^1)){ 359 | // console.log("play com"); 360 | this.setState({computerscore: this.state.computerscore+1}) 361 | } 362 | 363 | this.setState({done: true}) 364 | return 365 | } 366 | 367 | if(ele==null) return 368 | if(ele.target.classList.length>1) return 369 | // console.log(ele.target.classList); 370 | var a = this.state.a 371 | var pos = this.indexofchildren(ele) 372 | var x=pos[0], y=pos[1] 373 | a[x][y] = this.state.player; 374 | this.setState({a:a}) 375 | this.setState({temp: this.state.temp^1}) 376 | this.movecomputer() 377 | } 378 | 379 | componentWillReceiveProps(nextProps) { 380 | this.setState({}); 381 | } 382 | 383 | componentWillMount(){ 384 | if(this.state.turn==0){ 385 | this.movecomputer() 386 | } 387 | } 388 | 389 | render() { 390 | return ( 391 |
392 |
393 |
{this.state.playerscore}:{this.state.computerscore}
394 |
395 | {this.state.a && this.state.a.map(row=>{ 396 | return row.map(val=>{ 397 | var itstate = "square" 398 | if(val==1){ 399 | itstate+=" cross" 400 | }else if (val==0) { 401 | itstate+=" circle" 402 | } 403 | return
406 |
407 | }) 408 | })} 409 |
410 |
411 |
412 | ) 413 | } 414 | } 415 | -------------------------------------------------------------------------------- /menus/codeblue.json: -------------------------------------------------------------------------------- 1 | { 2 | "context-menu": { 3 | ".tree-view li.directory .header": [{ 4 | "type": "separator" 5 | }, 6 | { 7 | "label": "Codeblue: Set as working directory", 8 | "command": "codeblue:set-working-directory" 9 | } 10 | ] 11 | }, 12 | "menu": [{ 13 | "label": "Packages", 14 | "submenu": [{ 15 | "label": "codeblue", 16 | "submenu": [{ 17 | "label": "Start", 18 | "command": "codeblue:toggle" 19 | }] 20 | }] 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "codeblue", 3 | "version": "1.6.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "14.0.27", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz", 10 | "integrity": "sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g==" 11 | }, 12 | "ajv": { 13 | "version": "6.12.3", 14 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz", 15 | "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==", 16 | "requires": { 17 | "fast-deep-equal": "^3.1.1", 18 | "fast-json-stable-stringify": "^2.0.0", 19 | "json-schema-traverse": "^0.4.1", 20 | "uri-js": "^4.2.2" 21 | } 22 | }, 23 | "asn1": { 24 | "version": "0.2.4", 25 | "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", 26 | "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", 27 | "requires": { 28 | "safer-buffer": "~2.1.0" 29 | } 30 | }, 31 | "assert-plus": { 32 | "version": "1.0.0", 33 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 34 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" 35 | }, 36 | "asynckit": { 37 | "version": "0.4.0", 38 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 39 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 40 | }, 41 | "aws-sign2": { 42 | "version": "0.7.0", 43 | "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", 44 | "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" 45 | }, 46 | "aws4": { 47 | "version": "1.10.0", 48 | "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.0.tgz", 49 | "integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==" 50 | }, 51 | "axios": { 52 | "version": "0.19.2", 53 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", 54 | "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", 55 | "requires": { 56 | "follow-redirects": "1.5.10" 57 | } 58 | }, 59 | "bcrypt-pbkdf": { 60 | "version": "1.0.2", 61 | "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", 62 | "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", 63 | "requires": { 64 | "tweetnacl": "^0.14.3" 65 | } 66 | }, 67 | "boolbase": { 68 | "version": "1.0.0", 69 | "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", 70 | "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" 71 | }, 72 | "caseless": { 73 | "version": "0.12.0", 74 | "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", 75 | "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" 76 | }, 77 | "cheerio": { 78 | "version": "1.0.0-rc.3", 79 | "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.3.tgz", 80 | "integrity": "sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==", 81 | "requires": { 82 | "css-select": "~1.2.0", 83 | "dom-serializer": "~0.1.1", 84 | "entities": "~1.1.1", 85 | "htmlparser2": "^3.9.1", 86 | "lodash": "^4.15.0", 87 | "parse5": "^3.0.1" 88 | } 89 | }, 90 | "child_process": { 91 | "version": "1.0.2", 92 | "resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz", 93 | "integrity": "sha1-sffn/HPSXn/R1FWtyU4UODAYK1o=" 94 | }, 95 | "combined-stream": { 96 | "version": "1.0.8", 97 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 98 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 99 | "requires": { 100 | "delayed-stream": "~1.0.0" 101 | } 102 | }, 103 | "copy-to-clipboard": { 104 | "version": "3.3.1", 105 | "resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.1.tgz", 106 | "integrity": "sha512-i13qo6kIHTTpCm8/Wup+0b1mVWETvu2kIMzKoK8FpkLkFxlt0znUAHcMzox+T8sPlqtZXq3CulEjQHsYiGFJUw==", 107 | "requires": { 108 | "toggle-selection": "^1.0.6" 109 | } 110 | }, 111 | "core-util-is": { 112 | "version": "1.0.2", 113 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 114 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" 115 | }, 116 | "crypto": { 117 | "version": "1.0.1", 118 | "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz", 119 | "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==" 120 | }, 121 | "css-select": { 122 | "version": "1.2.0", 123 | "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", 124 | "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", 125 | "requires": { 126 | "boolbase": "~1.0.0", 127 | "css-what": "2.1", 128 | "domutils": "1.5.1", 129 | "nth-check": "~1.0.1" 130 | } 131 | }, 132 | "css-what": { 133 | "version": "2.1.3", 134 | "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", 135 | "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==" 136 | }, 137 | "dashdash": { 138 | "version": "1.14.1", 139 | "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", 140 | "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", 141 | "requires": { 142 | "assert-plus": "^1.0.0" 143 | } 144 | }, 145 | "debug": { 146 | "version": "3.1.0", 147 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", 148 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", 149 | "requires": { 150 | "ms": "2.0.0" 151 | } 152 | }, 153 | "delayed-stream": { 154 | "version": "1.0.0", 155 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 156 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" 157 | }, 158 | "dom-serializer": { 159 | "version": "0.1.1", 160 | "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", 161 | "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", 162 | "requires": { 163 | "domelementtype": "^1.3.0", 164 | "entities": "^1.1.1" 165 | } 166 | }, 167 | "domelementtype": { 168 | "version": "1.3.1", 169 | "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", 170 | "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" 171 | }, 172 | "domhandler": { 173 | "version": "2.4.2", 174 | "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", 175 | "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", 176 | "requires": { 177 | "domelementtype": "1" 178 | } 179 | }, 180 | "domutils": { 181 | "version": "1.5.1", 182 | "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", 183 | "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", 184 | "requires": { 185 | "dom-serializer": "0", 186 | "domelementtype": "1" 187 | } 188 | }, 189 | "ecc-jsbn": { 190 | "version": "0.1.2", 191 | "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", 192 | "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", 193 | "requires": { 194 | "jsbn": "~0.1.0", 195 | "safer-buffer": "^2.1.0" 196 | } 197 | }, 198 | "entities": { 199 | "version": "1.1.2", 200 | "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", 201 | "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" 202 | }, 203 | "extend": { 204 | "version": "3.0.2", 205 | "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", 206 | "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" 207 | }, 208 | "extsprintf": { 209 | "version": "1.3.0", 210 | "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", 211 | "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" 212 | }, 213 | "fast-deep-equal": { 214 | "version": "3.1.3", 215 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", 216 | "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" 217 | }, 218 | "fast-json-stable-stringify": { 219 | "version": "2.1.0", 220 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", 221 | "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" 222 | }, 223 | "follow-redirects": { 224 | "version": "1.5.10", 225 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", 226 | "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", 227 | "requires": { 228 | "debug": "=3.1.0" 229 | } 230 | }, 231 | "forever-agent": { 232 | "version": "0.6.1", 233 | "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", 234 | "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" 235 | }, 236 | "form-data": { 237 | "version": "2.3.3", 238 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", 239 | "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", 240 | "requires": { 241 | "asynckit": "^0.4.0", 242 | "combined-stream": "^1.0.6", 243 | "mime-types": "^2.1.12" 244 | } 245 | }, 246 | "fs": { 247 | "version": "0.0.1-security", 248 | "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", 249 | "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" 250 | }, 251 | "getpass": { 252 | "version": "0.1.7", 253 | "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", 254 | "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", 255 | "requires": { 256 | "assert-plus": "^1.0.0" 257 | } 258 | }, 259 | "har-schema": { 260 | "version": "2.0.0", 261 | "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", 262 | "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" 263 | }, 264 | "har-validator": { 265 | "version": "5.1.5", 266 | "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", 267 | "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", 268 | "requires": { 269 | "ajv": "^6.12.3", 270 | "har-schema": "^2.0.0" 271 | } 272 | }, 273 | "htmlparser2": { 274 | "version": "3.10.1", 275 | "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", 276 | "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", 277 | "requires": { 278 | "domelementtype": "^1.3.1", 279 | "domhandler": "^2.3.0", 280 | "domutils": "^1.5.1", 281 | "entities": "^1.1.1", 282 | "inherits": "^2.0.1", 283 | "readable-stream": "^3.1.1" 284 | } 285 | }, 286 | "http-signature": { 287 | "version": "1.2.0", 288 | "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", 289 | "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", 290 | "requires": { 291 | "assert-plus": "^1.0.0", 292 | "jsprim": "^1.2.2", 293 | "sshpk": "^1.7.0" 294 | } 295 | }, 296 | "inherits": { 297 | "version": "2.0.4", 298 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 299 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 300 | }, 301 | "is-typedarray": { 302 | "version": "1.0.0", 303 | "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", 304 | "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" 305 | }, 306 | "isstream": { 307 | "version": "0.1.2", 308 | "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", 309 | "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" 310 | }, 311 | "js-tokens": { 312 | "version": "4.0.0", 313 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", 314 | "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" 315 | }, 316 | "jsbn": { 317 | "version": "0.1.1", 318 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", 319 | "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" 320 | }, 321 | "json-schema": { 322 | "version": "0.2.3", 323 | "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", 324 | "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" 325 | }, 326 | "json-schema-traverse": { 327 | "version": "0.4.1", 328 | "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", 329 | "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" 330 | }, 331 | "json-stringify-safe": { 332 | "version": "5.0.1", 333 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", 334 | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" 335 | }, 336 | "jsprim": { 337 | "version": "1.4.1", 338 | "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", 339 | "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", 340 | "requires": { 341 | "assert-plus": "1.0.0", 342 | "extsprintf": "1.3.0", 343 | "json-schema": "0.2.3", 344 | "verror": "1.10.0" 345 | } 346 | }, 347 | "lodash": { 348 | "version": "4.17.19", 349 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", 350 | "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" 351 | }, 352 | "loose-envify": { 353 | "version": "1.4.0", 354 | "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", 355 | "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", 356 | "requires": { 357 | "js-tokens": "^3.0.0 || ^4.0.0" 358 | } 359 | }, 360 | "mime-db": { 361 | "version": "1.44.0", 362 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", 363 | "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" 364 | }, 365 | "mime-types": { 366 | "version": "2.1.27", 367 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", 368 | "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", 369 | "requires": { 370 | "mime-db": "1.44.0" 371 | } 372 | }, 373 | "ms": { 374 | "version": "2.0.0", 375 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 376 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 377 | }, 378 | "nth-check": { 379 | "version": "1.0.2", 380 | "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", 381 | "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", 382 | "requires": { 383 | "boolbase": "~1.0.0" 384 | } 385 | }, 386 | "oauth-sign": { 387 | "version": "0.9.0", 388 | "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", 389 | "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" 390 | }, 391 | "object-assign": { 392 | "version": "4.1.1", 393 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 394 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 395 | }, 396 | "parse5": { 397 | "version": "3.0.3", 398 | "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", 399 | "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", 400 | "requires": { 401 | "@types/node": "*" 402 | } 403 | }, 404 | "path": { 405 | "version": "0.12.7", 406 | "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", 407 | "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", 408 | "requires": { 409 | "process": "^0.11.1", 410 | "util": "^0.10.3" 411 | } 412 | }, 413 | "performance-now": { 414 | "version": "2.1.0", 415 | "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", 416 | "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" 417 | }, 418 | "process": { 419 | "version": "0.11.10", 420 | "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", 421 | "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" 422 | }, 423 | "prop-types": { 424 | "version": "15.7.2", 425 | "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", 426 | "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", 427 | "requires": { 428 | "loose-envify": "^1.4.0", 429 | "object-assign": "^4.1.1", 430 | "react-is": "^16.8.1" 431 | } 432 | }, 433 | "psl": { 434 | "version": "1.8.0", 435 | "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", 436 | "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==" 437 | }, 438 | "punycode": { 439 | "version": "2.1.1", 440 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", 441 | "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" 442 | }, 443 | "qs": { 444 | "version": "6.5.2", 445 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", 446 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" 447 | }, 448 | "react": { 449 | "version": "16.13.1", 450 | "resolved": "https://registry.npmjs.org/react/-/react-16.13.1.tgz", 451 | "integrity": "sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==", 452 | "requires": { 453 | "loose-envify": "^1.1.0", 454 | "object-assign": "^4.1.1", 455 | "prop-types": "^15.6.2" 456 | } 457 | }, 458 | "react-dom": { 459 | "version": "16.13.1", 460 | "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.13.1.tgz", 461 | "integrity": "sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==", 462 | "requires": { 463 | "loose-envify": "^1.1.0", 464 | "object-assign": "^4.1.1", 465 | "prop-types": "^15.6.2", 466 | "scheduler": "^0.19.1" 467 | } 468 | }, 469 | "react-is": { 470 | "version": "16.13.1", 471 | "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", 472 | "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" 473 | }, 474 | "readable-stream": { 475 | "version": "3.6.0", 476 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", 477 | "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", 478 | "requires": { 479 | "inherits": "^2.0.3", 480 | "string_decoder": "^1.1.1", 481 | "util-deprecate": "^1.0.1" 482 | } 483 | }, 484 | "request": { 485 | "version": "2.88.2", 486 | "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", 487 | "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", 488 | "requires": { 489 | "aws-sign2": "~0.7.0", 490 | "aws4": "^1.8.0", 491 | "caseless": "~0.12.0", 492 | "combined-stream": "~1.0.6", 493 | "extend": "~3.0.2", 494 | "forever-agent": "~0.6.1", 495 | "form-data": "~2.3.2", 496 | "har-validator": "~5.1.3", 497 | "http-signature": "~1.2.0", 498 | "is-typedarray": "~1.0.0", 499 | "isstream": "~0.1.2", 500 | "json-stringify-safe": "~5.0.1", 501 | "mime-types": "~2.1.19", 502 | "oauth-sign": "~0.9.0", 503 | "performance-now": "^2.1.0", 504 | "qs": "~6.5.2", 505 | "safe-buffer": "^5.1.2", 506 | "tough-cookie": "~2.5.0", 507 | "tunnel-agent": "^0.6.0", 508 | "uuid": "^3.3.2" 509 | } 510 | }, 511 | "safe-buffer": { 512 | "version": "5.2.1", 513 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 514 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" 515 | }, 516 | "safer-buffer": { 517 | "version": "2.1.2", 518 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 519 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 520 | }, 521 | "scheduler": { 522 | "version": "0.19.1", 523 | "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz", 524 | "integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==", 525 | "requires": { 526 | "loose-envify": "^1.1.0", 527 | "object-assign": "^4.1.1" 528 | } 529 | }, 530 | "sshpk": { 531 | "version": "1.16.1", 532 | "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", 533 | "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", 534 | "requires": { 535 | "asn1": "~0.2.3", 536 | "assert-plus": "^1.0.0", 537 | "bcrypt-pbkdf": "^1.0.0", 538 | "dashdash": "^1.12.0", 539 | "ecc-jsbn": "~0.1.1", 540 | "getpass": "^0.1.1", 541 | "jsbn": "~0.1.0", 542 | "safer-buffer": "^2.0.2", 543 | "tweetnacl": "~0.14.0" 544 | } 545 | }, 546 | "string_decoder": { 547 | "version": "1.3.0", 548 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", 549 | "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", 550 | "requires": { 551 | "safe-buffer": "~5.2.0" 552 | } 553 | }, 554 | "toggle-selection": { 555 | "version": "1.0.6", 556 | "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", 557 | "integrity": "sha1-bkWxJj8gF/oKzH2J14sVuL932jI=" 558 | }, 559 | "tough-cookie": { 560 | "version": "2.5.0", 561 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", 562 | "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", 563 | "requires": { 564 | "psl": "^1.1.28", 565 | "punycode": "^2.1.1" 566 | } 567 | }, 568 | "tunnel-agent": { 569 | "version": "0.6.0", 570 | "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", 571 | "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", 572 | "requires": { 573 | "safe-buffer": "^5.0.1" 574 | } 575 | }, 576 | "tweetnacl": { 577 | "version": "0.14.5", 578 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", 579 | "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" 580 | }, 581 | "uri-js": { 582 | "version": "4.2.2", 583 | "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", 584 | "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", 585 | "requires": { 586 | "punycode": "^2.1.0" 587 | } 588 | }, 589 | "util": { 590 | "version": "0.10.4", 591 | "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", 592 | "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", 593 | "requires": { 594 | "inherits": "2.0.3" 595 | }, 596 | "dependencies": { 597 | "inherits": { 598 | "version": "2.0.3", 599 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 600 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 601 | } 602 | } 603 | }, 604 | "util-deprecate": { 605 | "version": "1.0.2", 606 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 607 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 608 | }, 609 | "uuid": { 610 | "version": "3.4.0", 611 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", 612 | "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" 613 | }, 614 | "verror": { 615 | "version": "1.10.0", 616 | "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", 617 | "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", 618 | "requires": { 619 | "assert-plus": "^1.0.0", 620 | "core-util-is": "1.0.2", 621 | "extsprintf": "^1.2.0" 622 | } 623 | } 624 | } 625 | } 626 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "codeblue", 3 | "main": "./lib/codeblue", 4 | "version": "1.6.0", 5 | "description": "Run and submit solutions of codeforces live contest from your favorite text editor", 6 | "keywords": [ 7 | "coding", 8 | "programming", 9 | "codeforces", 10 | "helper", 11 | "atcoder", 12 | "submission" 13 | ], 14 | "activationCommands": { 15 | "atom-workspace": "codeblue:toggle" 16 | }, 17 | "repository": "https://github.com/blueedgetechno/codeblue", 18 | "license": "MIT", 19 | "engines": { 20 | "atom": ">=1.0.0 <2.0.0" 21 | }, 22 | "dependencies": { 23 | "axios": "^0.19.2", 24 | "cheerio": "^1.0.0-rc.3", 25 | "child_process": "^1.0.2", 26 | "copy-to-clipboard": "^3.3.1", 27 | "fs": "0.0.1-security", 28 | "path": "^0.12.7", 29 | "react": "^16.13.1", 30 | "react-dom": "^16.13.1", 31 | "request": "^2.88.2" 32 | }, 33 | "consumedServices": { 34 | "tree-view": { 35 | "versions": { 36 | "^1.0.0": "consumeTreeView" 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spec/codeblue-spec.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import Codeblue from '../lib/codeblue'; 4 | 5 | // Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. 6 | // 7 | // To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` 8 | // or `fdescribe`). Remove the `f` to unfocus the block. 9 | 10 | describe('Codeblue', () => { 11 | let workspaceElement, activationPromise; 12 | 13 | beforeEach(() => { 14 | workspaceElement = atom.views.getView(atom.workspace); 15 | activationPromise = atom.packages.activatePackage('codeblue'); 16 | }); 17 | 18 | describe('when the codeblue:toggle event is triggered', () => { 19 | it('hides and shows the modal panel', () => { 20 | // Before the activation event the view is not on the DOM, and no panel 21 | // has been created 22 | expect(workspaceElement.querySelector('.codeblue')).not.toExist(); 23 | 24 | // This is an activation event, triggering it will cause the package to be 25 | // activated. 26 | atom.commands.dispatch(workspaceElement, 'codeblue:toggle'); 27 | 28 | waitsForPromise(() => { 29 | return activationPromise; 30 | }); 31 | 32 | runs(() => { 33 | expect(workspaceElement.querySelector('.codeblue')).toExist(); 34 | 35 | let codeblueElement = workspaceElement.querySelector('.codeblue'); 36 | expect(codeblueElement).toExist(); 37 | 38 | // let codebluePanel = atom.workspace.panelForItem(codeblueElement); 39 | // expect(codebluePanel.isVisible()).toBe(true); 40 | // atom.commands.dispatch(workspaceElement, 'codeblue:toggle'); 41 | // expect(codebluePanel.isVisible()).toBe(false); 42 | }); 43 | }); 44 | 45 | it('hides and shows the view', () => { 46 | // This test shows you an integration test testing at the view level. 47 | 48 | // Attaching the workspaceElement to the DOM is required to allow the 49 | // `toBeVisible()` matchers to work. Anything testing visibility or focus 50 | // requires that the workspaceElement is on the DOM. Tests that attach the 51 | // workspaceElement to the DOM are generally slower than those off DOM. 52 | jasmine.attachToDOM(workspaceElement); 53 | 54 | expect(workspaceElement.querySelector('.codeblue')).not.toExist(); 55 | 56 | // This is an activation event, triggering it causes the package to be 57 | // activated. 58 | atom.commands.dispatch(workspaceElement, 'codeblue:toggle'); 59 | 60 | waitsForPromise(() => { 61 | return activationPromise; 62 | }); 63 | 64 | runs(() => { 65 | // Now we can test for view visibility 66 | let codeblueElement = workspaceElement.querySelector('.codeblue'); 67 | expect(codeblueElement).toBeVisible(); 68 | atom.commands.dispatch(workspaceElement, 'codeblue:toggle'); 69 | // expect(codeblueElement).not.toBeVisible(); 70 | }); 71 | }); 72 | }); 73 | }); 74 | -------------------------------------------------------------------------------- /spec/codeblue-view-spec.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import CodeblueView from '../lib/codeblue-view'; 4 | 5 | describe('CodeblueView', () => { 6 | it('has one valid test', () => { 7 | expect('life').toBe('easy'); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /styles/codeblue.less: -------------------------------------------------------------------------------- 1 | @import "ui-variables"; 2 | 3 | ::selection { 4 | background: inherit; 5 | color: inherit; 6 | } 7 | 8 | .codeblue { 9 | width: 100%; 10 | padding: 10px; 11 | height: 92vh; 12 | overflow-y: scroll; 13 | } 14 | 15 | .profile { 16 | display: flex; 17 | justify-content: space-between; 18 | padding: 10px; 19 | 20 | .profiledesc { 21 | display: flex; 22 | 23 | span { 24 | font-size: 1.2em; 25 | font-weight: bold; 26 | margin: auto 10px; 27 | } 28 | } 29 | 30 | .loginerror { 31 | display: flex; 32 | vertical-align: middle; 33 | align-items: center; 34 | 35 | span { 36 | cursor: pointer; 37 | font-weight: bold; 38 | } 39 | 40 | .notLog { 41 | font-weight: bold; 42 | // color: #12d248; 43 | } 44 | 45 | .doLog { 46 | color: #12d248; 47 | } 48 | } 49 | } 50 | 51 | .profile-image { 52 | width: 30px; 53 | height: 30px; 54 | overflow: hidden; 55 | border-radius: 50%; 56 | 57 | img { 58 | position: relative; 59 | height: 30px; 60 | } 61 | } 62 | 63 | .firstrow { 64 | display: flex; 65 | flex-direction: row; 66 | 67 | input[type=text] { 68 | border: none; 69 | padding: 5px; 70 | background: @background-color-selected; 71 | border-radius: 8px; 72 | color: @text-color-subtle; 73 | font-weight: bold; 74 | text-align: center; 75 | } 76 | 77 | button { 78 | border: none; 79 | padding: 0 10px; 80 | font-size: 1.2em; 81 | background: none; 82 | margin: 0; 83 | font-weight: bold; 84 | color: white; 85 | } 86 | } 87 | 88 | .fillup { 89 | width: 100%; 90 | padding: 10px; 91 | display: flex; 92 | flex-direction: column; 93 | align-items: center; 94 | 95 | span { 96 | font-weight: bold; 97 | font-size: 1.1em; 98 | color: @text-color; 99 | padding: 5px; 100 | margin-right: 10px; 101 | } 102 | 103 | .tips{ 104 | display: flex; 105 | flex-direction: column; 106 | align-items: center; 107 | 108 | i{ 109 | color: #d1a915; 110 | } 111 | 112 | h3{ 113 | margin: 5px auto; 114 | font-weight: bolder; 115 | text-decoration: underline; 116 | } 117 | 118 | ul{ 119 | line-height: 18px; 120 | 121 | li{ 122 | margin: 10px auto; 123 | } 124 | } 125 | } 126 | 127 | .customisation{ 128 | display: flex; 129 | flex-direction: column; 130 | margin-top: 10px; 131 | line-height: 30px; 132 | 133 | .initoption{ 134 | display: flex; 135 | flex-direction: row; 136 | align-items: center; 137 | 138 | span{ 139 | font-weight: 500; 140 | } 141 | } 142 | } 143 | 144 | input[type=checkbox] { 145 | -webkit-appearance: none; 146 | background: none; 147 | width: 12pt; 148 | height: 12pt; 149 | // padding: 2px 0 0 3px; 150 | // margin: 20px 10px 25px 60px; 151 | // vertical-align: middle; 152 | border: 1.5px solid @text-color; 153 | border-radius: 50%; 154 | outline: none; 155 | cursor: pointer; 156 | } 157 | 158 | input[type=checkbox]:checked { 159 | background: #0e45c1; 160 | } 161 | 162 | button[id=submit] { 163 | border: none; 164 | padding: 10px; 165 | font-size: 1.2em; 166 | background: #22b982; 167 | margin: 40px auto; 168 | font-weight: bold; 169 | border-radius: 18px; 170 | color: #f2f2f2; 171 | } 172 | } 173 | 174 | .timer { 175 | display: flex; 176 | flex-direction: column; 177 | align-items: center; 178 | line-height: 50px; 179 | font-size: 24px; 180 | font-weight: bold; 181 | margin-top: 20px; 182 | } 183 | 184 | .waiting { 185 | display: flex; 186 | flex-direction: column; 187 | 188 | button { 189 | border: none; 190 | width: 100px; 191 | padding: 10px; 192 | margin: 25px auto auto; 193 | border-radius: 10px; 194 | background: #0084b4; 195 | font-size: 1.4em; 196 | font-weight: bold; 197 | color: #fff; 198 | } 199 | } 200 | 201 | .gamelist { 202 | width: 100%; 203 | display: flex; 204 | justify-content: space-around; 205 | padding: 25px 0 0; 206 | 207 | span { 208 | cursor: pointer; 209 | font-size: 1.4em; 210 | font-weight: 600; 211 | padding: 2px 3px; 212 | border-radius: 5px; 213 | text-align: center; 214 | transition: 0.3s; 215 | } 216 | 217 | span:hover { 218 | background: @background-color-selected; 219 | transition: 0.3s; 220 | } 221 | } 222 | 223 | .headinfo { 224 | i { 225 | color: #d1a915; 226 | cursor: pointer; 227 | } 228 | 229 | span { 230 | position: absolute; 231 | padding: 5px 10px; 232 | font-weight: bold; 233 | top: 46px; 234 | right: 10px; 235 | cursor: pointer; 236 | } 237 | } 238 | 239 | .refreshproblems { 240 | position: absolute; 241 | border: none; 242 | padding: 0; 243 | width: 30px; 244 | height: 30px; 245 | border-radius: 50%; 246 | font-weight: bold; 247 | top: 21px; 248 | left: 20px; 249 | opacity: 0; 250 | } 251 | 252 | .refreshsubmissions { 253 | position: absolute; 254 | border: none; 255 | background: @background-color-selected; //#383f4b; 256 | padding: 5px 10px; 257 | border-radius: 5px; 258 | font-weight: bold; 259 | top: 20px; 260 | right: 10px; 261 | } 262 | 263 | .standings { 264 | width: 100%; 265 | overflow-x: scroll; 266 | } 267 | 268 | .fredhead * { 269 | background: @background-color-highlight; 270 | border-radius: 2px; 271 | } 272 | 273 | .friendslist * { 274 | padding: 2px; 275 | margin: 1px; 276 | font-weight: bold; 277 | text-align: center; 278 | } 279 | 280 | .fredhead, 281 | .friend { 282 | width: max-content; 283 | display: flex; 284 | } 285 | 286 | .rank { 287 | width: 45px; 288 | } 289 | 290 | .friendid { 291 | width: 80px; 292 | } 293 | 294 | .cmaster { 295 | color: #f957f9; 296 | } 297 | 298 | .expert { 299 | color: #377df9; 300 | } 301 | 302 | .specialist { 303 | color: #59f6ec; 304 | } 305 | 306 | .pupil { 307 | color: #72f972; 308 | } 309 | 310 | .newbie { 311 | color: #968e81; 312 | } 313 | 314 | .probcell { 315 | width: 45px; 316 | font-weight: 900; 317 | } 318 | 319 | .alpha { 320 | color: #1e76fa; 321 | } 322 | 323 | .correct { 324 | color: #11c84c; 325 | } 326 | 327 | .incorrectattempt { 328 | color: #908d8d; 329 | } 330 | 331 | .incorrectsol { 332 | color: #f13d4f; 333 | } 334 | 335 | .problems { 336 | width: 100%; 337 | display: flex; 338 | flex-direction: column; 339 | } 340 | 341 | .prob { 342 | padding: 15px 8px; 343 | // margin: 5px 0; 344 | font-size: 1.1em; 345 | display: flex; 346 | justify-content: flex-start; 347 | border-radius: 8px; 348 | cursor: pointer; 349 | 350 | span { 351 | width: 45%; 352 | padding-right: 10px; 353 | font-weight: bold; 354 | } 355 | } 356 | 357 | .prob:nth-child(even) { 358 | background-color: @background-color-selected; //#373c44; 359 | } 360 | 361 | .totsub { 362 | width: 75px !important; 363 | color: #328bff; 364 | } 365 | 366 | .accepted { 367 | font-size: 0.8em; 368 | height: 23px; 369 | color: #fff; 370 | background: #04a63a; 371 | font-weight: bold; 372 | margin-left: 10px; 373 | padding: 4px; 374 | border-radius: 8px; 375 | } 376 | 377 | .wrong { 378 | font-size: 0.8em; 379 | height: 23px; 380 | width: 80px; 381 | text-align: center; 382 | color: #fff; 383 | font-weight: bold; 384 | margin-left: 10px; 385 | background: #cb0000; 386 | padding: 4px; 387 | border-radius: 8px; 388 | } 389 | 390 | .tle { 391 | font-size: 0.8em; 392 | height: 23px; 393 | width: 80px; 394 | text-align: center; 395 | color: #fff; 396 | background: #de8d00; 397 | font-weight: bold; 398 | margin-left: 10px; 399 | padding: 4px; 400 | border-radius: 8px; 401 | } 402 | 403 | .mle { 404 | font-size: 0.8em; 405 | height: 23px; 406 | width: 80px; 407 | text-align: center; 408 | color: #fff; 409 | background: #b300de; 410 | font-weight: bold; 411 | margin-left: 10px; 412 | padding: 4px; 413 | border-radius: 8px; 414 | } 415 | 416 | .runtime { 417 | font-size: 0.8em; 418 | height: 23px; 419 | width: 80px; 420 | text-align: center; 421 | color: #fff; 422 | background: #af4827; 423 | font-weight: bold; 424 | margin-left: 10px; 425 | padding: 4px; 426 | border-radius: 8px; 427 | } 428 | 429 | .loader { 430 | border: 16px solid #505053; 431 | border-top: 16px solid #1989d4; 432 | border-radius: 50%; 433 | width: 100px; 434 | height: 100px; 435 | margin-left: 90px; 436 | margin-top: 100px; 437 | animation: spin 2s linear infinite; 438 | } 439 | @keyframes spin { 440 | 0% { 441 | transform: rotate(0deg); 442 | } 443 | 444 | 100% { 445 | transform: rotate(360deg); 446 | } 447 | } 448 | 449 | .queue, 450 | .queue:after, 451 | .queue:before { 452 | border-radius: 50%; 453 | width: 10px; 454 | height: 10px; 455 | -webkit-animation-fill-mode: both; 456 | animation-fill-mode: both; 457 | -webkit-animation: load7 1.8s infinite ease-in-out; 458 | animation: load7 1.8s infinite ease-in-out; 459 | } 460 | 461 | .queue { 462 | color: #ffffff; 463 | margin-top: -18px; 464 | left: 35px; 465 | position: relative; 466 | transform: translateZ(0); 467 | animation-delay: -0.16s; 468 | } 469 | 470 | .queue:after, 471 | .queue:before { 472 | content: ''; 473 | position: absolute; 474 | top: 0; 475 | } 476 | 477 | .queue:before { 478 | left: -15px; 479 | animation-delay: -0.32s; 480 | } 481 | 482 | .queue:after { 483 | left: 15px; 484 | } 485 | @-webkit-keyframes load7 { 486 | 0%, 487 | 100%, 488 | 80% { 489 | box-shadow: 0 23px 0 -12px; 490 | } 491 | 492 | 40% { 493 | box-shadow: 0 23px 0 0; 494 | } 495 | } 496 | @keyframes load7 { 497 | 0%, 498 | 100%, 499 | 80% { 500 | box-shadow: 0 23px 0 -12px; 501 | } 502 | 503 | 40% { 504 | box-shadow: 0 23px 0 0; 505 | } 506 | } 507 | 508 | .actions { 509 | display: flex; 510 | flex-direction: column; 511 | } 512 | 513 | .addoption { 514 | width: 100%; 515 | display: flex; 516 | justify-content: space-between; 517 | } 518 | 519 | .igcasediv { 520 | width: 85px; 521 | margin: 5px 5px 10px; 522 | display: flex; 523 | justify-content: space-between; 524 | align-items: center; 525 | 526 | input[type=checkbox] { 527 | -webkit-appearance: none; 528 | display: block; 529 | margin: 2px 0 0; 530 | background: none; 531 | border: 1.5px solid @text-color; 532 | width: 13px; 533 | height: 13px; 534 | border-radius: 50%; 535 | outline: none; 536 | cursor: pointer; 537 | } 538 | 539 | input[type=checkbox]:checked { 540 | background: #1351de; 541 | } 542 | 543 | span { 544 | font-weight: bold; 545 | color: #178eeb; 546 | } 547 | } 548 | 549 | .tasks { 550 | display: flex; 551 | flex-direction: column; 552 | } 553 | 554 | .task { 555 | display: flex; 556 | flex-direction: column; 557 | } 558 | 559 | .up { 560 | display: flex; 561 | justify-content: space-between; 562 | padding: 5px; 563 | 564 | span { 565 | font-size: 1.2em; 566 | font-weight: bold; 567 | cursor: pointer; 568 | } 569 | 570 | button { 571 | border: none; 572 | background: @background-color-selected; //#383f4b; 573 | padding: 5px 10px; 574 | border-radius: 5px; 575 | font-weight: bold; 576 | } 577 | } 578 | 579 | .realsubmit { 580 | background: #188330 !important; 581 | color: #fff; 582 | } 583 | 584 | .cancel { 585 | background: #a11c18 !important; 586 | color: #fff; 587 | } 588 | 589 | .down { 590 | display: none; 591 | flex-direction: column; 592 | padding: 5px 10px; 593 | transition: 1s; 594 | } 595 | 596 | .verdict { 597 | display: flex; 598 | flex-direction: column; 599 | } 600 | 601 | .errordetails { 602 | display: block; 603 | 604 | pre { 605 | font-weight: bold; 606 | color: @text-color; 607 | } 608 | } 609 | 610 | .comparision { 611 | display: flex; 612 | flex-direction: row; 613 | margin-bottom: 5px; 614 | } 615 | 616 | .outbox { 617 | width: 50%; 618 | margin: 1px; 619 | 620 | pre { 621 | background: @background-color-highlight; 622 | height: 100%; 623 | color: #ff6262; 624 | } 625 | } 626 | 627 | .outbox:first-child { 628 | pre { 629 | color: #00d708; 630 | } 631 | } 632 | 633 | .show-verdict { 634 | display: flex; 635 | cursor: pointer; 636 | flex-direction: row; 637 | justify-content: space-between; 638 | padding: 5px; 639 | margin: 1px 0; 640 | background: @background-color-selected; //#191c20; 641 | border-radius: 4px; 642 | 643 | span { 644 | font-size: 1.2em; 645 | font-weight: bold; 646 | } 647 | } 648 | 649 | .icon-check { 650 | color: #00ba29; 651 | } 652 | 653 | .icon-x { 654 | color: #d7282d; 655 | } 656 | 657 | .icon-clock { 658 | color: #d1b330; 659 | } 660 | 661 | .icon-hourglass { 662 | color: #0ab3d4; 663 | } 664 | 665 | .icon-alert { 666 | color: #ee7411; 667 | } 668 | 669 | .icon-stop { 670 | color: #e93961; 671 | } 672 | 673 | .icon-database { 674 | color: #b553e4; 675 | } 676 | 677 | .icon-light-bulb { 678 | color: #d1a915; 679 | } 680 | 681 | .icon-flame { 682 | color: #ffef15; 683 | } 684 | 685 | .action-view { 686 | display: flex; 687 | flex-direction: row; 688 | padding: 5px; 689 | margin: 1px 0; 690 | background: @background-color-highlight; 691 | 692 | i { 693 | width: 15%; 694 | font-style: normal; 695 | font-weight: bold; 696 | text-align: center; 697 | vertical-align: middle; 698 | word-spacing: 5px; 699 | } 700 | 701 | span { 702 | font-size: 1.2em; 703 | color: @text-color-subtle; //#bbb; 704 | font-weight: bold; 705 | } 706 | 707 | span:nth-child(1) { 708 | margin-left: 5px; 709 | width: 20%; 710 | } 711 | 712 | span:nth-child(3) { 713 | width: 30%; 714 | padding: 0 25px; 715 | text-align: left; 716 | } 717 | 718 | span:nth-child(4) { 719 | width: 30%; 720 | text-align: right; 721 | } 722 | } 723 | 724 | .icon-chevron-down { 725 | cursor: pointer; 726 | } 727 | 728 | .icon-chevron-right { 729 | cursor: pointer; 730 | } 731 | 732 | .titlename { 733 | color: #1abc9c; 734 | } 735 | // Play section 736 | 737 | .container { 738 | width: 100%; 739 | } 740 | 741 | .page { 742 | position: relative; 743 | top: 10px; 744 | } 745 | 746 | .puzzle { 747 | width: 280px; 748 | height: 280px; 749 | display: flex; 750 | justify-content: space-between; 751 | flex-direction: row; 752 | flex-wrap: wrap; 753 | /* flex-wrap: wrap; */ 754 | } 755 | 756 | .piece { 757 | width: 33%; 758 | height: 33%; 759 | background: inherit; 760 | // background: url("https://images.unsplash.com/photo-1559633657-c3008b46bac6?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1100&q=80"); 761 | background-size: 280px; 762 | } 763 | 764 | .finalimage img { 765 | width: 280px; 766 | height: 280px; 767 | } 768 | 769 | .p1 { 770 | background-position: 0 0; 771 | } 772 | 773 | .p2 { 774 | background-position: 50% 0 !important; 775 | } 776 | 777 | .p3 { 778 | background-position: 100% 0 !important; 779 | } 780 | 781 | .p4 { 782 | background-position: 0 50% !important; 783 | } 784 | 785 | .p5 { 786 | background-position: 50% 50% !important; 787 | } 788 | 789 | .p6 { 790 | background-position: 100% 50% !important; 791 | } 792 | 793 | .p7 { 794 | background-position: 0 100% !important; 795 | } 796 | 797 | .p8 { 798 | background-position: 50% 100% !important; 799 | } 800 | 801 | .p9 { 802 | background-position: 100% 100% !important; 803 | opacity: 0; 804 | } 805 | 806 | .nextbutton { 807 | padding: 0 !important; 808 | width: 50px !important; 809 | height: 30px !important; 810 | font-size: 1em !important; 811 | margin: 0; 812 | transform: translate(120px,-6px); 813 | } 814 | 815 | .copied { 816 | animation: pop 0.3s linear; 817 | transition: 0.3s; 818 | } 819 | @keyframes pop { 820 | 0% { 821 | transform: scale(1) translateZ(0); 822 | } 823 | 824 | 50% { 825 | transform: scale(1.1) translateZ(0); 826 | } 827 | 828 | 100% { 829 | transform: scale(1) translateZ(0); 830 | } 831 | } 832 | 833 | .square { 834 | width: 33.33%; 835 | height: 33.33%; 836 | background: inherit; 837 | border-width: 2px; 838 | border-color: @text-color; 839 | border-style: solid; 840 | } 841 | 842 | .square:nth-child(1) { 843 | border-width: 0 2px 2px 0; 844 | } 845 | 846 | .square:nth-child(2) { 847 | border-width: 0 2px 2px 2px; 848 | } 849 | 850 | .square:nth-child(3) { 851 | border-width: 0 0 2px 2px; 852 | } 853 | 854 | .square:nth-child(4) { 855 | border-width: 2px 2px 2px 0; 856 | } 857 | 858 | .square:nth-child(6) { 859 | border-width: 2px 0 2px 2px; 860 | } 861 | 862 | .square:nth-child(7) { 863 | border-width: 2px 2px 0 0; 864 | } 865 | 866 | .square:nth-child(8) { 867 | border-width: 2px 2px 0 2px; 868 | } 869 | 870 | .square:nth-child(9) { 871 | border-width: 2px 0 0 2px; 872 | } 873 | 874 | .cross::after { 875 | content: ""; 876 | position: absolute; 877 | width: 5px; 878 | height: 28%; 879 | margin: 2% 15%; 880 | transform: rotate(45deg); 881 | background: @text-color; 882 | } 883 | 884 | .cross::before { 885 | content: ""; 886 | position: absolute; 887 | width: 5px; 888 | height: 28%; 889 | margin: 2% 15%; 890 | transform: rotate(-45deg); 891 | background: @text-color; 892 | z-index: 1; 893 | } 894 | 895 | .circle::before { 896 | content: ""; 897 | position: absolute; 898 | width: 25%; 899 | height: 22%; 900 | margin: 3.5% 4%; 901 | border: 5px solid @text-color; 902 | border-radius: 50%; 903 | } 904 | 905 | .score { 906 | width: 100%; 907 | text-align: right; 908 | padding: 5px; 909 | font-size: 1.5em; 910 | } 911 | 912 | button[disabled]{ 913 | color: @text-color-subtle; 914 | cursor: not-allowed; 915 | // pointer-events: none; 916 | } 917 | --------------------------------------------------------------------------------