forked from Open-Source-you/Hackotberfest2025
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndex.html
More file actions
95 lines (79 loc) · 1.85 KB
/
Index.html
File metadata and controls
95 lines (79 loc) · 1.85 KB
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
1. HTML (editor structure)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Code Editor</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="editor-container">
<h1>Simple Code Editor</h1>
<textarea id="code" placeholder="Write your code here..."></textarea>
<button id="runBtn">Run Code</button>
<h2>Output:</h2>
<pre id="output"></pre>
</div>
<script src="script.js"></script>
</body>
</html>
---
2. CSS (editor styling)
/* style.css */
body {
font-family: 'Courier New', monospace;
background-color: #1e1e1e;
color: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.editor-container {
width: 80%;
max-width: 900px;
}
textarea {
width: 100%;
height: 300px;
background-color: #252526;
color: #d4d4d4;
border: none;
padding: 10px;
font-size: 16px;
resize: vertical;
}
button {
margin-top: 10px;
padding: 10px 20px;
background-color: #0e639c;
color: white;
border: none;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #1177bb;
}
pre {
background-color: #252526;
padding: 10px;
min-height: 100px;
white-space: pre-wrap;
word-wrap: break-word;
}
---
3. JavaScript (run JS code)
// script.js
document.getElementById("runBtn").addEventListener("click", () => {
const code = document.getElementById("code").value;
const output = document.getElementById("output");
try {
const result = eval(code); // Runs JavaScript code
output.textContent = result !== undefined ? result : "Code executed!";
} catch (err) {
output.textContent = "Error: " + err;
}
});