|
| 1 | + |
| 2 | +const form = document.getElementById("chatForm"); |
| 3 | +const input = document.getElementById("message"); |
| 4 | +const messages = document.getElementById("messages"); |
| 5 | + |
| 6 | +function addMessage(text, type) { |
| 7 | + const element = document.createElement("div"); |
| 8 | + element.className = type; |
| 9 | + element.textContent = text; |
| 10 | + messages.appendChild(element); |
| 11 | + messages.scrollTop = messages.scrollHeight; |
| 12 | +} |
| 13 | + |
| 14 | +function reply(text) { |
| 15 | + const t = text.toLowerCase(); |
| 16 | + |
| 17 | + if (t.includes("привіт")) { |
| 18 | + return "Привіт! 👋 Я Zayrox_KrytoiBot!"; |
| 19 | + } |
| 20 | + |
| 21 | + if (t.includes("майнкрафт")) { |
| 22 | + return "🎮 Ідея: створи Minecraft Shorts, де таємничий портал змінює світ кожні 5 секунд!"; |
| 23 | + } |
| 24 | + |
| 25 | + if (t.includes("переклади") || t.includes("переклад")) { |
| 26 | + return 'Напиши текст для перекладу. Наприклад, "Hello" українською — "Привіт".'; |
| 27 | + } |
| 28 | + |
| 29 | + if (t.includes("математ")) { |
| 30 | + return "🧮 Напиши математичний приклад. Це демо-версія, тому складні приклади можуть потребувати справжнього AI."; |
| 31 | + } |
| 32 | + |
| 33 | + return "💙 Я отримав твоє повідомлення! Зараз працює демо-режим. Щоб давати розумні відповіді на будь-які запитання, потрібно підключити AI через сервер."; |
| 34 | +} |
| 35 | + |
| 36 | +form.addEventListener("submit", function(event) { |
| 37 | + event.preventDefault(); |
| 38 | + |
| 39 | + const text = input.value.trim(); |
| 40 | + if (!text) return; |
| 41 | + |
| 42 | + addMessage(text, "user"); |
| 43 | + input.value = ""; |
| 44 | + |
| 45 | + setTimeout(() => { |
| 46 | + addMessage(reply(text), "bot"); |
| 47 | + }, 300); |
| 48 | +}); |
1 | 49 | --- |
2 | 50 | title: Quickstart for GitHub Pages |
3 | 51 | intro: You can use {% data variables.product.prodname_pages %} to showcase open source projects, host a blog, or even share your résumé. This guide will help get you started on creating your next website. |
|
0 commit comments