-
Notifications
You must be signed in to change notification settings - Fork 192
/
ide.html
306 lines (272 loc) · 13.1 KB
/
ide.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/ide_style.css" />
<!--Fontasome CDN-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css">
<!--Bootstarp CDN-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- style.css For Custom Styling -->
<link rel="stylesheet" href="css/style.css">
<link rel="apple-touch-icon" sizes="180x180" href="favicon_package\apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon_package\favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon_package\favicon-16x16.png">
<link rel="manifest" href="favicon_package\site.webmanifest">
<link rel="mask-icon" href="favicon_package\safari-pinned-tab.svg" color="#3caea3">
<meta name="msapplication-TileColor" content="#2b5797">
<meta name="theme-color" content="#ffffff">
<script src="https://kit.fontawesome.com/bd43ee06c8.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous">
</script>
<title>IDE</title>
<style>
body {
background-color: #3caea3;
margin: 10px 10px 10px 10px;
}
.button1 {
color: black;
font-size: medium;
border-radius: 8px;
}
</style>
</head>
<body>
<section>
<nav class="navbar navbar-expand-lg navbar-dark fixed-top nav-col top">
<a class="navbar-brand" href="index.html"><img src="images/icon.png" alt="Algo Phantoms" width="50"
height="50"><span class="brand1">Algo</span>Phantoms
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link font-weight-bold nav-items" href="index.html">Home </a>
</li>
<li class="nav-item">
<a class="nav-link font-weight-bold nav-items" href="index.html#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link font-weight-bold nav-items" href="team.html">Team<span
class="sr-only">(current)</span></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link font-weight-bold nav-items dropdown-toggle" href="#" id="navbarDropdown"
role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
More
</a>
<div class="dropdown-menu dropdown-menu-center" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="DSA.html">RoadMap to your DSA</a>
<a class="dropdown-item" href="https://github.com/Algo-Phantoms" target="_blank">Contribute
to Project</a>
<a class="dropdown-item" href="practicedsa.html">DSA Problems</a>
</div>
<li class="nav-item">
<a class="nav-link font-weight-bold nav-items" href="#footer">Contact</a>
</li>
</ul>
</div>
</nav>
<script>
const navbar = document.getElementsByTagName("nav")[0];
let scrolled = false;
window.onscroll = function () {
if (window.pageYOffset > 100) {
navbar.classList.remove("top");
if (!scrolled) {
navbar.style.transform = "translateY(-70px)";
}
setTimeout(function () {
navbar.style.transform = 'translateY(0)';
scrolled = true;
}, 200);
} else {
navbar.classList.add("top");
scrolled = false;
}
};
</script>
</section>
<div id="test">
<div class="control-panel">
Select Language:
<select id="languages" class="languages" onchange="changeLanguage()">
<option value="c"> C </option>
<option value="cpp"> C++ </option>
<option value="java"> Java </option>
<option value="python"> Python </option>
</select>
</div>
<div class="editor" id="editor"></div>
<div class="button-container">
<button class="btn" onclick="executeCode()"> Run </button>
</div>
<textarea id="input" placeholder="Inputs" class="input" rows="4" cols="50"></textarea>
<br><br>
<div class="output" aria-placeholder="kn"></div>
</div>
<!--footer starts-->
<footer id="footer">
<div class="container">
<div class="row subscribe-box py-5">
<div class="col-lg-4 col-md-4 col-sm-12 col-12 offset-lg-1">
<h2 class="text-white font-weight-bold py-2">Contact Us</h2>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">
<form action="mailto:[email protected]">
<div class="input-group">
<input type="email" class="form-control py-3" placeholder="Enter your Email" required>
<div class="input-group-append">
<button type="submit"
class="input-group-text subscribe-button text-white px-5 font-weight-bold">
Contact Us
</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="container mt-5 pt-lg-5">
<div class="row">
<div class="col-md-3 col-sm-6 col-lg-3 col-12">
<div class="">
<img src="images/icon.png" alt="" class="img-fluid mb-lg-4" width="100px" height="100px">
</div>
<p class="text-white">An Open Source organization focuses on Data Structure and Algorithms.</p>
</div>
<div class="col-lg-2 col-md-2 col-sm-6 col-12 offset-lg-1">
<h5 class="font-weight-bold text-white mb-lg-4 pb-2 margin-top-mobile">Useful Links</h5>
<ul>
<a class="text-white mb-lg-3" href="index.html#about">About</a><br>
<a class="text-white mb-lg-3" href="team.html">Our Team</a><br>
<a class="text-white mb-lg-3" href="#footer">Contact</a><br>
<a class="text-white mb-lg-3" href="./sitemap.html">SiteMap</a>
</ul>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-12">
<h5 class="font-weight-bold text-white mb-lg-4 pb-2 margin-top-mobile">Features</h5>
<ul>
<a class="text-white mb-lg-3" href="https://www.codechef.com/ide" target="_blank">Code
Editor</a><br>
<a class="text-white mb-lg-3" href="https://www.geeksforgeeks.org/data-structure-gq/"
target="_blank">Quizzes</a><br>
<a class="text-white mb-lg-3" href="https://github.com/Algo-Phantoms/Algo-Tree"
target="_blank">DSA Guidance</a><br>
<a class="text-white mb-lg-3" href="https://dare2compete.com/"
target="_blank">Opportunities<a><br>
<a class="text-white mb-lg-3"
href="https://www.geeksforgeeks.org/computer-science-projects/?ref=shm"
target="_blank">Project Ideas</a><br>
<a class="text-white mb-lg-3" href="DSA.html">RoadMap to your DSA</a><br>
<a class="text-white mb-lg-3" href="practicedsa.html">DSA Problems</a><br>
</ul>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-12 socialicons">
<h5 class="font-weight-bold text-white mb-lg-4 pb-2 margin-top-mobile">Follow Us</h5>
<a href="https://github.com/Algo-Phantoms" target="_blank"><i class="fa fa-github p-2 socialicon"
aria-hidden="true"></i>
</a>
<a href="#" target="_blank"><i class="fa fa-instagram p-2 socialicon" aria-hidden="true"></i>
</a>
<a href="#" target="_blank"><i class="fa fa-linkedin p-2 socialicon" aria-hidden="true"></i>
</a>
<a href="#" target="_blank"><i class="fa fa-twitter p-2 socialicon" aria-hidden="true"></i>
</a>
</div>
</div>
<hr style="background: white;" class="mt-5">
<div class="text-center text-white mt-lg-4 pt-lg-2 copyright-text">
Copyright © 2021 <a href="#" style="color: #3caea3; text-decoration: none;" target="_blank"><span
class="font-weight-bold">AlgoPhantoms.</span></a> All Rights Reserved</div>
</div>
</footer>
<!--footer ends-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="js/lib/ace.js"></script>
<script src="js/lib/theme-monokai.js"></script>
<script>
let editor;
var request = require('request');
window.onload = function () {
editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/c_cpp");
}
function changeLanguage() {
let language = $("#languages").val();
if (language == 'c' || language == 'cpp') editor.session.setMode("ace/mode/c_cpp");
else if (language == 'java') editor.session.setMode("ace/mode/java");
else if (language == 'python') editor.session.setMode("ace/mode/python");
}
function fetchOutput(token) {
$.ajax({
type: "GET",
async: true,
crossDomain: true,
url: `https://judge0-ce.p.rapidapi.com/submissions/${token}?base64_encoded=true&fields=`,
headers: {
"content-type": "application/json",
"x-rapidapi-key": "API_KEY",
"x-rapidapi-host": "judge0-ce.p.rapidapi.com"
},
success: function (data) {
$(".output").text(base64Decode(data.stdout))
}
})
}
var languageId = {
"C": 50,
"C++": 54,
"Java": 62,
"Python": 71
};
function base64Encode(str) {
return btoa(unescape(encodeURIComponent(str || "")));
}
function base64Decode(bytes) {
var escaped = escape(atob(bytes || ""));
try {
return decodeURIComponent(escaped);
} catch {
return unescape(escaped);
}
}
function executeCode() {
let lang = $("#languages").val().trim();
let input = $("#input").val();
let code = editor.getSession().getValue()
var dataJSON = JSON.stringify({
"source_code": base64Encode(code),
"language_id": 71,
"stdin": base64Encode(input)
})
$.ajax({
type: "POST",
async: true,
crossDomain: true,
url: "https://judge0-ce.p.rapidapi.com/submissions?base64_encoded=true&fields=*",
headers: {
"content-type": "application/json",
"x-rapidapi-key": "API_KEY",
"x-rapidapi-host": "judge0-ce.p.rapidapi.com"
},
data: dataJSON,
success: function (data) {
fetchOutput(data["token"])
}
})
}
</script>
</body>
</html>