Skip to content

Commit f79e30a

Browse files
committed
fixed bug
1 parent f5d51ee commit f79e30a

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

src/App.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ function App() {
2121
const [input, setInput] = useState('');
2222
const [output, setOutput] = useState('');
2323
const [python, setpython] = useState('');
24+
const [cpp, setcpp] = useState('');
25+
const [java, setjava] = useState('');
26+
const [js, setjs] = useState('');
27+
const [pascal, setpascal] = useState('');
28+
const [perl, setperl] = useState('');
29+
const [php, setphp] = useState('');
30+
const [ruby, setruby] = useState('');
2431
const [modal, setModal] = useState(false);
2532
const [docId, setDocId] = useState(null);
2633
const [isDocId, setIsDocId] = useState(false);
@@ -67,10 +74,35 @@ function App() {
6774

6875
var lang = selected;
6976
const backend_url = process.env.REACT_APP_BACKEND_ENDPOINT_URL + "/runcode";
70-
77+
var source = "print(1)";
78+
if (lang === "python") {
79+
source = python;
80+
}
81+
else if (lang === "cpp") {
82+
source = cpp;
83+
}
84+
else if (lang === "java") {
85+
source = java;
86+
}
87+
else if (lang === "javascript") {
88+
source = js;
89+
}
90+
else if (lang === "pascal") {
91+
source = pascal;
92+
}
93+
else if (lang === "perl") {
94+
source = perl;
95+
}
96+
else if (lang === "php") {
97+
source = php;
98+
}
99+
else if (lang === "ruby") {
100+
source = ruby;
101+
}
102+
if (lang === "javascript") lang = "javascript_node";
71103
var data = {
72104
"lang": lang.toUpperCase(),
73-
"source": python,
105+
"source": source,
74106
"input": input,
75107
"memory_limit": 243232,
76108
"time_limit": 5,
@@ -165,7 +197,7 @@ function App() {
165197
isDocId ?
166198
<>
167199
<Header userInfo={user} runCode={runCode} isAuthenticated={isAuthenticated} toggleModal={toggleModal} isInputBoxShown={isInputBoxShown} setisInputBoxShown={setisInputBoxShown} />
168-
<IDE docId={docId} modal={modal} toggleModal={toggleModal} setModal={setModal} python={python} setpython={setpython} input={input} setInput={setInput} selected={selected} setSelected={setSelected} output={output} setOutput={setOutput} textEditor={textEditor} setTextEditor={setTextEditor} processing={processing} setProcessing={setProcessing} percentageStage={percentageStage} setPercentageStage={setPercentageStage} isInputBoxShown={isInputBoxShown} />
200+
<IDE docId={docId} modal={modal} java={java} setjava={ setjava } toggleModal={toggleModal} setModal={setModal} cpp={cpp} setcpp={setcpp} js={js} setjs={setjs} php={php} setphp={setphp} perl={perl} setperl={setperl} ruby={ruby} setruby={setruby} pascal={pascal} setpascal={ setpascal} python={python} setpython={setpython} input={input} setInput={setInput} selected={selected} setSelected={setSelected} output={output} setOutput={setOutput} textEditor={textEditor} setTextEditor={setTextEditor} processing={processing} setProcessing={setProcessing} percentageStage={percentageStage} setPercentageStage={setPercentageStage} isInputBoxShown={isInputBoxShown} />
169201
</>
170202
:
171203
<Preview docId={docId} />

src/components/IDE.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,9 @@ import { Tabs, TabList, TabPanels, Tab, TabPanel, Skeleton, Progress, Tag } from
2727
import 'react-circular-progressbar/dist/styles.css';
2828

2929

30-
export default function IDE({ docId, modal, toggleModal, python, setpython, input, setInput, selected, setSelected, output, textEditor, setTextEditor, processing, percentageStage, isInputBoxShown, setOutput }) {
30+
export default function IDE({ docId, modal, toggleModal, cpp, setcpp, java, setjava, js, setjs, php, setphp, pascal, setpascal, perl, setperl, ruby, setruby, python, setpython, input, setInput, selected, setSelected, output, textEditor, setTextEditor, processing, percentageStage, isInputBoxShown, setOutput }) {
3131
const [socket, setSocket] = useState(null);
32-
const [cpp, setcpp] = useState('');
33-
const [java, setjava] = useState('');
34-
const [js, setjs] = useState('');
35-
const [pascal, setpascal] = useState('');
36-
const [perl, setperl] = useState('');
37-
const [php, setphp] = useState('');
38-
const [ruby, setruby] = useState('');
32+
3933
const [peer, setPeer] = useState(null);
4034
const userName = 'smit'
4135
const videoGrid = document.getElementById('video-grid');
@@ -597,7 +591,7 @@ export default function IDE({ docId, modal, toggleModal, python, setpython, inpu
597591
/>
598592
}
599593
{
600-
selected === 'js' && <CodeMirror
594+
selected === 'javascript' && <CodeMirror
601595
value={
602596
js
603597
}
@@ -793,7 +787,7 @@ function LanguageSelector({ language, setLanguage }) {
793787
<option className="bg-theme-dark-blue" value="cpp">cpp</option>
794788
<option className="bg-theme-dark-blue" value="python">python</option>
795789
<option className="bg-theme-dark-blue" value="java">java</option>
796-
<option className="bg-theme-dark-blue" value="js">js</option>
790+
<option className="bg-theme-dark-blue" value="javascript">javascript</option>
797791
<option className="bg-theme-dark-blue" value="perl">perl</option>
798792
<option className="bg-theme-dark-blue" value="php">php</option>
799793
<option className="bg-theme-dark-blue" value="ruby">ruby</option>

0 commit comments

Comments
 (0)