commit
508cf6a748
7 files changed
+98
-80
No files matched your search
+59
-50
@@ -1,64 +1,73 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const toggleBtn = document.getElementById("chatbot-toggle-btn");
|
||||
const closeBtn = document.getElementById("chatbot-close-btn");
|
||||
const chatWindow = document.getElementById("chatbot-window");
|
||||
const chatForm = document.getElementById("chatbot-input-form");
|
||||
const inputField = document.getElementById("chatbot-input-field");
|
||||
const messagesContainer = document.getElementById("chatbot-messages");
|
||||
const pulseDot = document.querySelector(".pulse-notification-dot");
|
||||
const toggleBtn = document.getElementById("chatbot-toggle-btn");
|
||||
const closeBtn = document.getElementById("chatbot-close-btn");
|
||||
const chatWindow = document.getElementById("chatbot-window");
|
||||
const chatForm = document.getElementById("chatbot-input-form");
|
||||
const inputField = document.getElementById("chatbot-input-field");
|
||||
const messagesContainer = document.getElementById("chatbot-messages");
|
||||
const pulseDot = document.querySelector(".pulse-notification-dot");
|
||||
|
||||
// Initialize the new JavaScript intent matching engine using injected PHP data
|
||||
// Initialize the new JavaScript intent matching engine using injected PHP data
|
||||
// We add a safety check in case chatbot-engine.js failed to load
|
||||
if (typeof window.PortfolioChatEngine === 'undefined') {
|
||||
console.error("Chat engine not loaded");
|
||||
} else {
|
||||
const engine = new window.PortfolioChatEngine(window.portfolioData || {});
|
||||
let isWaiting = false;
|
||||
|
||||
// Toggle Chat Window
|
||||
toggleBtn.addEventListener("click", () => {
|
||||
chatWindow.classList.toggle("hidden");
|
||||
chatWindow.classList.toggle("active");
|
||||
if (chatWindow.classList.contains("active")) {
|
||||
inputField.focus();
|
||||
if (pulseDot) pulseDot.style.display = "none";
|
||||
}
|
||||
});
|
||||
if (toggleBtn) {
|
||||
toggleBtn.addEventListener("click", () => {
|
||||
chatWindow.classList.toggle("hidden");
|
||||
chatWindow.classList.toggle("active");
|
||||
if (chatWindow.classList.contains("active")) {
|
||||
inputField.focus();
|
||||
if (pulseDot) pulseDot.style.display = "none";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
closeBtn.addEventListener("click", () => {
|
||||
chatWindow.classList.add("hidden");
|
||||
chatWindow.classList.remove("active");
|
||||
});
|
||||
if (closeBtn) {
|
||||
closeBtn.addEventListener("click", () => {
|
||||
chatWindow.classList.add("hidden");
|
||||
chatWindow.classList.remove("active");
|
||||
});
|
||||
}
|
||||
|
||||
// Handle form submit
|
||||
chatForm.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
if (isWaiting) return;
|
||||
if (chatForm) {
|
||||
chatForm.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
if (isWaiting) return;
|
||||
|
||||
const message = inputField.value.trim();
|
||||
if (!message) return;
|
||||
const message = inputField.value.trim();
|
||||
if (!message) return;
|
||||
|
||||
// Add user message to UI
|
||||
addMessage(message, "user-msg");
|
||||
inputField.value = "";
|
||||
|
||||
isWaiting = true;
|
||||
|
||||
// Show typing indicator
|
||||
const typingId = showTypingIndicator();
|
||||
|
||||
// Simulate network delay for natural feel (600ms - 1200ms)
|
||||
const delay = Math.floor(Math.random() * 600) + 600;
|
||||
|
||||
setTimeout(() => {
|
||||
// Remove typing indicator
|
||||
removeTypingIndicator(typingId);
|
||||
// Add user message to UI
|
||||
addMessage(message, "user-msg");
|
||||
inputField.value = "";
|
||||
|
||||
// Get response from our JS engine instead of API
|
||||
const responseText = engine.match(message);
|
||||
isWaiting = true;
|
||||
|
||||
// Show typing indicator
|
||||
const typingId = showTypingIndicator();
|
||||
|
||||
// Simulate network delay for natural feel (600ms - 1200ms)
|
||||
const delay = Math.floor(Math.random() * 600) + 600;
|
||||
|
||||
// Display formatted markdown response
|
||||
addMessage(responseText, "bot-msg", true);
|
||||
isWaiting = false;
|
||||
|
||||
}, delay);
|
||||
});
|
||||
setTimeout(() => {
|
||||
// Remove typing indicator
|
||||
removeTypingIndicator(typingId);
|
||||
|
||||
// Get response from our JS engine instead of API
|
||||
const responseText = engine.match(message);
|
||||
|
||||
// Display formatted markdown response
|
||||
addMessage(responseText, "bot-msg", true);
|
||||
isWaiting = false;
|
||||
|
||||
}, delay);
|
||||
});
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// UI Helpers
|
||||
@@ -151,4 +160,4 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
return text;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
<meta name="description" content="Blog — Tutorials, tech reviews, and updates from Cris Charles Garcia's developer journey.">
|
||||
<title>Blog | Cris Charles Garcia</title>
|
||||
<link rel="icon" type="image/svg+xml" href="assets/img/favicon.svg">
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
<link rel="stylesheet" href="assets/css/style.css?v=2.0.0">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
<meta name="description" content="Certifications — Qualifications and courses completed by Cris Charles Garcia.">
|
||||
<title>Certifications | Cris Charles Garcia</title>
|
||||
<link rel="icon" type="image/svg+xml" href="assets/img/favicon.svg">
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
<link rel="stylesheet" href="assets/css/style.css?v=2.0.0">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ $contactEmail = $_ENV['CONTACT_EMAIL'] ?? getenv('CONTACT_EMAIL')
|
||||
<meta name="description" content="Cris Charles Garcia — BSIT Software Development student based in Laguna, Philippines. Building digital products with purpose using MERN Stack and PHP.">
|
||||
<title>Cris Charles Garcia | Software Developer</title>
|
||||
<link rel="icon" type="image/svg+xml" href="assets/img/favicon.svg">
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
<link rel="stylesheet" href="assets/css/style.css?v=2.0.1">
|
||||
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
<meta name="description" content="All Projects — A complete archive of apps, websites, and experiments built by Cris Charles Garcia.">
|
||||
<title>All Projects | Cris Charles Garcia</title>
|
||||
<link rel="icon" type="image/svg+xml" href="assets/img/favicon.svg">
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
<link rel="stylesheet" href="assets/css/style.css?v=2.0.0">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
+6
-1
@@ -49,7 +49,7 @@ if ($logStmt) {
|
||||
|
||||
// Forward submission to FormSubmit via cURL
|
||||
$contactEmail = $_ENV['CONTACT_EMAIL'] ?? getenv('CONTACT_EMAIL') ?? 'crischarlesgarcia345@gmail.com';
|
||||
$url = "https://formsubmit.co/" . $contactEmail;
|
||||
$url = "https://formsubmit.co/ajax/" . $contactEmail;
|
||||
|
||||
if (!function_exists('curl_init')) {
|
||||
header("Location: index.php?status=error&msg=cURL is not available on this server.#contact");
|
||||
@@ -63,6 +63,11 @@ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($_POST));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Accept: application/json'
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36');
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
+29
-25
@@ -7,34 +7,38 @@ $certs = [];
|
||||
$articles = [];
|
||||
|
||||
if (isset($mysqli) && !$mysqli->connect_error) {
|
||||
// 1. Settings / About
|
||||
$settingsQuery = $mysqli->query("SELECT * FROM settings WHERE id = 1");
|
||||
if ($settingsQuery) {
|
||||
$settings = $settingsQuery->fetch_assoc();
|
||||
}
|
||||
|
||||
// 2. Projects
|
||||
$projectsQuery = $mysqli->query("SELECT title, des, techstack, url FROM projects");
|
||||
if ($projectsQuery) {
|
||||
while ($row = $projectsQuery->fetch_assoc()) {
|
||||
$projects[] = $row;
|
||||
try {
|
||||
// 1. Settings / About
|
||||
$settingsQuery = $mysqli->query("SELECT * FROM settings WHERE id = 1");
|
||||
if ($settingsQuery) {
|
||||
$settings = $settingsQuery->fetch_assoc();
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Certifications
|
||||
$certsQuery = $mysqli->query("SELECT title, issuer, date_issued FROM certifications");
|
||||
if ($certsQuery) {
|
||||
while ($row = $certsQuery->fetch_assoc()) {
|
||||
$certs[] = $row;
|
||||
// 2. Projects
|
||||
$projectsQuery = $mysqli->query("SELECT title, des, techstack, url FROM projects");
|
||||
if ($projectsQuery) {
|
||||
while ($row = $projectsQuery->fetch_assoc()) {
|
||||
$projects[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Articles
|
||||
$articlesQuery = $mysqli->query("SELECT title, excerpt, date_published, tag, url FROM articles");
|
||||
if ($articlesQuery) {
|
||||
while ($row = $articlesQuery->fetch_assoc()) {
|
||||
$articles[] = $row;
|
||||
// 3. Certifications
|
||||
$certsQuery = $mysqli->query("SELECT title, issuer, date_issued FROM certifications");
|
||||
if ($certsQuery) {
|
||||
while ($row = $certsQuery->fetch_assoc()) {
|
||||
$certs[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Articles
|
||||
$articlesQuery = $mysqli->query("SELECT title, excerpt, date_published, tag, url FROM articles");
|
||||
if ($articlesQuery) {
|
||||
while ($row = $articlesQuery->fetch_assoc()) {
|
||||
$articles[] = $row;
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// Silently ignore DB errors here to prevent breaking the whole page
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -103,5 +107,5 @@ window.portfolioData = {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/chatbot-engine.js" defer></script>
|
||||
<script src="assets/js/chat.js" defer></script>
|
||||
<script src="assets/js/chatbot-engine.js?v=2.0.0" defer></script>
|
||||
<script src="assets/js/chat.js?v=2.0.0" defer></script>
|
||||
Reference in new issue
Block a user