-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
101 lines (89 loc) · 2.81 KB
/
index.html
File metadata and controls
101 lines (89 loc) · 2.81 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
96
97
98
99
100
101
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Pyilot</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="container">
<aside id="sidebar">
<button id="newChat">+ New Chat</button>
<div class="sidebar-scroll">
<ul id="chatHistory"></ul>
</div>
</aside>
<main>
<div id="chatBox"></div>
<div class="input-area">
<textarea id="userInput" placeholder="Ask something..."></textarea>
<button id="send">➤</button>
</div>
</main>
</div>
<script src="renderer.js"></script>
<script>
const inputBox = document.getElementById("userInput");
const sidebar = document.getElementById("sidebar");
let historyIndex = -1;
let userInputs = [];
document.addEventListener("keydown", (e) => {
const isInputFocused = document.activeElement === inputBox;
// Shift+Enter = newline | Enter = send
if (isInputFocused && e.key === "Enter") {
if (e.shiftKey) return;
e.preventDefault();
document.getElementById("send").click();
}
// Ctrl+N = New Chat
if (e.ctrlKey && e.key.toLowerCase() === "n") {
e.preventDefault();
document.getElementById("newChat").click();
}
// Ctrl+K = focus input box
if (e.ctrlKey && e.key.toLowerCase() === "k") {
e.preventDefault();
inputBox.focus();
}
// Ctrl+H = toggle sidebar
if (e.ctrlKey && e.key.toLowerCase() === "h") {
e.preventDefault();
sidebar.style.display = (sidebar.style.display === "none") ? "block" : "none";
}
// Ctrl+ArrowUp = Previous input
if (isInputFocused && e.ctrlKey && e.key === "ArrowUp") {
e.preventDefault();
if (userInputs.length > 0 && historyIndex < userInputs.length - 1) {
historyIndex++;
inputBox.value = userInputs[userInputs.length - 1 - historyIndex];
}
}
// Ctrl+ArrowDown = Next input
if (isInputFocused && e.ctrlKey && e.key === "ArrowDown") {
e.preventDefault();
if (historyIndex > 0) {
historyIndex--;
inputBox.value = userInputs[userInputs.length - 1 - historyIndex];
} else {
historyIndex = -1;
inputBox.value = "";
}
}
// Ctrl+R = Rerun last script
if (e.ctrlKey && e.key.toLowerCase() === "r") {
e.preventDefault();
if (typeof rerunLastScript === "function") rerunLastScript();
}
});
// Track input history
document.getElementById("send").addEventListener("click", () => {
const val = inputBox.value.trim();
if (val) {
userInputs.push(val);
historyIndex = -1;
}
});
</script>
</body>
</html>