-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
91 lines (91 loc) · 2.68 KB
/
index.html
File metadata and controls
91 lines (91 loc) · 2.68 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS Editor</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
height: 100vh;
margin: 0;
overflow: hidden;
}
#editor-container {
flex: 1;
padding: 10px;
display: flex;
flex-direction: column;
}
#code-editor {
width: 100%;
flex-grow: 1;
font-family: 'Courier New', monospace;
font-size: 14px;
padding: 10px;
border: 1px solid #ccc;
resize: none;
}
#console-container {
flex: 1;
padding: 10px;
display: flex;
flex-direction: column;
background-color: #f0f0f0;
border-left: 1px solid #ccc;
}
#console-output {
flex-grow: 1;
background-color: #333;
color: #eee;
padding: 10px;
overflow-y: auto;
font-family: 'Courier New', monospace;
font-size: 13px;
white-space: pre-wrap;
}
button {
margin-top: 10px;
padding: 8px 15px;
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div id="editor-container">
<h2>JavaScript Code</h2>
<textarea id="code-editor" spellcheck="false">Replace this text with your javascript code.. </textarea>
<button onclick="runCode()">Run Code</button>
</div>
<div id="console-container">
<h2>Console Output</h2>
<pre id="console-output"></pre>
<button onclick="clearConsole()">Clear Console</button>
</div>
<script>
const codeEditor = document.getElementById('code-editor');
const consoleOutput = document.getElementById('console-output');
const originalConsoleLog = console.log;
console.log = (...args) => {
originalConsoleLog(...args);
consoleOutput.textContent += args.map(arg => typeof arg === 'object' ? JSON.stringify(arg) : arg).join(' ') + '\n';
consoleOutput.scrollTop = consoleOutput.scrollHeight;
}
function runCode() {
clearConsole();
eval(codeEditor.value);
}
function clearConsole() {
consoleOutput.textContent = ''
}
runCode()
</script>
</body>
</html>