Добавил поиск

This commit is contained in:
RedGrox
2026-05-19 21:12:26 +03:00
parent d985807e53
commit 0b28111381
3 changed files with 74 additions and 0 deletions
+21
View File
@@ -43,6 +43,27 @@ function tryToggleTextContent(elementId, textContent) {
el.textContent = textContent;
}
function searchQuery(event) {
event.preventDefault();
const engine = document.getElementById('searchEngine').value;
const query = document.getElementById('searchInput').value.trim();
if (!query) {
document.getElementById('searchInput').focus();
return;
}
const encodedQuery = encodeURIComponent(query);
let url = 'https://www.google.com/search?q=' + encodedQuery;
if (engine === 'duckduckgo') {
url = 'https://duckduckgo.com/?q=' + encodedQuery;
}
window.open(url, '_blank', 'noopener');
}
// Background animation
const canvas = document.getElementById('bgCanvas');
const ctx = canvas.getContext('2d');