Create index.html
Browse files- index.html +184 -0
index.html
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>AI-Powered Terminal Chat</title>
|
7 |
+
<style>
|
8 |
+
body, html {
|
9 |
+
margin: 0;
|
10 |
+
padding: 0;
|
11 |
+
height: 100%;
|
12 |
+
overflow: hidden;
|
13 |
+
font-family: 'Courier New', monospace;
|
14 |
+
background-color: #000;
|
15 |
+
color: #0f0;
|
16 |
+
}
|
17 |
+
#terminal {
|
18 |
+
height: calc(100% - 60px);
|
19 |
+
width: 100%;
|
20 |
+
overflow-y: auto;
|
21 |
+
padding: 20px;
|
22 |
+
box-sizing: border-box;
|
23 |
+
}
|
24 |
+
#input-area {
|
25 |
+
height: 60px;
|
26 |
+
width: 100%;
|
27 |
+
display: flex;
|
28 |
+
padding: 10px;
|
29 |
+
box-sizing: border-box;
|
30 |
+
background-color: #111;
|
31 |
+
align-items: center;
|
32 |
+
}
|
33 |
+
#user-input {
|
34 |
+
flex-grow: 1;
|
35 |
+
background-color: #000;
|
36 |
+
border: 2px solid #0f0;
|
37 |
+
color: #0f0;
|
38 |
+
font-family: 'Courier New', monospace;
|
39 |
+
font-size: 16px;
|
40 |
+
padding: 10px;
|
41 |
+
border-radius: 5px 0 0 5px;
|
42 |
+
outline: none;
|
43 |
+
}
|
44 |
+
#send-btn {
|
45 |
+
width: 80px;
|
46 |
+
height: 42px;
|
47 |
+
background-color: #0f0;
|
48 |
+
color: #000;
|
49 |
+
border: none;
|
50 |
+
cursor: pointer;
|
51 |
+
font-family: 'Courier New', monospace;
|
52 |
+
font-size: 16px;
|
53 |
+
font-weight: bold;
|
54 |
+
border-radius: 0 5px 5px 0;
|
55 |
+
transition: background-color 0.3s;
|
56 |
+
}
|
57 |
+
#send-btn:hover {
|
58 |
+
background-color: #00ff00;
|
59 |
+
}
|
60 |
+
.line {
|
61 |
+
margin: 5px 0;
|
62 |
+
overflow: hidden;
|
63 |
+
white-space: nowrap;
|
64 |
+
}
|
65 |
+
.typed {
|
66 |
+
overflow: hidden;
|
67 |
+
white-space: nowrap;
|
68 |
+
animation: typing 0.5s steps(30, end);
|
69 |
+
}
|
70 |
+
@keyframes typing {
|
71 |
+
from { width: 0; }
|
72 |
+
to { width: 100%; }
|
73 |
+
}
|
74 |
+
@media (max-width: 768px) {
|
75 |
+
#terminal {
|
76 |
+
font-size: 14px;
|
77 |
+
}
|
78 |
+
#user-input, #send-btn {
|
79 |
+
font-size: 14px;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
</style>
|
83 |
+
</head>
|
84 |
+
<body>
|
85 |
+
<div id="terminal"></div>
|
86 |
+
<div id="input-area">
|
87 |
+
<input type="text" id="user-input" placeholder="Enter your command..." aria-label="Enter your command">
|
88 |
+
<button id="send-btn">Send</button>
|
89 |
+
</div>
|
90 |
+
<script>
|
91 |
+
const terminal = document.getElementById('terminal');
|
92 |
+
const userInput = document.getElementById('user-input');
|
93 |
+
const sendBtn = document.getElementById('send-btn');
|
94 |
+
|
95 |
+
function typeWriter(text, lineElement, index = 0) {
|
96 |
+
if (index < text.length) {
|
97 |
+
lineElement.textContent += text.charAt(index);
|
98 |
+
setTimeout(() => typeWriter(text, lineElement, index + 1), Math.random() * 10 + 5);
|
99 |
+
} else {
|
100 |
+
lineElement.classList.remove('typed');
|
101 |
+
terminal.scrollTop = terminal.scrollHeight;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
function addLine(text, isUser = false) {
|
106 |
+
const lineElement = document.createElement('div');
|
107 |
+
lineElement.classList.add('line', 'typed');
|
108 |
+
if (isUser) {
|
109 |
+
lineElement.style.color = '#ff0';
|
110 |
+
lineElement.textContent = '> ' + text;
|
111 |
+
terminal.appendChild(lineElement);
|
112 |
+
terminal.scrollTop = terminal.scrollHeight;
|
113 |
+
} else {
|
114 |
+
terminal.appendChild(lineElement);
|
115 |
+
typeWriter(text, lineElement);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
function toggleFullScreen() {
|
120 |
+
if (!document.fullscreenElement) {
|
121 |
+
document.documentElement.requestFullscreen();
|
122 |
+
addLine("Entering fullscreen mode...");
|
123 |
+
} else {
|
124 |
+
if (document.exitFullscreen) {
|
125 |
+
document.exitFullscreen();
|
126 |
+
addLine("Exiting fullscreen mode...");
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
async function processCommand(command) {
|
132 |
+
addLine(command, true);
|
133 |
+
|
134 |
+
if (command.toLowerCase() === 'help') {
|
135 |
+
addLine("Available commands:");
|
136 |
+
addLine("- help: Show this help message");
|
137 |
+
addLine("- pip install <package>: Install a Python package");
|
138 |
+
addLine("- git clone <repo>: Clone a git repository");
|
139 |
+
addLine("- python <script>: Execute a Python script");
|
140 |
+
addLine("- download <url>: Download a file from the given URL");
|
141 |
+
addLine("- !<shell command>: Execute a shell command");
|
142 |
+
addLine("- clear: Clear the terminal screen");
|
143 |
+
addLine("- cs: Toggle fullscreen mode");
|
144 |
+
} else if (command.toLowerCase() === 'clear') {
|
145 |
+
terminal.innerHTML = '';
|
146 |
+
} else if (command.toLowerCase() === 'cs') {
|
147 |
+
toggleFullScreen();
|
148 |
+
} else {
|
149 |
+
try {
|
150 |
+
const response = await fetch('/execute', {
|
151 |
+
method: 'POST',
|
152 |
+
headers: {
|
153 |
+
'Content-Type': 'application/json',
|
154 |
+
},
|
155 |
+
body: JSON.stringify({ command }),
|
156 |
+
});
|
157 |
+
const data = await response.json();
|
158 |
+
addLine(data.output);
|
159 |
+
} catch (error) {
|
160 |
+
addLine('Error executing command. Please try again.');
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
sendBtn.addEventListener('click', () => {
|
166 |
+
const command = userInput.value.trim();
|
167 |
+
if (command) {
|
168 |
+
processCommand(command);
|
169 |
+
userInput.value = '';
|
170 |
+
}
|
171 |
+
});
|
172 |
+
|
173 |
+
userInput.addEventListener('keypress', (e) => {
|
174 |
+
if (e.key === 'Enter') {
|
175 |
+
sendBtn.click();
|
176 |
+
}
|
177 |
+
});
|
178 |
+
|
179 |
+
// Initial messages
|
180 |
+
addLine("Welcome to the AI-Powered Terminal Chat!");
|
181 |
+
addLine("Type 'help' for available commands.");
|
182 |
+
</script>
|
183 |
+
</body>
|
184 |
+
</html>
|