Spaces:
Running
Running
File size: 8,372 Bytes
8aeb522 |
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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
<!DOCTYPE html>
<html lang="en">
<!-- Mirrored from es-teams-database2025.onrender.com/esteams-ai.html by HTTrack Website Copier/3.x [XR&CO'2017], Fri, 14 Feb 2025 22:35:13 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ES TEAMS AI Chat</title>
<!-- Tailwind CSS -->
<script src="../external.html?link=https://cdn.tailwindcss.com/"></script>
<!-- Google Fonts -->
<link href="../external.html?link=https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
}
/* Typing Animation */
.typing {
display: flex;
align-items: center;
}
.typing span {
width: 8px;
height: 8px;
background: white;
margin: 0 2px;
border-radius: 50%;
animation: typing 1.5s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
0%, 100% { opacity: 0.2; }
50% { opacity: 1; }
}
/* AI Text Animation */
.ai-text {
opacity: 0;
transform: translateX(100%);
animation: slide-in 1s forwards;
}
@keyframes slide-in {
to {
opacity: 1;
transform: translateX(0);
}
}
</style>
</head>
<body class="bg-gray-900 text-white flex items-center justify-center h-screen">
<div class="w-full max-w-lg bg-gray-800 p-6 rounded-lg shadow-md">
<h2 class="text-2xl font-bold text-center mb-4">πͺππππ’π π π§π’ ππ¦ π§πππ π¦ ππ</h2>
<p class="text-center text-gray-400 mb-6">I am an Artificial Intelligence built by ES TEAMS TECH</p>
<div id="chat-box" class="space-y-4 max-h-96 overflow-y-auto p-2 bg-gray-700 rounded-lg">
<div class="flex items-start space-x-2">
<div class="bg-blue-600 p-3 rounded-lg text-white">
Hello! How can I help you today?
</div>
</div>
</div>
<div class="flex items-center mt-4">
<input id="user-input" type="text" placeholder="Type your message..."
class="flex-1 p-3 rounded-lg bg-gray-700 focus:ring-2 focus:ring-blue-500 focus:outline-none text-white"
oninput="toggleSendButton()">
<button id="send-button" onclick="sendMessage()"
class="ml-2 bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-lg text-white font-bold send-btn" disabled>
Send
</button>
</div>
</div>
<script>
function toggleSendButton() {
document.getElementById("send-button").disabled = document.getElementById("user-input").value.trim() === "";
}
function getRequestData() {
const requestData = JSON.parse(localStorage.getItem("requestData")) || { count: 0, timestamp: null };
return requestData;
}
function updateRequestData() {
const now = Date.now();
let requestData = getRequestData();
if (!requestData.timestamp || now - requestData.timestamp > 24 * 60 * 60 * 1000) {
requestData = { count: 0, timestamp: now }; // Reset after 24 hours
}
requestData.count += 1;
localStorage.setItem("requestData", JSON.stringify(requestData));
return requestData;
}
function getRemainingTime() {
const requestData = getRequestData();
if (!requestData.timestamp) return 0;
const elapsedTime = Date.now() - requestData.timestamp;
const remainingTime = 24 * 60 * 60 * 1000 - elapsedTime;
if (remainingTime <= 0) {
localStorage.removeItem("requestData"); // Clear the count when time reaches zero
return 0;
}
return remainingTime;
}
function formatTime(ms) {
const hours = Math.floor(ms / (1000 * 60 * 60));
const minutes = Math.floor((ms % (1000 * 60 * 60)) / (1000 * 60));
return `${hours} hours ${minutes} minutes`;
}
async function sendMessage() {
const query = document.getElementById("user-input").value.trim().toLowerCase();
if (!query) return;
const requestData = getRequestData();
if (requestData.count >= 50) {
const remainingTime = getRemainingTime();
addMessage(`Limit Exceeded, Kindly use ES TEAMS AI + or wait for ${formatTime(remainingTime)}`, "ai");
return;
}
updateRequestData();
addMessage(query, "user");
document.getElementById("user-input").value = "";
toggleSendButton();
const typingElement = addTypingAnimation();
try {
const creatorQuestions = [
"who created you", "when were you created", "who developed you", "who fixed you", "who trained you", "who pet you", "who organized you", "who coded you", "who grew you", "who took care of you", "when last were you created", "who made you", "who built you",
"who is your creator", "when were you built", "who is the developer", "who designed you", "when was your creation"
];
const responseMessage = creatorQuestions.some(q => query.includes(q))
? "I was built by ES TEAMS TECH on 1st Feb 2025."
: null;
if (responseMessage) {
removeTypingAnimation(typingElement);
addMessage(responseMessage, "ai");
return;
}
const apiUrl = `https://api.davidcyriltech.my.id/ai/chatbot?query=${encodeURIComponent(query)}`;
const response = await fetch(apiUrl);
const jsonData = await response.json();
removeTypingAnimation(typingElement);
addMessage(jsonData.result || "Sorry, I couldn't process your request.", "ai");
} catch (error) {
console.error("Error fetching API response:", error);
removeTypingAnimation(typingElement);
addMessage("An error occurred. Please try again later.", "ai");
}
}
function addMessage(text, sender) {
const chatBox = document.getElementById("chat-box");
const messageDiv = document.createElement("div");
messageDiv.classList.add("flex", "items-start", "space-x-2");
if (sender === "ai") {
messageDiv.innerHTML = `<div class="bg-blue-600 p-3 rounded-lg text-white">${text}</div>`;
} else {
messageDiv.classList.add("justify-end");
messageDiv.innerHTML = `<div class="bg-gray-500 p-3 rounded-lg text-white">${text}</div>`;
}
chatBox.appendChild(messageDiv);
chatBox.scrollTop = chatBox.scrollHeight;
}
function addTypingAnimation() {
const chatBox = document.getElementById("chat-box");
const typingDiv = document.createElement("div");
typingDiv.classList.add("typing", "space-x-1", "ml-2");
for (let i = 0; i < 3; i++) {
const dot = document.createElement("span");
dot.classList.add("bg-white", "w-2", "h-2", "rounded-full");
typingDiv.appendChild(dot);
}
chatBox.appendChild(typingDiv);
chatBox.scrollTop = chatBox.scrollHeight;
return typingDiv;
}
function removeTypingAnimation(element) {
if (element) element.remove();
}
</script>
</body>
<!-- Mirrored from es-teams-database2025.onrender.com/esteams-ai.html by HTTrack Website Copier/3.x [XR&CO'2017], Fri, 14 Feb 2025 22:35:13 GMT -->
</html>
|