forked from Sulagna-Dutta-Roy/GGExtensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68a457c
commit d5b3769
Showing
6 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
# Project Name | ||
code Compiler | ||
|
||
## Steps to Run | ||
|
||
### Step 1: Clone the Repository | ||
Clone this repository to your local machine using the following command: | ||
``` | ||
git clone <repository-url> | ||
``` | ||
|
||
### Step 2: Install Dependencies | ||
Navigate to the project directory and install the necessary dependencies by running: | ||
``` | ||
cd code compiler | ||
npm install | ||
``` | ||
|
||
### Step 3: Start the Server | ||
Run the following command to start the server: | ||
``` | ||
node server.js | ||
``` | ||
|
||
### Step 4: Load Extension | ||
[Insert instructions on how to load the extension] | ||
|
||
## Dependencies | ||
- Express | ||
- Axios | ||
- Cors | ||
- Body-parser | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// background.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Online Compiler", | ||
"description": "Compile and run Java, C++, and Python code.", | ||
"version": "1.0", | ||
"action": { | ||
"default_popup": "popup.html" | ||
|
||
}, | ||
"permissions": ["storage"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Online Compiler</title> | ||
<!-- Bootstrap CSS --> | ||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
padding-top: 20px; | ||
} | ||
#code { | ||
width: 100%; | ||
height: 200px; | ||
margin-bottom: 15px; | ||
} | ||
#output { | ||
white-space: pre; | ||
background: #f8f9fa; | ||
padding: 15px; | ||
border: 1px solid #ced4da; | ||
border-radius: 5px; | ||
min-height: 100px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container" style="width: 500px; height: fit-content;"> | ||
<h1 class="mb-4">Online Compiler</h1> | ||
<div class="form-group"> | ||
<label for="language">Select Language</label> | ||
<select class="form-control" id="language"> | ||
<option value="java">Java</option> | ||
<option value="cpp">C++</option> | ||
<option value="python">Python</option> | ||
</select> | ||
</div> | ||
<div class="form-group"> | ||
<label for="code">Code</label> | ||
<textarea class="form-control" id="code" rows="10">print("Hello, World!")</textarea> | ||
</div> | ||
<button class="btn btn-primary mb-4" id="run">Run</button> | ||
<h2>Output</h2> | ||
<div id="output"></div> | ||
</div> | ||
|
||
<!-- Bootstrap JS and dependencies --> | ||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> | ||
<script src="popup.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
document.getElementById('run').addEventListener('click', function () { | ||
var code = document.getElementById('code').value; | ||
var language = document.getElementById('language').value; | ||
compileAndRunCode(language, code); | ||
}); | ||
|
||
function compileAndRunCode(language, code) { | ||
var url = 'http://localhost:3000/execute'; // Proxy server URL | ||
|
||
var payload = { | ||
script: code, | ||
language: language, | ||
versionIndex: '0' | ||
}; | ||
|
||
fetch(url, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify(payload) | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
document.getElementById('output').textContent = data.output; | ||
}) | ||
.catch(error => { | ||
document.getElementById('output').textContent = 'Error: ' + error; | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const express = require('express'); | ||
const axios = require('axios'); | ||
const bodyParser = require('body-parser'); | ||
const cors = require('cors'); | ||
|
||
const app = express(); | ||
|
||
const CLIENT_ID = '8c012c7168f33b12a2d2a91597e46402'; | ||
const CLIENT_SECRET = '9e394a35e755bc9a4cb515a243d48e54d4f24826b4f545d996438829a42c333b'; | ||
|
||
app.use(bodyParser.json()); | ||
app.use(cors()); | ||
|
||
app.post('/execute', async (req, res) => { | ||
const { script, language, versionIndex } = req.body; | ||
|
||
try { | ||
const response = await axios.post('https://api.jdoodle.com/v1/execute', { | ||
script: script, | ||
language: language, | ||
versionIndex: versionIndex, | ||
clientId: CLIENT_ID, | ||
clientSecret: CLIENT_SECRET, | ||
}, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
console.log(response.data) | ||
res.json(response.data); | ||
} catch (error) { | ||
res.status(500).json({ error: 'Error fetching data from JDoodle API' }); | ||
} | ||
}); | ||
|
||
const PORT = process.env.PORT || 3000; | ||
app.listen(PORT, () => { | ||
console.log(`Server is running on port ${PORT}`); | ||
}); |