File size: 6,192 Bytes
0edbe2c |
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 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI-Powered Terminal Chat</title>
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
font-family: 'Courier New', monospace;
background-color: #000;
color: #0f0;
}
#terminal {
height: calc(100% - 60px);
width: 100%;
overflow-y: auto;
padding: 20px;
box-sizing: border-box;
}
#input-area {
height: 60px;
width: 100%;
display: flex;
padding: 10px;
box-sizing: border-box;
background-color: #111;
align-items: center;
}
#user-input {
flex-grow: 1;
background-color: #000;
border: 2px solid #0f0;
color: #0f0;
font-family: 'Courier New', monospace;
font-size: 16px;
padding: 10px;
border-radius: 5px 0 0 5px;
outline: none;
}
#send-btn {
width: 80px;
height: 42px;
background-color: #0f0;
color: #000;
border: none;
cursor: pointer;
font-family: 'Courier New', monospace;
font-size: 16px;
font-weight: bold;
border-radius: 0 5px 5px 0;
transition: background-color 0.3s;
}
#send-btn:hover {
background-color: #00ff00;
}
.line {
margin: 5px 0;
overflow: hidden;
white-space: nowrap;
}
.typed {
overflow: hidden;
white-space: nowrap;
animation: typing 0.5s steps(30, end);
}
@keyframes typing {
from { width: 0; }
to { width: 100%; }
}
@media (max-width: 768px) {
#terminal {
font-size: 14px;
}
#user-input, #send-btn {
font-size: 14px;
}
}
</style>
</head>
<body>
<div id="terminal"></div>
<div id="input-area">
<input type="text" id="user-input" placeholder="Enter your command..." aria-label="Enter your command">
<button id="send-btn">Send</button>
</div>
<script>
const terminal = document.getElementById('terminal');
const userInput = document.getElementById('user-input');
const sendBtn = document.getElementById('send-btn');
function typeWriter(text, lineElement, index = 0) {
if (index < text.length) {
lineElement.textContent += text.charAt(index);
setTimeout(() => typeWriter(text, lineElement, index + 1), Math.random() * 10 + 5);
} else {
lineElement.classList.remove('typed');
terminal.scrollTop = terminal.scrollHeight;
}
}
function addLine(text, isUser = false) {
const lineElement = document.createElement('div');
lineElement.classList.add('line', 'typed');
if (isUser) {
lineElement.style.color = '#ff0';
lineElement.textContent = '> ' + text;
terminal.appendChild(lineElement);
terminal.scrollTop = terminal.scrollHeight;
} else {
terminal.appendChild(lineElement);
typeWriter(text, lineElement);
}
}
function toggleFullScreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
addLine("Entering fullscreen mode...");
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
addLine("Exiting fullscreen mode...");
}
}
}
async function processCommand(command) {
addLine(command, true);
if (command.toLowerCase() === 'help') {
addLine("Available commands:");
addLine("- help: Show this help message");
addLine("- pip install <package>: Install a Python package");
addLine("- git clone <repo>: Clone a git repository");
addLine("- python <script>: Execute a Python script");
addLine("- download <url>: Download a file from the given URL");
addLine("- !<shell command>: Execute a shell command");
addLine("- clear: Clear the terminal screen");
addLine("- cs: Toggle fullscreen mode");
} else if (command.toLowerCase() === 'clear') {
terminal.innerHTML = '';
} else if (command.toLowerCase() === 'cs') {
toggleFullScreen();
} else {
try {
const response = await fetch('/execute', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ command }),
});
const data = await response.json();
addLine(data.output);
} catch (error) {
addLine('Error executing command. Please try again.');
}
}
}
sendBtn.addEventListener('click', () => {
const command = userInput.value.trim();
if (command) {
processCommand(command);
userInput.value = '';
}
});
userInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
sendBtn.click();
}
});
// Initial messages
addLine("Welcome to the AI-Powered Terminal Chat!");
addLine("Type 'help' for available commands.");
</script>
</body>
</html> |