Text Generation
Transformers
Safetensors
English
phi3
phi
nlp
math
code
chat
conversational
reasoning
text-generation-inference
Run this model with HF Jobs
Run Ashok75/base2 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/Ashok75/base2. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Ashok75/base2 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/Ashok75/base2. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/Ashok75/base2. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use Ashok75/base2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ashok75/base2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Ashok75/base2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Ashok75/base2") model = AutoModelForCausalLM.from_pretrained("Ashok75/base2", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Ashok75/base2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Ashok75/base2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ashok75/base2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Ashok75/base2
- SGLang
How to use Ashok75/base2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Ashok75/base2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ashok75/base2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Ashok75/base2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ashok75/base2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Ashok75/base2 with Docker Model Runner:
docker model run hf.co/Ashok75/base2
Upload 3 files
Browse filesFiles changed (3)
- auth.html+335-56
- chat.html+139-100
- profile.htmlAdded+2090
39 unmodified lines4041424343444546395 unmodified lines44244344444544644744844944544644744844945045145245345445545145645745845945446046146246346446546611 unmodified lines47847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257362 unmodified lines63663763854354463964064164264354754854955064464564664764864955355465065165265365465565665765856056156256365966066166266366466566666766866967067167267367456656756867567667767867968031 unmodified lines71271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474529 unmodified lines77577677764177877978078178278378478578678778878979079179279379433 unmodified lines828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858167 unmodified lines102610271028854102910301031103220 unmodified lines105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751 unmodified line107710781079888108010811082108342 unmodified lines1126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114815 unmodified lines11641165116611671168116911701171117211731174117538 unmodified lines1214121512161217121812191220122112221223122412251 unmodified line122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125110111252125312541255125613 unmodified lines127012711272103112731274127510331276127710351036103710381039104012781279128012811282128312841285128659 unmodified lines134613471348134913501351135219 unmodified lines13721373137413751376137713781379138013811382138313841385138613873 unmodified lines13911392139313941395139613971398139914001401140214031404140514063 unmodified lines141014111412141314141415141614171418141914201421142214231424142558 unmodified lines14841485148614871488148914901491149214931494149514961497149814993 unmodified lines150315041505150615071508150985 unmodified lines1595159615971598159916001316160116021603160448 unmodified lines16531654165513711372137313741375137613771378137913801381138213831384138513861387138816561657165816591660166116621663166416651666166715 unmodified lines168316841685168616871688168916901691169216931694169511 unmodified lines1707170817091431171017111433171217131714171539 unmodified lines width: 100%; background: -webkit-linear-gradient(left, #003366,#004080,#0059b3 , #0073e6); color: var(--bs-body-color); padding-top: 5vh; padding-top: calc(64px + 5vh); padding-bottom: 5vh; min-height: 100vh; /* Allow space for modal overlay */395 unmodified lines font-size: 0.9rem; color: var(--bs-body-color); } .modal-form input[type="text"], .modal-form input[type="email"], .modal-form input[type="password"] { width: 100%; padding: 10px 15px; .otp-input-container { display: flex; gap: 5px; justify-content: center; margin-bottom: 10px; } .otp-digit { width: 40px; height: 40px; text-align: center; border: 1px solid var(--bs-border-color); border-radius: 10px; border-radius: 5px; font-size: 1.2rem; background-color: var(--bs-body-bg); color: var(--bs-body-color); box-sizing: border-box; /* Crucial for consistent width */ } .otp-digit:focus { border-color: var(--gakr-blue); outline: none; } .modal-form .error-message { position: static; /* Remove absolute positioning */11 unmodified lines width: 100%; max-width: 150px; }
/* Header styles */ .gakr-chat-header { padding: 0.75rem 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--bs-border-color); height: 64px; position: fixed; top: 0; left: 0; right: 0; width: 100%; background-color: var(--bs-body-bg); z-index: 10; }
.gakr-logo-area { display: flex; align-items: center; gap: 0.75rem; }
.gakr-brand-logo { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.gakr-brand-text { font-size: 1.25rem; font-weight: 500; color: var(--gakr-blue); }
.gakr-nav-controls { display: flex; align-items: center; }
.gakr-login-button { color: var(--gakr-blue); text-decoration: none; background: transparent; border: 1px solid var(--gakr-blue); padding: 0.5rem 1rem; border-radius: 50px; font-size: 0.9rem; transition: background-color 0.2s; }
.gakr-login-button:hover { background-color: rgba(66, 133, 244, 0.1); }
.gakr-profile-button { color: var(--gakr-blue); text-decoration: none; background: transparent; border: none; padding: 0.5rem 1rem; border-radius: 50px; font-size: 0.9rem; transition: background-color 0.2s; display: flex; align-items: center; gap: 0.5rem; }
.gakr-profile-button:hover { background-color: rgba(66, 133, 244, 0.1); } </style></head><body> <header class="gakr-chat-header"> <div class="gakr-logo-area"> <a href="/" class="gakr-brand-logo"> <i class="fas fa-robot" style="color: var(--gakr-blue);"></i> </a> <a href="/" class="gakr-brand-text" style="text-decoration: none;">GAKR AI</a> </div>
<div class="gakr-nav-controls" id="authButtonContainer"> <a href="/auth" class="gakr-login-button">Sign in / Register</a> </div> </header>
<div class="wrapper"> <div class="title-text">62 unmodified lines </div>
<div class="modal-overlay" id="forgotPasswordRequestModal"> <div class="modal-content"> <p class="modal-message" id="forgotModalMessage">Enter your registered email to request a password reset.</p> <div class="modal-content" style="max-width: 450px;"> <h3 style="text-align: center; margin-bottom: 20px; color: var(--gakr-blue);">Reset Password</h3> <p class="modal-message" id="forgotModalMessage" style="text-align: center; margin-bottom: 25px;">Enter your registered email address to receive a password reset code.</p> <form id="forgotPasswordRequestForm" class="modal-form"> <div class="field"> <label for="forgotEmail">Email:</label> <input type="email" id="forgotEmail" name="email" required> <div class="error-message" id="forgotEmailError"></div> <div class="field" style="margin-bottom: 30px;"> <label for="forgotEmail" style="display: block; margin-bottom: 8px; font-weight: 500; color: var(--bs-body-color);">Email Address:</label> <input type="email" id="forgotEmail" name="email" required style="width: 100%; padding: 12px; border: 2px solid var(--bs-border-color); border-radius: 8px; font-size: 16px; background-color: var(--bs-body-bg); color: var(--bs-body-color);" placeholder="Enter your email"> <div class="error-message" id="forgotEmailError" style="margin-top: 8px;"></div> </div> <div class="modal-buttons-stacked"> <button type="submit" class="modal-button" id="forgotSubmitButton">Request OTP</button> <button type="button" class="modal-button" id="forgotCancelButton" style="background-color: var(--bs-secondary-color);">Cancel</button> <button type="submit" class="modal-button" id="forgotSubmitButton" style="width: 100%; padding: 12px; font-size: 16px;">Send Reset Code</button> <button type="button" class="modal-button" id="forgotCancelButton" style="width: 100%; padding: 12px; font-size: 16px; background-color: var(--bs-secondary-color); margin-top: 10px;">Cancel</button> </div> </form>
<div id="otpSection" style="display: none;"> <h3 style="text-align: center; margin-bottom: 20px; color: var(--gakr-blue);">Enter Verification Code</h3> <p style="text-align: center; margin-bottom: 25px; color: var(--bs-secondary-color);">We've sent a 8-digit code to your email. Enter it below to continue.</p> <form id="verifyOtpForm" class="modal-form"> <div class="field"> <label for="otpInput">Enter OTP:</label> <input type="text" id="otpInput" name="otp" required maxlength="6" pattern="\d{6}" title="Please enter a 6-digit OTP"> <div class="error-message" id="otpError"></div> <div class="field" style="margin-bottom: 30px;"> <label style="display: block; margin-bottom: 15px; font-weight: 500; color: var(--bs-body-color); text-align: center;">Verification Code:</label> <div class="otp-input-container" style="display: flex; justify-content: center; gap: 8px; margin-bottom: 10px;"> <input type="text" class="otp-digit" maxlength="1" pattern="\d" required style="width: 45px; height: 50px; text-align: center; font-size: 20px; font-weight: bold; border: 2px solid var(--bs-border-color); border-radius: 8px; background-color: var(--bs-body-bg); color: var(--bs-body-color);"> <input type="text" class="otp-digit" maxlength="1" pattern="\d" required style="width: 45px; height: 50px; text-align: center; font-size: 20px; font-weight: bold; border: 2px solid var(--bs-border-color); border-radius: 8px; background-color: var(--bs-body-bg); color: var(--bs-body-color);"> <input type="text" class="otp-digit" maxlength="1" pattern="\d" required style="width: 45px; height: 50px; text-align: center; font-size: 20px; font-weight: bold; border: 2px solid var(--bs-border-color); border-radius: 8px; background-color: var(--bs-body-bg); color: var(--bs-body-color);"> <input type="text" class="otp-digit" maxlength="1" pattern="\d" required style="width: 45px; height: 50px; text-align: center; font-size: 20px; font-weight: bold; border: 2px solid var(--bs-border-color); border-radius: 8px; background-color: var(--bs-body-bg); color: var(--bs-body-color);"> <input type="text" class="otp-digit" maxlength="1" pattern="\d" required style="width: 45px; height: 50px; text-align: center; font-size: 20px; font-weight: bold; border: 2px solid var(--bs-border-color); border-radius: 8px; background-color: var(--bs-body-bg); color: var(--bs-body-color);"> <input type="text" class="otp-digit" maxlength="1" pattern="\d" required style="width: 45px; height: 50px; text-align: center; font-size: 20px; font-weight: bold; border: 2px solid var(--bs-border-color); border-radius: 8px; background-color: var(--bs-body-bg); color: var(--bs-body-color);"> <input type="text" class="otp-digit" maxlength="1" pattern="\d" required style="width: 45px; height: 50px; text-align: center; font-size: 20px; font-weight: bold; border: 2px solid var(--bs-border-color); border-radius: 8px; background-color: var(--bs-body-bg); color: var(--bs-body-color);"> <input type="text" class="otp-digit" maxlength="1" pattern="\d" required style="width: 45px; height: 50px; text-align: center; font-size: 20px; font-weight: bold; border: 2px solid var(--bs-border-color); border-radius: 8px; background-color: var(--bs-body-bg); color: var(--bs-body-color);"> </div> <input type="hidden" id="otpInput" name="otp"> <div class="error-message" id="otpError" style="text-align: center; margin-top: 10px;"></div> </div> <div class="modal-buttons-stacked"> <button type="submit" class="modal-button" id="verifyOtpButton">Verify OTP</button> <button type="button" class="modal-button" id="resendOtpButton" style="background-color: var(--bs-secondary-color);">Send Again</button> <button type="button" class="modal-button" id="otpCancelButton" style="background-color: var(--bs-secondary-color);">Cancel</button> <button type="submit" class="modal-button" id="verifyOtpButton" style="width: 100%; padding: 12px; font-size: 16px;">Verify Code</button> <button type="button" class="modal-button" id="resendOtpButton" style="width: 100%; padding: 12px; font-size: 16px; margin-top: 10px;">Send Code Again</button> <button type="button" class="modal-button" id="otpCancelButton" style="width: 100%; padding: 12px; font-size: 16px; background-color: var(--bs-secondary-color); margin-top: 10px;">Cancel</button> </div> </form> </div>31 unmodified lines
<script> document.addEventListener('DOMContentLoaded', function() { // --- Authentication Status Check --- function updateAuthButton() { const authButtonContainer = document.getElementById('authButtonContainer'); const userIsLoggedIn = localStorage.getItem('isLoggedIn') === 'true';
if (userIsLoggedIn) { authButtonContainer.innerHTML = ` <a href="/profile" class="gakr-profile-button"> <i class="fas fa-user-circle me-2"></i>Profile </a> `; const profileButton = authButtonContainer.querySelector('.gakr-profile-button'); if (profileButton) { profileButton.addEventListener('click', function(event) { console.log("Profile button clicked!"); }); } } else { authButtonContainer.innerHTML = ` <a href="/auth" class="gakr-login-button">Sign in / Register</a> `; } }
updateAuthButton(); window.addEventListener('focus', updateAuthButton); window.addEventListener('storage', updateAuthButton);
const loginText = document.querySelector(".title-text .login"); const loginFormDiv = document.querySelector("form.login"); const signupLink = document.querySelector("form .signup-link a");29 unmodified lines const modalMessageDiv = document.getElementById('modalMessage'); const modalButtonsContainer = document.getElementById('modalButtonsContainer');
// Forgot Password Request & OTP Modals elements // OTP digit inputs const otpDigits = document.querySelectorAll('.otp-digit'); otpDigits.forEach((input, index) => { input.addEventListener('input', function() { if (this.value.length === 1 && index < otpDigits.length - 1) { otpDigits[index + 1].focus(); } }); input.addEventListener('keydown', function(e) { if (e.key === 'Backspace' && this.value === '' && index > 0) { otpDigits[index - 1].focus(); } }); }); const forgotPasswordLink = document.getElementById('forgotPasswordLink'); const forgotPasswordRequestModal = document.getElementById('forgotPasswordRequestModal'); // The main overlay for forgot/otp const forgotModalMessage = document.getElementById('forgotModalMessage'); // Message within the forgot/otp modal33 unmodified lines // Stores the email across the forgot password/OTP/reset flow let currentForgotEmail = '';
// Resend OTP cooldown variables let resendCooldown = 0; let resendInterval = null;
// Function to start resend cooldown timer function startResendCooldown() { resendCooldown = 60; // 60 seconds resendOtpButton.disabled = true; resendOtpButton.textContent = `Send Again (60s)`; resendOtpButton.style.backgroundColor = 'var(--bs-secondary-color)'; // Gray during cooldown
resendInterval = setInterval(() => { resendCooldown--; if (resendCooldown > 0) { resendOtpButton.textContent = `Send Again (${resendCooldown}s)`; } else { clearInterval(resendInterval); resendInterval = null; resendOtpButton.disabled = false; resendOtpButton.textContent = 'Send Code Again'; resendOtpButton.style.backgroundColor = ''; // Reset to default (primary blue) } }, 1000); }
// Function to clear all error messages and input error classes function clearErrors(formType = 'all') { if (formType === 'all' || formType === 'main') {167 unmodified lines
// Login Form Submission Handler if (loginForm) { loginForm.addEventListener('submit', function(event) { loginForm.addEventListener('submit', async function(event) { event.preventDefault(); clearErrors('main'); // Clear main form errors
20 unmodified lines }
if (isValid) { // Check if user exists try { const checkResponse = await fetch('/api/check_user', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ identifier: usernameOrEmail }) }); const checkData = await checkResponse.json(); if (!checkData.exists) { loginUsernameOrEmailError.textContent = 'User does not exist.'; loginUsernameOrEmailInput.classList.add('error'); return; } } catch (error) { console.error('Error checking user:', error); // Proceed anyway } submitFormData(event.target, loginSubmitButton, '/api/login', 'main'); } });1 unmodified line
// Signup Form Submission Handler if (signupForm) { signupForm.addEventListener('submit', function(event) { signupForm.addEventListener('submit', async function(event) { event.preventDefault(); clearErrors('main');
42 unmodified lines }
if (isValid) { // Check if user already exists try { const checkResponse = await fetch('/api/check_user', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ identifier: email }) }); const checkData = await checkResponse.json(); if (checkData.exists) { signupEmailError.textContent = 'Email already registered.'; signupEmailInput.classList.add('error'); return; } } catch (error) { console.error('Error checking user:', error); // Proceed anyway } submitFormData(event.target, signupSubmitButton, '/api/signup', 'main'); } });15 unmodified lines forgotPasswordRequestForm.style.display = 'block'; if (otpSection) otpSection.style.display = 'none'; // Ensure OTP section is hidden initially
// Reset modal size for email input const modalContent = forgotPasswordRequestModal.querySelector('.modal-content'); if (modalContent) { modalContent.style.maxWidth = '450px'; }
showCustomModal(forgotPasswordRequestModal); }); }38 unmodified lines if (otpSection) otpSection.style.display = 'block'; otpInput.value = ''; // Clear previous OTP in case of resend
// Increase modal size for OTP section const modalContent = forgotPasswordRequestModal.querySelector('.modal-content'); if (modalContent) { modalContent.style.maxWidth = '550px'; }
// Update message for OTP section let messageText = `<p>An OTP has been sent to <strong>${email}</strong>. Please enter it below.</p>`; // Note: Do not display simulated OTP in production. This is for testing convenience.1 unmodified line // messageText += `<p><strong>SIMULATED OTP (FOR TESTING):</strong> ${result.simulated_otp}</p>`; // } forgotModalMessage.innerHTML = messageText; startResendCooldown(); // Start the cooldown timer for the resend button
} else { // Handle different error types if (response.status === 404) { // Email not registered - show registration modal hideCustomModal(forgotPasswordRequestModal); showFlexibleModal( '<p>The email address you entered is not registered yet.</p><p>Please sign up to create an account.</p>', [ { text: 'Sign Up', action: () => { signupRadio.checked = true; slideToSignup(); // Pre-fill the email in signup form signupEmailInput.value = email; }}, { text: 'Try Again', style: 'background-color: var(--bs-secondary-color);' } ] ); } else { // Other errors (400, 500) - show in modal result.status = response.status; displayModalFormErrors(result, forgotPasswordRequestForm, 'forgot'); displayModalFormErrors(result, forgotPasswordRequestForm, 'forgot'); } } } catch (error) { console.error('Fetch error:', error);13 unmodified lines clearErrors('otp'); // Clear errors specific to the OTP verification form
let isValid = true; const otp = otpInput.value.trim(); const otpDigits = document.querySelectorAll('.otp-digit'); const otp = Array.from(otpDigits).map(d => d.value).join('');
if (otp === '') { if (otp.length !== 8 || !/^\d{8}$/.test(otp)) { isValid = false; otpError.textContent = 'OTP is required.'; otpInput.classList.add('error'); } else if (!/^\d{6}$/.test(otp)) { // Ensure it's 6 digits isValid = false; otpError.textContent = 'OTP must be a 6-digit number.'; otpInput.classList.add('error'); otpError.textContent = 'Please enter all 8 digits of the OTP.'; otpDigits.forEach(d => d.classList.add('error')); }
if (isValid) { otpInput.value = otp; // Set hidden input verifyOtpButton.disabled = true; verifyOtpButton.innerHTML = '<span class="loading-spinner"></span> Verifying...';
59 unmodified lines otpInput.value = ''; // Clear previous OTP otpInput.classList.remove('error'); // Clear error state otpError.textContent = ''; // Clear error message startResendCooldown(); // Start the cooldown timer } else { // If there's an error on resend, display it in the OTP section's error message otpError.textContent = result.message || 'Failed to resend OTP.';19 unmodified lines forgotPasswordRequestForm.reset(); currentForgotEmail = ''; // Clear stored email clearErrors('forgot'); // Ensure all forgot-related errors are cleared // Clear resend cooldown if (resendInterval) { clearInterval(resendInterval); resendInterval = null; resendCooldown = 0; } // Reset resend button styling resendOtpButton.disabled = false; resendOtpButton.textContent = 'Send Code Again'; resendOtpButton.style.backgroundColor = ''; }); }
3 unmodified lines verifyOtpForm.reset(); currentForgotEmail = ''; // Clear stored email clearErrors('otp'); // Ensure all OTP-related errors are cleared // Clear resend cooldown if (resendInterval) { clearInterval(resendInterval); resendInterval = null; resendCooldown = 0; } // Reset resend button styling resendOtpButton.disabled = false; resendOtpButton.textContent = 'Send Code Again'; resendOtpButton.style.backgroundColor = ''; }); }
3 unmodified lines resetPasswordForm.reset(); currentForgotEmail = ''; // Clear stored email clearErrors('reset'); // Ensure all reset-related errors are cleared // Clear resend cooldown if (resendInterval) { clearInterval(resendInterval); resendInterval = null; resendCooldown = 0; } // Reset resend button styling resendOtpButton.disabled = false; resendOtpButton.textContent = 'Send Code Again'; resendOtpButton.style.backgroundColor = ''; }); }
58 unmodified lines hideCustomModal(resetPasswordModal); resetPasswordForm.reset(); currentForgotEmail = ''; // Clear stored email after successful reset // Clear resend cooldown if (resendInterval) { clearInterval(resendInterval); resendInterval = null; resendCooldown = 0; } // Reset resend button styling resendOtpButton.disabled = false; resendOtpButton.textContent = 'Send Code Again'; resendOtpButton.style.backgroundColor = ''; showFlexibleModal( '<p>Password reset successful. You can now login with your new password.</p>', [{ text: 'OK', action: () => {3 unmodified lines ); } else { // Display error messages from the backend result.status = response.status; displayModalFormErrors(result, resetPasswordForm, 'reset'); if (result.message && (result.message.includes('OTP not verified') || result.message.includes('not initiated'))) { showFlexibleModal(85 unmodified lines // Update the main message area of the modal if a general message is returned const targetModalMessage = formElement.closest('.modal-content').querySelector('.modal-message'); if (targetModalMessage && result.message) { // Check if this is an error response (status codes 400-599 indicate errors) const isError = result.status >= 400 && result.status < 600; const messageClass = isError ? 'error-message' : ''; targetModalMessage.innerHTML = `<p>${result.message}</p>`; targetModalMessage.innerHTML = `<p class="${messageClass}">${result.message}</p>`; } }
48 unmodified lines }}] ); } else if (endpoint === '/api/login') { showFlexibleModal( '<p>Login successful!</p>', [{ text: 'OK', action: () => { // Mark user as logged in so chat.html knows localStorage.setItem('gakr_is_logged_in', 'true'); alert('Welcome! You are logged in.'); // Optional: remove any guest flag if you had one // localStorage.removeItem('gakr_is_guest');
// Redirect back to chat interface window.location.href = 'chat.html'; } }] );}
showFlexibleModal( '<p>Login successful!</p>', [{ text: 'OK', action: () => { localStorage.setItem('isLoggedIn', 'true'); localStorage.setItem('user', JSON.stringify(result.user)); window.location.href = '/'; }}] ); } } // For forgot/otp/reset, successful handling is now done directly in their respective event listeners // so no generic handling here for those contexts.15 unmodified lines handleMainFormErrors(result, formElement, endpoint); } } else if (formContext === 'forgot') { result.status = response.status; displayModalFormErrors(result, formElement, 'forgot'); } else if (formContext === 'otp') { result.status = response.status; displayModalFormErrors(result, formElement, 'otp'); } else if (formContext === 'reset') { result.status = response.status; displayModalFormErrors(result, formElement, 'reset'); } }11 unmodified lines submitButton.disabled = false; // Reset button text specifically for modal forms if not handled by success/error flows above if (formContext === 'forgot') { submitButton.innerHTML = 'Request OTP'; submitButton.innerHTML = 'Send Reset Code'; } else if (formContext === 'otp') { submitButton.innerHTML = 'Verify OTP'; submitButton.innerHTML = 'Verify Code'; } else if (formContext === 'reset') { submitButton.innerHTML = 'Reset Password'; }28 unmodified lines29303132323334352 unmodified lines38394041414243442 unmodified lines4748495050515253545556565758591 unmodified line6162636464656667686970707172731 unmodified line75767778787980815 unmodified lines87888990909192934 unmodified lines98991001011011021031041051061071081081091101111121121131141151161161171181191 unmodified line1211221231241241251261273 unmodified lines1311321331341341351361372 unmodified lines14014114214314314414514614714814814915015115215315315415515615715715815916016116216316316416516611 unmodified lines17817918018118118218318418518618718818818919019117 unmodified lines2092102112122122132142152162172172182192205 unmodified lines2262272282292302292302312322336 unmodified lines2402412422432432442452462472482482492502512522532542552552562572582592602602612622632642652652662672682692702712722722732742752762772782792792802812822832842852862862872882894 unmodified lines2942952962972972982993001 unmodified line3023033043053063073053063073083093093103113124 unmodified lines3173183193203203213223232 unmodified lines3263273283293293303313323333343353353363373383393403413413423433443453463473483483493503514 unmodified lines3563573583593593603613623633643653663673683693703713723733743753763773783793803813823643833843853869 unmodified lines3963973983803994004014024033854044054064071 unmodified line4094104113934124134144154164174184004194204214224234244254074264274284296 unmodified lines4364374384204394404414424244434444454466 unmodified lines4534544554374564574584594414604614624636 unmodified lines470471472454473474475476128 unmodified lines60560660758959059159260860961061161261359561461561659859961761861962062160360460560662262362462562662760962862963063161361461563263363463563663763862063964064164262462562662764364464564664764864963163263365065165265365465565663865765864064165966066166264466366466566623 unmodified lines69069169267467567669369469569667867968068169769869970070170270321 unmodified lines7257267277097107287297307317327337347357367377387397407417427437443 unmodified lines74874975072075175275375451 unmodified lines806807808809810811812813814815816817818819176 unmodified lines99699799896099910001001100242 unmodified lines1045104610471009104810491050105146 unmodified lines10981099110010621101110211031065110411051106106811071108110911102 unmodified lines1113111411151077111611171118111930 unmodified lines115011511152111411531154115511568 unmodified lines1165116611671129116811691170117128 unmodified lines }
/* --- Base Chat Layout --- */ .gemini-chat-layout { .gakr-chat-layout { display: flex; flex-direction: column; height: 100vh;2 unmodified lines color: var(--bs-body-color); /* Use BS var */ }
.gemini-chat-header { .gakr-chat-header { padding: 0.75rem 1.5rem; display: flex; justify-content: space-between;2 unmodified lines height: 64px; }
.gemini-logo-area { .gakr-logo-area { display: flex; align-items: center; gap: 0.75rem; }
.gemini-brand-logo { .gakr-brand-logo { width: 24px; height: 24px; display: flex;1 unmodified line justify-content: center; }
.gemini-brand-text { .gakr-brand-text { font-size: 1.25rem; font-weight: 500; color: var(--gakr-blue); }
.gemini-chat-wrapper { .gakr-chat-wrapper { flex: 1; overflow: hidden; position: relative;1 unmodified line flex-direction: column; }
.gemini-chat-container { .gakr-chat-container { flex: 1; overflow-y: auto; padding: 1rem;5 unmodified lines margin: 0 auto; }
.gemini-prompt-area { .gakr-prompt-area { padding: 1rem; border-top: 1px solid var(--bs-border-color); width: 100%;4 unmodified lines /* --- END MODIFIED CSS --- */ }
.gemini-message { .gakr-message { display: flex; flex-direction: column; gap: 0.5rem; max-width: 90%; }
.gemini-message-user { .gakr-message-user { align-self: flex-end; }
.gemini-message-ai { .gakr-message-ai { align-self: flex-start; }
.gemini-message-header { .gakr-message-header { display: flex; align-items: center; gap: 0.5rem;1 unmodified line color: var(--bs-secondary-color); }
.gemini-message-avatar { .gakr-message-avatar { width: 24px; height: 24px; border-radius: 50%;3 unmodified lines font-size: 0.75rem; }
.gemini-message-content { .gakr-message-content { padding: 1rem; border-radius: 12px; line-height: 1.5;2 unmodified lines word-break: break-word; }
.gemini-message-user .gemini-message-content { .gakr-message-user .gakr-message-content { background-color: var(--bs-tertiary-bg); border-top-right-radius: 4px; }
.gemini-message-ai .gemini-message-content { .gakr-message-ai .gakr-message-content { background-color: rgba(66, 133, 244, 0.1); border-top-left-radius: 4px; }
.gemini-message-user .gemini-message-avatar { .gakr-message-user .gakr-message-avatar { background-color: var(--bs-tertiary-bg); }
.gemini-message-ai .gemini-message-avatar { .gakr-message-ai .gakr-message-avatar { background-color: rgba(66, 133, 244, 0.2); color: var(--gakr-blue); }
/* --- MODIFIED CSS FOR INPUT/TEXTAREA AND ACTIONS --- */ .gemini-input-container { .gakr-input-container { position: relative; /* Keep relative */ border-radius: 24px; border: 1px solid var(--bs-border-color);11 unmodified lines }
/* Style when the container or its children are focused */ .gemini-input-container:focus-within { .gakr-input-container:focus-within { border-color: var(--gakr-blue); box-shadow: 0 1px 8px rgba(66, 133, 244, 0.2); background: var(--bs-body-bg); }
/* Style the textarea (#userInput) */ .gemini-input { /* Targets the textarea with id="userInput" */ .gakr-input { /* Targets the textarea with id="userInput" */ flex: 1; /* Textarea takes available space */ border: none; background: transparent;17 unmodified lines transition: height 0.3s ease-in-out; /* Animate height change */ }
.gemini-input:focus { .gakr-input:focus { outline: none; }
.gemini-input-actions { .gakr-input-actions { display: flex; /* --- MODIFIED: align-items to flex-end for textarea --- */ align-items: flex-end;5 unmodified lines flex-shrink: 0; /* Prevent shrinking */ }
/* Reusing .gemini-action-button styles for new '+' button */ .gemini-action-button { /* Reusing .gakr-action-button styles for new '+' button */ .gakr-action-button { width: 36px; height: 36px; border-radius: 50%;6 unmodified lines transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out; }
.gemini-action-button:hover { .gakr-action-button:hover { background-color: var(--bs-tertiary-bg); /* Use BS var */ color: var(--bs-body-color); /* Darken icon color slightly on hover */ }
.gemini-action-button:active { .gakr-action-button:active { transform: scale(0.95); /* Slight press effect */ background-color: var(--bs-tertiary-bg); /* Keep hover bg on active */ color: var(--bs-body-color); transition: background-color 0s, transform 0.1s; /* Make feedback immediate */ }
.gemini-submit-button { .gakr-submit-button { color: var(--gakr-blue); /* Use CSS var */ }
/* Specific styles for submit button hover/active */ .gemini-submit-button:hover { .gakr-submit-button:hover { background-color: var(--gakr-blue-light); /* Light blue background on hover */ color: var(--gakr-blue-dark); /* Darker blue icon on hover */ }
.gemini-submit-button:active { .gakr-submit-button:active { transform: scale(0.95); /* Slight press effect */ background-color: var(--gakr-blue-light); color: var(--gakr-blue-dark); transition: background-color 0s, transform 0.1s; }
.gemini-submit-button.disabled { .gakr-submit-button.disabled { opacity: 0.5; cursor: default; /* Ensure transitions are off when disabled to avoid weird states */ transition: none; }
.gemini-submit-button.disabled:hover { .gakr-submit-button.disabled:hover { background-color: transparent; color: var(--gakr-blue); /* Keep original color when disabled */ } /* --- END MODIFIED CSS --- */
.gemini-typing { .gakr-typing { display: inline-flex; align-items: center; gap: 4px;4 unmodified lines align-self: flex-end; }
.gemini-typing-dot { .gakr-typing-dot { width: 6px; height: 6px; border-radius: 50%;1 unmodified line animation: typing 1.3s infinite ease-in-out; }
.gemini-typing-dot:nth-child(1) { animation-delay: 0s; } .gemini-typing-dot:nth-child(2) { animation-delay: 0.2s; } .gemini-typing-dot:nth-child(3) { animation-delay: 0.4s; } .gakr-typing-dot:nth-child(1) { animation-delay: 0s; } .gakr-typing-dot:nth-child(2) { animation-delay: 0.2s; } .gakr-typing-dot:nth-child(3) { animation-delay: 0.4s; }
.gemini-thinking-toggle { .gakr-thinking-toggle { background: none; border: none; color: var(--gakr-blue);4 unmodified lines text-decoration: underline; }
.gemini-thinking-content { .gakr-thinking-content { display: block; margin-top: 0.5rem; padding: 0.5rem;2 unmodified lines font-style: italic; }
.gemini-welcome { .gakr-welcome { text-align: center; max-width: 600px; margin: 4rem auto; }
.gemini-welcome-icon { .gakr-welcome-icon { font-size: 3rem; margin-bottom: 1.5rem; color: var(--gakr-blue); }
.gemini-welcome-title { .gakr-welcome-title { font-size: 2rem; margin-bottom: 1rem; font-weight: 500; }
/* Login button styling (from homepage) */ .gemini-login-button { .gakr-login-button { color: var(--gakr-blue); text-decoration: none; background: transparent;4 unmodified lines transition: background-color 0.2s; }
.gemini-login-button:hover { .gakr-login-button:hover { background-color: rgba(66, 133, 244, 0.1); }
/* Profile button styling */ .gakr-profile-button { color: var(--gakr-blue); text-decoration: none; background: transparent; border: 1px solid var(--gakr-blue); padding: 0.5rem 1rem; border-radius: 50px; font-size: 0.9rem; transition: background-color 0.2s; display: inline-flex; align-items: center; gap: 0.5rem; }
.gakr-profile-button:hover { background-color: rgba(66, 133, 244, 0.1); }
/* Login prompt modal (keep existing) */ .gemini-login-prompt { .gakr-login-prompt { position: fixed; top: 0; left: 0;9 unmodified lines transition: opacity 0.3s, visibility 0.3s; }
.gemini-login-prompt.show { .gakr-login-prompt.show { opacity: 1; visibility: visible; }
.gemini-login-prompt-content { .gakr-login-prompt-content { background-color: var(--bs-body-bg); border-radius: 12px; padding: 1.5rem;1 unmodified line width: 90%; }
.gemini-login-prompt-title { .gakr-login-prompt-title { font-size: 1.25rem; font-weight: 500; margin-bottom: 1rem; color: var(--gakr-blue); }
.gemini-login-prompt-buttons { .gakr-login-prompt-buttons { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.5rem; }
.gemini-button-primary { .gakr-button-primary { background-color: var(--gakr-blue); color: white; border: none;6 unmodified lines transition: background-color 0.2s; }
.gemini-button-primary:hover { .gakr-button-primary:hover { background-color: #3b78e7; }
.gemini-button-secondary { .gakr-button-secondary { background-color: transparent; color: var(--gakr-blue); border: 1px solid var(--gakr-blue);6 unmodified lines transition: background-color 0.2s; }
.gemini-button-secondary:hover { .gakr-button-secondary:hover { background-color: rgba(66, 133, 244, 0.1); }
.gemini-button-text { .gakr-button-text { background-color: transparent; color: var(--bs-body-color); border: none;6 unmodified lines transition: background-color 0.2s; }
.gemini-button-text:hover { .gakr-button-text:hover { background-color: var(--bs-tertiary-bg); }
128 unmodified lines </style></head><body> <div class="gemini-chat-layout"> <header class="gemini-chat-header"> <div class="gemini-logo-area"> <a href="/" class="gemini-brand-logo"> <div class="gakr-chat-layout"> <header class="gakr-chat-header"> <div class="gakr-logo-area"> <a href="/" class="gakr-brand-logo"> <i class="fas fa-robot" style="color: var(--gakr-blue);"></i> </a> <a href="/" class="gemini-brand-text" style="text-decoration: none;">GAKR AI</a> <a href="/" class="gakr-brand-text" style="text-decoration: none;">GAKR AI</a> </div>
<div class="gemini-nav-controls"> <a href="auth.html" class="gemini-login-button">Sign in / Register</a> <div class="gakr-nav-controls"> <a href="/auth" class="gakr-login-button">Sign in / Register</a> </div> </header>
<div class="gemini-chat-wrapper"> <div class="gemini-chat-container" id="chatContainer"> <div class="gemini-welcome" id="welcomeMessage"> <div class="gemini-welcome-icon"> <div class="gakr-chat-wrapper"> <div class="gakr-chat-container" id="chatContainer"> <div class="gakr-welcome" id="welcomeMessage"> <div class="gakr-welcome-icon"> <i class="fas fa-robot"></i> </div> <h1 class="gemini-welcome-title">How can I help you today?</h1> <h1 class="gakr-welcome-title">How can I help you today?</h1> <p>I'm GAKR AI, your AI assistant. Ask me anything!</p> </div>
<div class="gemini-message gemini-message-ai d-none" id="initialMessage"> <div class="gemini-message-header"> <div class="gemini-message-avatar"> <div class="gakr-message gakr-message-ai d-none" id="initialMessage"> <div class="gakr-message-header"> <div class="gakr-message-avatar"> <i class="fas fa-robot"></i> </div> <span>GAKR AI</span> </div> <div class="gemini-message-content">Hello! I'm GAKR AI How can I help you today? <div class="gakr-message-content">Hello! I'm GAKR AI How can I help you today? </div> </div>
<div class="gemini-typing d-none" id="typingIndicator"> <div class="gemini-typing-dot"></div> <div class="gemini-typing-dot"></div> <div class="gemini-typing-dot"></div> <div class="gakr-typing d-none" id="typingIndicator"> <div class="gakr-typing-dot"></div> <div class="gakr-typing-dot"></div> <div class="gakr-typing-dot"></div> </div> </div>
<div class="gemini-prompt-area"> <div class="gemini-input-container" id="inputContainer"> <div class="gemini-action-button" id="addButton"> <div class="gakr-prompt-area"> <div class="gakr-input-container" id="inputContainer"> <div class="gakr-action-button" id="addButton"> <i class="fas fa-plus"></i> </div> <div class="attached-file-preview-container" id="attachedFilePreviewContainer"> </div> <textarea class="gemini-input" id="userInput" placeholder="Message GAKR AI..." rows="1"></textarea> <textarea class="gakr-input" id="userInput" placeholder="Message GAKR AI..." rows="1"></textarea>
<div class="gemini-input-actions"> <div class="gemini-action-button"> <div class="gakr-input-actions"> <div class="gakr-action-button"> <i class="fas fa-microphone"></i> </div> <div class="gemini-action-button gemini-submit-button disabled" id="submitButton"> <div class="gakr-action-button gakr-submit-button disabled" id="submitButton"> <i class="fas fa-arrow-right"></i> </div> </div>23 unmodified lines </div> </div>
<div class="gemini-login-prompt" id="loginPrompt"> <div class="gemini-login-prompt-content"> <div class="gemini-login-prompt-title">Continue with GAKR AI</div> <div class="gakr-login-prompt" id="loginPrompt"> <div class="gakr-login-prompt-content"> <div class="gakr-login-prompt-title">Continue with GAKR AI</div> <p>You've had 5 conversations with GAKR AI. Would you like to create an account to save your history?</p> <div class="gemini-login-prompt-buttons"> <a href="login.html" class="gemini-button-primary">Sign in</a> <a href="/login?signup=true" class="gemini-button-secondary">Create account</a> <button type="button" class="gemini-button-text" id="continueGuest">Continue as guest</button> <div class="gakr-login-prompt-buttons"> <a href="login.html" class="gakr-button-primary">Sign in / Register</a> <a href="/login?signup=true" class="gakr-button-secondary">Create account</a> <button type="button" class="gakr-button-text" id="continueGuest">Continue as guest</button> </div> </div> </div>21 unmodified lines let messageCount = 0; let attachedFiles = [];
// Simple login flag (set in auth flow: localStorage.setItem("gakr_is_logged_in","true")) const isLoggedIn = localStorage.getItem("gakr_is_logged_in") === "true"; // Simple login flag (set in auth flow: localStorage.setItem("isLoggedIn","true")) const isLoggedIn = localStorage.getItem("isLoggedIn") === "true";
// Update header based on login status updateHeader();
function updateHeader() { const navControls = document.querySelector('.gakr-nav-controls'); if (isLoggedIn) { navControls.innerHTML = '<a href="/profile" class="gakr-profile-button"><i class="fas fa-user"></i> Profile</a>'; } else { navControls.innerHTML = '<a href="/auth" class="gakr-login-button">Sign in / Register</a>'; } }
// --- Textarea Auto-Grow & Scroll Logic (original, kept) --- const style = getComputedStyle(userInput);3 unmodified lines
const initialInputContainerPaddingTop = parseFloat(getComputedStyle(inputContainer).paddingTop); const initialInputContainerPaddingBottom = parseFloat(getComputedStyle(inputContainer).paddingBottom); const initialActionButtonsHeight = document.querySelector('.gemini-input-actions').offsetHeight; const initialActionButtonsHeight = document.querySelector('.gakr-input-actions').offsetHeight;
function autoGrowTextarea() { if (!userInput) {51 unmodified lines } });
// Handle microphone button click const microphoneButton = document.querySelector('.gakr-input-actions .gakr-action-button:first-child'); if (microphoneButton) { microphoneButton.addEventListener('click', function() { alert('Voice input feature is currently in development.'); }); }
// Existing “continue as guest” modal continueGuest.addEventListener('click', function() { loginPrompt.classList.remove('show');176 unmodified lines });
loginBtn.addEventListener('click', function () { window.location.href = 'auth.html'; window.location.href = '/auth'; });
buttonRow.appendChild(skipBtn);42 unmodified lines scrollToBottom();
const formData = new FormData(); formData.append('api_key', 'gakr-ai-2025-secret'); formData.append('prompt', text);
if (filesSnapshot.length > 0) {46 unmodified lines
function addMessage(text, type, streaming = false) { const messageDiv = document.createElement('div'); messageDiv.className = `gemini-message gemini-message-${type}`; messageDiv.className = `gakr-message gakr-message-${type}`;
const headerDiv = document.createElement('div'); headerDiv.className = 'gemini-message-header'; headerDiv.className = 'gakr-message-header';
const avatarDiv = document.createElement('div'); avatarDiv.className = 'gemini-message-avatar'; avatarDiv.className = 'gakr-message-avatar';
const avatarIcon = document.createElement('i'); avatarIcon.className = type === 'user' ? 'fas fa-user' : 'fas fa-robot';2 unmodified lines nameSpan.textContent = type === 'user' ? 'You' : 'GAKR AI';
const contentDiv = document.createElement('div'); contentDiv.className = 'gemini-message-content'; contentDiv.className = 'gakr-message-content'; if (!streaming) { if (type === 'ai') { updateAIMessage(contentDiv, text);30 unmodified lines
// Create toggle button const toggleButton = document.createElement('button'); toggleButton.className = 'gemini-thinking-toggle'; toggleButton.className = 'gakr-thinking-toggle'; toggleButton.textContent = 'hide thinking'; toggleButton.onclick = function() { const thinkingDiv = this.nextElementSibling;8 unmodified lines
// Create thinking content div const thinkingDiv = document.createElement('div'); thinkingDiv.className = 'gemini-thinking-content'; thinkingDiv.className = 'gakr-thinking-content'; thinkingDiv.textContent = thinking;
contentDiv.appendChild(toggleButton);12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090<!DOCTYPE html><html lang="en" data-bs-theme="dark"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>GAKR AI - Profile</title> <script> // Immediate check for login status if (localStorage.getItem('isLoggedIn') !== 'true') { window.location.href = '/auth'; } </script> <link rel="stylesheet" href="https://cdn.replit.com/agent/bootstrap-agent-dark-theme.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <style> /* ======================================== Base & Layout Styles ======================================== */ :root { --gakr-blue: #007bff; /* A vibrant blue for accents */ --gakr-blue-dark: #0056b3; /* Darker shade for hover/active states */ --gakr-blue-light: #e0f0ff; /* Lighter shade for selected states */ --gakr-blue-rgb: 0, 123, 255; /* RGB for translucent backgrounds */
/* Dark theme specifics (from replit's bootstrap-agent-dark-theme.min.css for consistency) */ --bs-body-bg: #1a1a1a; /* Dark background */ --bs-body-color: #f0f0f0; /* Light text */ --bs-primary: var(--gakr-blue); --bs-secondary: #6c757d; --bs-secondary-bg: #2a2a2a; /* Slightly lighter dark background */ --bs-tertiary-bg: #3a3a3a; /* Even lighter dark background for elements */ --bs-border-color: #4a4a4a; /* Border color */ --bs-link-color: var(--gakr-blue); --bs-link-hover-color: var(--gakr-blue-dark); --bs-heading-color: #f8f9fa; /* Lighter headings */ --bs-tertiary-color: #adb5bd; /* For less prominent text */ --bs-success: #28a745; --bs-info: #17a2b8; --bs-warning: #ffc107; --bs-danger: #dc3545; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(--bs-body-bg); color: var(--bs-body-color); margin: 0; padding-top: 64px; display: flex; flex-direction: column; min-height: 100vh; }
.gakr-layout { display: flex; flex-direction: column; min-height: 100vh; width: 100%; max-width: 1200px; /* Max width for content */ margin: 0 auto; /* Center the layout */ box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); /* Subtle shadow */ background-color: var(--bs-body-bg); /* Ensure content area matches body bg */ }
/* ======================================== Header Styles ======================================== */ .gakr-chat-header { padding: 0.75rem 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--bs-border-color); height: 64px; position: fixed; top: 0; left: 0; right: 0; width: 100%; background-color: var(--bs-body-bg); z-index: 10; }
.gakr-logo-area { display: flex; align-items: center; gap: 0.75rem; }
.gakr-brand-logo { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.gakr-brand-text { font-size: 1.25rem; font-weight: 500; color: var(--gakr-blue); }
.gakr-nav-controls { display: flex; align-items: center; }
.gakr-login-button { color: var(--gakr-blue); text-decoration: none; background: transparent; border: 1px solid var(--gakr-blue); padding: 0.5rem 1rem; border-radius: 50px; font-size: 0.9rem; transition: background-color 0.2s; }
.gakr-login-button:hover { background-color: rgba(66, 133, 244, 0.1); }
.gakr-profile-button { color: var(--gakr-blue); text-decoration: none; background: transparent; border: none; padding: 0.5rem 1rem; border-radius: 50px; font-size: 0.9rem; transition: background-color 0.2s; display: flex; align-items: center; gap: 0.5rem; }
.gakr-profile-button:hover { background-color: rgba(66, 133, 244, 0.1); }
/* ======================================== Profile Button & Dropdown ======================================== */ .profile-nav-controls { position: relative; z-index: 1001; /* Ensure dropdown is above other content */ }
.profile-button { width: 40px; height: 40px; border-radius: 50%; background-color: var(--gakr-blue); color: white; display: flex; justify-content: center; align-items: center; font-size: 1.2rem; font-weight: bold; cursor: pointer; transition: background-color 0.2s ease; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); }
.profile-button:hover { background-color: var(--gakr-blue-dark); }
.profile-dropdown-menu { position: absolute; top: calc(100% + 10px); right: 0; background-color: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); border-radius: 8px; min-width: 180px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); opacity: 0; visibility: hidden; transform: translateY(-10px); transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease; padding: 0.5rem 0; z-index: 100; }
.profile-dropdown-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }
.profile-dropdown-item { display: block; padding: 0.8rem 1.2rem; color: var(--bs-body-color); text-decoration: none; font-size: 0.95rem; transition: background-color 0.2s ease, color 0.2s ease; }
.profile-dropdown-item:hover { background-color: var(--bs-secondary-bg); color: var(--gakr-blue); }
/* ======================================== Profile View Specific Styles ======================================== */ .profile-view { flex-grow: 1; padding: 2rem; background-color: var(--bs-body-bg); /* Main content background */ display: flex; flex-direction: column; gap: 2rem; }
.profile-header-section { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--bs-border-color); }
.profile-avatar-large { width: 120px; height: 120px; border-radius: 50%; background-color: var(--gakr-blue); color: white; display: flex; justify-content: center; align-items: center; font-size: 4rem; font-weight: bold; margin-bottom: 1rem; border: 4px solid var(--bs-tertiary-bg); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); position: relative; /* For the edit icon */ overflow: hidden; /* To clip avatar images */ }
.profile-avatar-large img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-avatar-edit-icon { position: absolute; bottom: 5px; right: 5px; background-color: var(--bs-tertiary-bg); border-radius: 50%; width: 30px; height: 30px; display: flex; justify-content: center; align-items: center; cursor: pointer; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); transition: background-color 0.2s ease; color: var(--bs-body-color); }
.profile-avatar-edit-icon:hover { background-color: var(--bs-secondary-bg); color: var(--gakr-blue); }
.profile-username-container { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.profile-username { font-size: 2.2rem; font-weight: 700; color: var(--bs-heading-color); margin: 0; line-height: 1; }
.username-edit-icon, .section-edit-icon { color: var(--bs-secondary-color); cursor: pointer; font-size: 1.1rem; transition: color 0.2s ease; }
.username-edit-icon:hover, .section-edit-icon:hover { color: var(--gakr-blue); }
.username-input-container { display: none; /* Hidden by default, toggled by JS */ align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; width: 100%; max-width: 300px; }
.username-edit-input { flex-grow: 1; padding: 0.6rem 0.8rem; border-radius: 8px; border: 1px solid var(--bs-border-color); background-color: var(--bs-secondary-bg); color: var(--bs-body-color); font-size: 1.1rem; outline: none; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2); } .username-edit-input::placeholder { color: var(--bs-tertiary-color); } .username-edit-input:focus { border-color: var(--gakr-blue); box-shadow: 0 0 0 0.25rem rgba(var(--gakr-blue-rgb), 0.25); }
.username-save-button { padding: 0.6rem 1.2rem; border-radius: 8px; background-color: var(--gakr-blue); color: white; border: none; cursor: pointer; font-size: 1rem; transition: background-color 0.2s ease; }
.username-save-button:hover { background-color: var(--gakr-blue-dark); }
.profile-email { font-size: 1.1rem; color: var(--bs-secondary-color); margin: 0; }
.profile-section { background-color: var(--bs-secondary-bg); border-radius: 12px; padding: 1.5rem 2rem; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15); display: flex; flex-direction: column; gap: 1rem; }
.profile-section-title { font-size: 1.6rem; color: var(--bs-heading-color); margin-top: 0; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--bs-border-color); display: flex; align-items: center; gap: 0.75rem; }
.profile-info-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px dashed var(--bs-border-color); } .profile-info-item:last-child { border-bottom: none; }
.profile-info-label { font-weight: 500; color: var(--bs-tertiary-color); flex-basis: 30%; /* Adjust as needed */ }
.profile-info-value { color: var(--bs-body-color); text-align: right; flex-basis: 70%; /* Adjust as needed */ }
/* About Me specific styles */ .profile-about-me-display { color: var(--bs-body-color); line-height: 1.6; margin-bottom: 1rem; background-color: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: 8px; padding: 1rem; min-height: 80px; overflow-y: auto; } .profile-about-me-display.placeholder { color: var(--bs-tertiary-color); font-style: italic; }
.about-me-edit-icon { margin-left: auto; /* Push icon to the right if title is flex */ }
.about-me-input-container { display: none; /* Hidden by default */ flex-direction: column; /* Stack textarea and button */ gap: 0.75rem; }
.about-me-edit-textarea { width: 100%; padding: 0.8rem; border-radius: 8px; border: 1px solid var(--bs-border-color); background-color: var(--bs-body-bg); color: var(--bs-body-color); font-size: 1rem; min-height: 120px; resize: vertical; outline: none; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2); } .about-me-edit-textarea::placeholder { color: var(--bs-tertiary-color); } .about-me-edit-textarea:focus { border-color: var(--gakr-blue); box-shadow: 0 0 0 0.25rem rgba(var(--gakr-blue-rgb), 0.25); }
.about-me-save-button { align-self: flex-end; /* Align to the right */ padding: 0.7rem 1.5rem; border-radius: 8px; background-color: var(--gakr-blue); color: white; border: none; cursor: pointer; font-size: 1rem; transition: background-color 0.2s ease; }
.about-me-save-button:hover { background-color: var(--gakr-blue-dark); }
/* Chat History Styles */ .profile-chat-history { display: flex; flex-direction: column; gap: 1rem; }
.chat-history-item { background-color: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: 12px; padding: 1rem 1.2rem; cursor: pointer; transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease; position: relative; /* For context menu positioning */ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); }
.chat-history-item:hover { background-color: var(--bs-secondary-bg); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); }
.chat-history-item .chat-title-wrapper { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.chat-history-item .chat-title { font-size: 1.15rem; font-weight: 600; color: var(--bs-heading-color); flex-grow: 1; /* Allows title to take available space */ }
.chat-history-item .chat-meta { font-size: 0.85rem; color: var(--bs-secondary-color); display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.empty-chat-history { text-align: center; color: var(--bs-tertiary-color); font-style: italic; padding: 2rem; }
/* Profile Buttons Area */ .profile-buttons-area { display: flex; flex-direction: column; align-items: center; gap: 1rem; margin-top: 2rem; padding-top: 2rem; border-top: 1px solid var(--bs-border-color); }
.gakr-button-primary, .gakr-button-secondary { display: inline-flex; align-items: center; justify-content: center; padding: 0.8rem 1.5rem; border-radius: 10px; font-size: 1rem; font-weight: 500; text-decoration: none; transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; width: 100%; max-width: 300px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }
.gakr-button-primary { background-color: var(--gakr-blue); color: white; border: 1px solid var(--gakr-blue); }
.gakr-button-primary:hover { background-color: var(--gakr-blue-dark); border-color: var(--gakr-blue-dark); color: white; }
.gakr-button-secondary { background-color: transparent; color: var(--gakr-blue); border: 1px solid var(--gakr-blue); }
.gakr-button-secondary:hover { background-color: var(--gakr-blue-light); color: var(--gakr-blue-dark); border-color: var(--gakr-blue-dark); }
.me-2 { /* Margin End (right) */ margin-right: 0.5rem; }
/* ======================================== Footer Styles ======================================== */ .gakr-footer { padding: 1rem 1.5rem; background-color: var(--bs-tertiary-bg); border-top: 1px solid var(--bs-border-color); text-align: center; font-size: 0.9rem; color: var(--bs-secondary-color); margin-top: auto; /* Push footer to the bottom */ }
/* ======================================== Toast Notification Styles ======================================== */ .toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; z-index: 2000; /* Above all other content */ }
.gakr-toast { background-color: var(--bs-tertiary-bg); color: var(--bs-body-color); padding: 12px 20px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); display: flex; align-items: center; gap: 10px; min-width: 250px; opacity: 0; transform: translateY(20px); transition: opacity 0.3s ease-out, transform 0.3s ease-out; border: 1px solid var(--bs-border-color); }
.gakr-toast.show { opacity: 1; transform: translateY(0); }
.gakr-toast.hide { opacity: 0; transform: translateY(20px); }
.gakr-toast .toast-icon { font-size: 1.2rem; }
.gakr-toast.success { border-left: 5px solid var(--bs-success); } .gakr-toast.success .toast-icon { color: var(--bs-success); }
.gakr-toast.error { border-left: 5px solid var(--bs-danger); } .gakr-toast.error .toast-icon { color: var(--bs-danger); }
.gakr-toast.warning { border-left: 5px solid var(--bs-warning); } .gakr-toast.warning .toast-icon { color: var(--bs-warning); }
.gakr-toast.info { border-left: 5px solid var(--bs-info); } .gakr-toast.info .toast-icon { color: var(--bs-info); }
/* ======================================== Custom Modal Styles (Confirm/Prompt) ======================================== */ .gakr-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent dark overlay */ display: flex; justify-content: center; align-items: center; z-index: 1500; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.gakr-modal-overlay.show { opacity: 1; visibility: visible; }
.gakr-modal-content { background-color: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); padding: 2rem; width: 90%; max-width: 450px; text-align: center; transform: translateY(-20px) scale(0.95); opacity: 0; transition: transform 0.3s ease-out, opacity 0.3s ease-out; }
.gakr-modal-overlay.show .gakr-modal-content { transform: translateY(0) scale(1); opacity: 1; }
.gakr-modal-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; color: var(--bs-heading-color); }
.gakr-modal-message { font-size: 1rem; color: var(--bs-body-color); margin-bottom: 1.5rem; line-height: 1.5; }
.gakr-modal-input { width: calc(100% - 20px); /* Account for padding */ padding: 0.8rem 10px; margin-bottom: 1.5rem; border: 1px solid var(--bs-border-color); border-radius: 8px; background-color: var(--bs-secondary-bg); color: var(--bs-body-color); font-size: 1rem; outline: none; }
.gakr-modal-input:focus { border-color: var(--gakr-blue); box-shadow: 0 0 0 0.2rem rgba(var(--gakr-blue-rgb), 0.25); }
.gakr-modal-buttons { display: flex; justify-content: center; gap: 1rem; }
.gakr-modal-buttons button { padding: 0.7rem 1.5rem; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out; }
.confirm-ok, .prompt-submit { background-color: var(--gakr-blue); color: white; border: none; }
.confirm-ok:hover, .prompt-submit:hover { background-color: var(--gakr-blue-dark); }
.confirm-cancel, .prompt-cancel { background-color: transparent; color: var(--gakr-blue); border: 1px solid var(--gakr-blue); }
.confirm-cancel:hover, .prompt-cancel:hover { background-color: var(--gakr-blue-light); color: var(--gakr-blue-dark); border-color: var(--gakr-blue-dark); }
/* ======================================== Advanced Features Styles (New) ======================================== */ .chat-history-item.pinned { background-color: var(--bs-secondary-bg); border-left: 5px solid var(--gakr-blue); padding-left: calc(1rem - 5px); /* Adjust padding due to border */ } .pinned-icon { color: var(--gakr-blue); font-size: 0.9em; margin-left: 0.5rem; vertical-align: middle; }
.chat-history-item .chat-tags { font-size: 0.8rem; color: var(--bs-secondary-color); margin-top: 0.5rem; } .chat-history-item .chat-tags span { background-color: rgba(var(--gakr-blue-rgb), 0.1); color: var(--gakr-blue); padding: 0.2rem 0.6rem; border-radius: 12px; /* Pill shape */ margin-right: 0.4rem; display: inline-block; margin-bottom: 0.4rem; /* For multiple lines of tags */ white-space: nowrap; /* Prevent tags from breaking */ } .chat-history-item .chat-tags span:last-child { margin-right: 0; }
.chat-history-search-container { position: relative; margin-bottom: 1rem; width: 100%; max-width: 400px; /* Limit search input width */ align-self: center; /* Center if flex container */ } .chat-history-search-input { width: 100%; padding: 0.6rem 2.5rem 0.6rem 1rem; /* Adjust padding for icon */ border-radius: 8px; border: 1px solid var(--bs-border-color); background-color: var(--bs-body-bg); color: var(--bs-body-color); font-size: 0.95rem; outline: none; } .chat-history-search-input:focus { border-color: var(--gakr-blue); box-shadow: 0 0 0 0.25rem rgba(var(--gakr-blue-rgb), 0.25); } .chat-history-search-icon { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); pointer-events: none; /* Make icon not interfere with input clicks */ }
.chat-history-sort-container { margin-bottom: 1rem; display: flex; justify-content: flex-end; /* Align to the right */ align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--bs-secondary-color); } .chat-history-sort-select { background-color: var(--bs-tertiary-bg); color: var(--bs-body-color); border: 1px solid var(--bs-border-color); border-radius: 8px; padding: 0.3rem 0.6rem; font-size: 0.9rem; cursor: pointer; outline: none; -webkit-appearance: none; /* Remove default arrow */ -moz-appearance: none; appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f0f0f0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3Csvg%3E"); background-repeat: no-repeat; background-position: right 0.5rem center; background-size: 1em; } .chat-history-sort-select:focus { border-color: var(--gakr-blue); box-shadow: 0 0 0 0.25rem rgba(var(--gakr-blue-rgb), 0.25); }
.chat-history-last-active { font-size: 0.75rem; color: var(--bs-tertiary-color); margin-left: auto; /* Push to the right */ }
/* Chat Context Menu */ .chat-context-menu { position: fixed; /* Fixed position relative to viewport */ background-color: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); border-radius: 8px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); min-width: 150px; padding: 0.5rem 0; z-index: 1002; /* Above profile dropdown */ opacity: 0; visibility: hidden; transform: scale(0.95); transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease; }
.chat-context-menu.show { opacity: 1; visibility: visible; transform: scale(1); }
.chat-context-menu-item { display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 1.2rem; color: var(--bs-body-color); text-decoration: none; font-size: 0.9rem; transition: background-color 0.2s ease, color 0.2s ease; }
.chat-context-menu-item:hover { background-color: var(--bs-secondary-bg); color: var(--gakr-blue); }
.chat-context-menu-item i { width: 1.2rem; /* Align icons */ text-align: center; }
/* Tag Selection Modal */ .tag-selection-modal-content { background-color: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); padding: 1.5rem; width: 90%; max-width: 500px; text-align: left; transform: translateY(-20px) scale(0.95); opacity: 0; transition: transform 0.3s ease-out, opacity 0.3s ease-out; } .gakr-modal-overlay.show .tag-selection-modal-content { transform: translateY(0) scale(1); opacity: 1; } .tag-selection-modal-title { font-size: 1.3rem; font-weight: 600; margin-bottom: 1rem; color: var(--bs-heading-color); padding-bottom: 0.5rem; border-bottom: 1px solid var(--bs-border-color); } .tag-options-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); /* Responsive grid */ gap: 0.75rem; margin-bottom: 1.5rem; } .tag-option { background-color: var(--bs-secondary-bg); color: var(--bs-body-color); border: 1px solid var(--bs-border-color); border-radius: 8px; padding: 0.5rem 0.8rem; cursor: pointer; text-align: center; transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease; font-size: 0.9rem; display: flex; justify-content: center; align-items: center; } .tag-option:hover { background-color: var(--bs-tertiary-bg); border-color: var(--gakr-blue); } .tag-option.selected { background-color: var(--gakr-blue); color: white; border-color: var(--gakr-blue-dark); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); } .tag-option.selected:hover { background-color: var(--gakr-blue-dark); border-color: var(--gakr-blue-dark); } .tag-actions { display: flex; justify-content: flex-end; gap: 1rem; padding-top: 1rem; border-top: 1px solid var(--bs-border-color); } .tag-actions button { padding: 0.6rem 1rem; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out; } .tag-actions .confirm-ok { background-color: var(--gakr-blue); color: white; border: none; } .tag-actions .confirm-ok:hover { background-color: var(--gakr-blue-dark); } .tag-actions .confirm-cancel { background-color: transparent; color: var(--gakr-blue); border: 1px solid var(--gakr-blue); } .tag-actions .confirm-cancel:hover { background-color: var(--gakr-blue-light); color: var(--gakr-blue-dark); border-color: var(--gakr-blue-dark); }
/* ======================================== Responsive Adjustments (Optional but Recommended) ======================================== */ @media (max-width: 768px) { .gakr-header { padding: 0.8rem 1rem; } .profile-view { padding: 1rem; gap: 1.5rem; } .profile-header-section { margin-bottom: 1.5rem; } .profile-username { font-size: 1.8rem; } .profile-email { font-size: 1rem; } .profile-section { padding: 1rem 1.2rem; } .profile-section-title { font-size: 1.4rem; } .profile-info-item { flex-direction: column; align-items: flex-start; gap: 0.2rem; } .profile-info-label { flex-basis: auto; font-size: 0.9rem; } .profile-info-value { flex-basis: auto; text-align: left; font-size: 0.95rem; } .profile-buttons-area { margin-top: 1.5rem; padding-top: 1.5rem; } .gakr-button-primary, .gakr-button-secondary { max-width: none; /* Full width on small screens */ } .chat-history-sort-container { justify-content: flex-start; /* Align left on small screens */ } .tag-options-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 0.5rem; } .tag-option { padding: 0.4rem 0.6rem; font-size: 0.8rem; } }
@media (max-width: 480px) { .gakr-brand-text { font-size: 1.3rem; } .profile-avatar-large { width: 90px; height: 90px; font-size: 3rem; } .profile-username { font-size: 1.5rem; } .username-edit-input, .username-save-button { font-size: 0.9rem; padding: 0.5rem 0.8rem; } .about-me-edit-textarea, .about-me-save-button { font-size: 0.9rem; padding: 0.6rem 1rem; } .chat-history-item { padding: 0.8rem 1rem; } .chat-history-item .chat-title { font-size: 1rem; } .chat-history-item .chat-meta { font-size: 0.75rem; } .chat-history-sort-select { font-size: 0.85rem; padding: 0.2rem 0.5rem; } .gakr-modal-content { padding: 1.5rem; } .gakr-modal-title { font-size: 1.3rem; } .gakr-modal-message { font-size: 0.9rem; } .gakr-modal-buttons button { padding: 0.5rem 1rem; font-size: 0.9rem; } } </style></head><body class="on-profile-page"> <div class="gakr-layout"> <header class="gakr-chat-header"> <div class="gakr-logo-area"> <a href="/" class="gakr-brand-logo"> <i class="fas fa-robot" style="color: var(--gakr-blue);"></i> </a> <a href="/" class="gakr-brand-text" style="text-decoration: none;">GAKR AI</a> </div>
<div class="gakr-nav-controls" id="authButtonContainer"> <a href="/auth" class="gakr-login-button">Sign in / Register</a> </div> </header>
<div class="profile-view" id="profileView"> <div class="profile-header-section"> <div class="profile-avatar-large" id="profileAvatarLarge"> U <label for="avatarUpload" class="profile-avatar-edit-icon" title="Change Avatar"> <i class="fas fa-camera"></i> <input type="file" id="avatarUpload" accept="image/*" style="display: none;"> </label> </div> <div class="profile-username-container"> <h1 class="profile-username" id="profileUsernameDisplay">User Name</h1> <i class="fas fa-pencil-alt username-edit-icon" id="editUsernameIcon" title="Edit Username"></i> </div> <div class="username-input-container" id="usernameInputContainer"> <input type="text" id="usernameEditInput" class="username-edit-input" placeholder="Enter new username"> <button id="usernameSaveButton" class="username-save-button">Save</button> </div> <p class="profile-email" id="profileEmailDisplay">user.email@example.com</p> </div>
<div class="profile-section"> <h2 class="profile-section-title">Account Information</h2> <div class="profile-info-item"> <span class="profile-info-label">Name:</span> <span class="profile-info-value" id="accountName">User Name</span> </div> <div class="profile-info-item"> <span class="profile-info-label">Email:</span> <span class="profile-info-value" id="accountEmail">user.email@example.com</span> </div> </div>
<div class="profile-section"> <h2 class="profile-section-title"> About Me <i class="fas fa-pencil-alt section-edit-icon about-me-edit-icon" id="editAboutMeIcon" title="Edit About Me"></i> </h2> <div class="profile-about-me-display" id="profileAboutMeDisplay">Tell us something about yourself...</div> <div class="about-me-input-container" id="aboutMeInputContainer"> <textarea id="aboutMeEditInput" class="about-me-edit-textarea" placeholder="Write a short bio..."></textarea> <button id="aboutMeSaveButton" class="about-me-save-button">Save</button> </div> </div>
<div class="profile-section"> <h2 class="profile-section-title">Recent Conversations</h2> <div class="chat-history-search-container"> <input type="text" id="chatHistorySearchInput" class="chat-history-search-input" placeholder="Search conversations..."> <i class="fas fa-search chat-history-search-icon"></i> </div> <div class="profile-chat-history" id="chatHistoryList"> <p class="empty-chat-history" id="emptyChatHistoryMessage" style="display: none;">No conversations yet. Start chatting with GAKR AI!</p> </div> </div>
<div class="profile-buttons-area"> <a href="/chat" class="gakr-button-primary" id="startChattingButton"> <i class="fas fa-comments me-2"></i> Start Chatting with GAKR AI </a> <button type="button" class="gakr-button-primary" id="profileSettingsButton"> <i class="fas fa-cog me-2"></i> Settings</button>
<a href="#" class="gakr-button-secondary" id="profileLogoutButton" onclick="logoutFunction()"> <i class="fas fa-sign-out-alt me-2"></i> Log out </a> </div> </div>
<footer class="gakr-footer"> <div>GAKR AI - Powered by Advanced Local AI</div> </footer>
<div id="chatContextMenu" class="chat-context-menu"> <a href="#" class="chat-context-menu-item" data-action="delete"><i class="fas fa-trash-alt"></i> Delete</a> <a href="#" class="chat-context-menu-item" data-action="share"><i class="fas fa-share-alt"></i> Share</a> <a href="#" class="chat-context-menu-item pin-unpin" data-action="pin"><i class="fas fa-thumbtack"></i> Pin</a> <a href="#" class="chat-context-menu-item" data-action="tag"><i class="fas fa-tag"></i> Add Tag</a> </div> </div>
<div class="toast-container" id="toastContainer"></div>
<div class="gakr-modal-overlay" id="confirmModal"> <div class="gakr-modal-content"> <h3 class="gakr-modal-title" id="confirmTitle">Confirm Action</h3> <p class="gakr-modal-message" id="confirmMessage">Are you sure you want to proceed?</p> <div class="gakr-modal-buttons"> <button class="confirm-cancel" id="confirmCancelButton">Cancel</button> <button class="confirm-ok" id="confirmOkButton">Confirm</button> </div> </div> </div>
<div class="gakr-modal-overlay" id="promptModal"> <div class="gakr-modal-content"> <h3 class="gakr-modal-title" id="promptTitle">Enter Information</h3> <p class="gakr-modal-message" id="promptMessage">Please provide the required input:</p> <input type="text" class="gakr-modal-input" id="promptInput" placeholder="Enter text here..."> <div class="gakr-modal-buttons"> <button class="prompt-cancel" id="promptCancelButton">Cancel</button> <button class="prompt-submit" id="promptSubmitButton">Submit</button> </div> </div> </div>
<div class="gakr-modal-overlay" id="tagModal"> <div class="tag-selection-modal-content"> <h3 class="tag-selection-modal-title" id="tagModalTitle">Add Tag to Conversation</h3> <div class="tag-options-grid" id="tagOptions"> </div> <div class="tag-actions"> <button class="confirm-cancel" id="tagCancelButton">Cancel</button> <button class="confirm-ok" id="tagSaveButton">Save</button> </div> </div> </div>
<script> // Global modal elements let confirmModal, confirmTitle, confirmMessage, confirmOkButton, confirmCancelButton;
// Logout function - defined globally for onclick async function logoutFunction() { const confirmed = await showConfirmDialog('Are you sure you want to log out?', 'Logout Confirmation'); if (confirmed) { localStorage.removeItem('isLoggedIn'); sessionStorage.clear(); // Clear all session data window.location.href = '/'; // Redirect to home/login immediately } }
// Custom Confirm Dialog Function (Global) function showConfirmDialog(message, title = 'Confirm Action') { return new Promise((resolve) => { if (!confirmModal) { // Fallback if modal not loaded yet const confirmed = window.confirm(message); resolve(confirmed); return; }
confirmTitle.textContent = title; confirmMessage.textContent = message; confirmModal.classList.add('show');
// Store the element that triggered the modal for focus management const triggeringElement = document.activeElement;
const handleOk = () => { confirmModal.classList.remove('show'); confirmOkButton.removeEventListener('click', handleOk); confirmCancelButton.removeEventListener('click', handleCancel); if (triggeringElement) triggeringElement.focus(); // Return focus resolve(true); };
const handleCancel = () => { confirmModal.classList.remove('show'); confirmOkButton.removeEventListener('click', handleOk); confirmCancelButton.removeEventListener('click', handleCancel); if (triggeringElement) triggeringElement.focus(); // Return focus resolve(false); };
confirmOkButton.addEventListener('click', handleOk); confirmCancelButton.addEventListener('click', handleCancel);
// Close on overlay click (but prevent immediate closing if clicking content) confirmModal.addEventListener('click', function(event) { if (event.target === confirmModal) { // Only close if click is directly on the overlay handleCancel(); } }, { once: true }); // Ensure it only runs once per dialog instance }); }
document.addEventListener('DOMContentLoaded', function() { // --- Authentication Status Check --- function updateAuthButton() { const authButtonContainer = document.getElementById('authButtonContainer'); const userIsLoggedIn = localStorage.getItem('isLoggedIn') === 'true';
if (userIsLoggedIn) { authButtonContainer.innerHTML = ` <a href="/profile" class="gakr-profile-button"> <i class="fas fa-user-circle me-2"></i>Profile </a> `; const profileButton = authButtonContainer.querySelector('.gakr-profile-button'); if (profileButton) { profileButton.addEventListener('click', function(event) { console.log("Profile button clicked!"); }); } } else { authButtonContainer.innerHTML = ` <a href="/auth" class="gakr-login-button">Sign in / Register</a> `; } }
updateAuthButton(); window.addEventListener('focus', updateAuthButton); window.addEventListener('storage', updateAuthButton);
// Check if user is logged in if (localStorage.getItem('isLoggedIn') !== 'true') { window.location.href = '/auth'; return; } // --- DOM Element References --- const profileButton = document.getElementById('profileButton'); const profileDropdown = document.getElementById('profileDropdown'); const logoutButton = document.getElementById('logoutButton'); const brandLogoArea = document.getElementById('brandLogoArea'); const signInRegisterButton = document.getElementById('signInRegisterButton'); const profileControls = document.getElementById('profileControls');
// Profile-specific elements const profileAvatarLarge = document.getElementById('profileAvatarLarge'); const profileUsernameDisplay = document.getElementById('profileUsernameDisplay'); const profileEmailDisplay = document.getElementById('profileEmailDisplay'); const accountName = document.getElementById('accountName'); const accountEmail = document.getElementById('accountEmail'); const chatHistoryList = document.getElementById('chatHistoryList'); const profileSettingsButton = document.getElementById('profileSettingsButton'); const profileLogoutButton = document.getElementById('profileLogoutButton'); const profileLink = document.getElementById('profileLink'); const settingsLink = document.getElementById('settingsLink'); const emptyChatHistoryMessage = document.getElementById('emptyChatHistoryMessage');
// Check login if (localStorage.getItem('isLoggedIn') !== 'true') { window.location.href = '/auth'; }
// Load user data const user = JSON.parse(localStorage.getItem('user') || '{}'); if (user.name) { profileUsernameDisplay.textContent = user.name; accountName.textContent = user.name; } if (user.email) { profileEmailDisplay.textContent = user.email; accountEmail.textContent = user.email; }
// Elements for edit functionality // Note: avatarUpload needs to be re-referenced after dynamic re-creation let avatarUpload = document.getElementById('avatarUpload'); const editUsernameIcon = document.getElementById('editUsernameIcon'); const usernameInputContainer = document.getElementById('usernameInputContainer'); const usernameEditInput = document.getElementById('usernameEditInput'); const usernameSaveButton = document.getElementById('usernameSaveButton');
// About Me Section elements const profileAboutMeDisplay = document.getElementById('profileAboutMeDisplay'); const editAboutMeIcon = document.getElementById('editAboutMeIcon'); const aboutMeInputContainer = document.getElementById('aboutMeInputContainer'); const aboutMeEditInput = document.getElementById('aboutMeEditInput'); const aboutMeSaveButton = document.getElementById('aboutMeSaveButton');
// Chat History Search const chatHistorySearchInput = document.getElementById('chatHistorySearchInput');
// Chat Context Menu elements const chatContextMenu = document.getElementById('chatContextMenu'); let currentChatContextItem = null; // To keep track of which chat item was right-clicked
// Toast Container const toastContainer = document.getElementById('toastContainer');
// Custom Modal Elements confirmModal = document.getElementById('confirmModal'); confirmTitle = document.getElementById('confirmTitle'); confirmMessage = document.getElementById('confirmMessage'); confirmOkButton = document.getElementById('confirmOkButton'); confirmCancelButton = document.getElementById('confirmCancelButton');
const promptModal = document.getElementById('promptModal'); const promptTitle = document.getElementById('promptTitle'); const promptMessage = document.getElementById('promptMessage'); const promptInput = document.getElementById('promptInput'); const promptSubmitButton = document.getElementById('promptSubmitButton'); const promptCancelButton = document.getElementById('promptCancelButton');
// Tag Modal Elements (New) const tagModal = document.getElementById('tagModal'); const tagModalTitle = document.getElementById('tagModalTitle'); const tagOptions = document.getElementById('tagOptions'); const tagSaveButton = document.getElementById('tagSaveButton'); const tagCancelButton = document.getElementById('tagCancelButton'); let currentChatIdForTagging = null; let selectedTags = new Set(); // Stores tags currently selected in the modal
// New button const startChattingButton = document.getElementById('startChattingButton');
// --- Mock Data (Enhanced) --- // Data is stored in sessionStorage to persist across page reloads in a session let mockUserData = JSON.parse(sessionStorage.getItem('userData')) || { name: 'GAKR User', email: 'gakr.user@example.com', avatar: null, // Base64 string for avatar image aboutMe: '', pinnedChats: [] // Stored as array, converted to Set on load/save };
// Ensure pinnedChats is a Set for quick lookups and consistency if (mockUserData.pinnedChats && Array.isArray(mockUserData.pinnedChats)) { mockUserData.pinnedChats = new Set(mockUserData.pinnedChats); } else if (!mockUserData.pinnedChats) { mockUserData.pinnedChats = new Set(); }
let mockChatHistory = JSON.parse(sessionStorage.getItem('mockChatHistory')) || [ { id: 1, title: "What is AI?", date: "2 days ago", tags: ['Learning'], lastActive: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString() }, { id: 2, title: "Poem about the ocean", date: "Yesterday", tags: ['Personal', 'Creative'], lastActive: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000).toISOString() }, { id: 3, title: "Explain quantum physics to me simply", date: "Today", tags: ['Learning', 'Ideas'], lastActive: new Date().toISOString() }, { id: 4, title: "Recipe for a simple pasta dish", date: "3 days ago", tags: ['Personal'], lastActive: new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toISOString() }, { id: 5, title: "History of the internet", date: "Last week", tags: ['Learning', 'Work'], lastActive: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString() } ];
// Convert tags arrays to Sets when loading, for consistency with mockUserData.pinnedChats mockChatHistory = mockChatHistory.map(chat => ({ ...chat, tags: new Set(chat.tags || []) }));
// --- Utility Functions ---
// Animated Toast Message Function (Middle of Page) function showToast(message, type = 'info', duration = 3000) { const toast = document.createElement('div'); toast.className = `gakr-toast ${type}`; let iconClass = ''; switch(type) { case 'success': iconClass = 'fas fa-check-circle'; break; case 'error': iconClass = 'fas fa-times-circle'; break; case 'warning': iconClass = 'fas fa-exclamation-triangle'; break; default: iconClass = 'fas fa-info-circle'; break; } toast.innerHTML = `<i class="${iconClass} toast-icon"></i> <span>${message}</span>`; toastContainer.appendChild(toast);
// Show animation setTimeout(() => { toast.classList.add('show'); }, 10); // Small delay for CSS transition to work
// Hide animation and remove after duration setTimeout(() => { toast.classList.remove('show'); toast.classList.add('hide'); // Add hide class for exit animation toast.addEventListener('transitionend', () => toast.remove(), { once: true }); }, duration); }
// Custom Prompt Dialog Function (Middle of Page) function showPromptDialog(message, defaultValue = '', title = 'Enter Information') { return new Promise((resolve) => { promptTitle.textContent = title; promptMessage.textContent = message; promptInput.value = defaultValue; promptModal.classList.add('show'); promptInput.focus(); // Focus on the input field
const triggeringElement = document.activeElement;
const handleSubmit = () => { promptModal.classList.remove('show'); promptSubmitButton.removeEventListener('click', handleSubmit); promptCancelButton.removeEventListener('click', handleCancel); promptInput.removeEventListener('keypress', handleKeyPress); if (triggeringElement) triggeringElement.focus(); // Return focus resolve(promptInput.value); };
const handleCancel = () => { promptModal.classList.remove('show'); promptSubmitButton.removeEventListener('click', handleSubmit); promptCancelButton.removeEventListener('click', handleCancel); promptInput.removeEventListener('keypress', handleKeyPress); if (triggeringElement) triggeringElement.focus(); // Return focus resolve(null); // Return null if cancelled };
const handleKeyPress = (event) => { if (event.key === 'Enter') { handleSubmit(); } };
promptSubmitButton.addEventListener('click', handleSubmit); promptCancelButton.addEventListener('click', handleCancel); promptInput.addEventListener('keypress', handleKeyPress);
// Close on overlay click promptModal.addEventListener('click', function(event) { if (event.target === promptModal) { handleCancel(); } }, { once: true }); }); }
// --- User Data Management (Mock) --- function getUserData() { return mockUserData; }
function setUserData(data) { // Merge new data while preserving existing keys mockUserData = { ...mockUserData, ...data }; // Ensure pinnedChats is always an Array when saving to sessionStorage for JSON stringify const dataToSave = { ...mockUserData, pinnedChats: Array.from(mockUserData.pinnedChats) }; sessionStorage.setItem('userData', JSON.stringify(dataToSave)); updateProfileUI(); // Update UI after data change }
function getChatHistory() { // Return a deep copy to prevent direct modification outside of updateChatInHistory return JSON.parse(JSON.stringify(Array.from(mockChatHistory).map(chat => ({ ...chat, tags: Array.from(chat.tags) })))); }
function saveChatHistory() { // Convert tags back to arrays for storage const chatsToSave = mockChatHistory.map(chat => ({ ...chat, tags: Array.from(chat.tags) // Convert Set to Array for JSON stringify })); sessionStorage.setItem('mockChatHistory', JSON.stringify(chatsToSave)); }
function updateChatInHistory(chatId, update) { const index = mockChatHistory.findIndex(chat => chat.id === chatId); if (index !== -1) { // Ensure tags are handled as Sets internally if (update.tags && ! (update.tags instanceof Set)) { update.tags = new Set(update.tags); } mockChatHistory[index] = { ...mockChatHistory[index], ...update }; saveChatHistory(); } }
function deleteChatFromHistory(chatId) { const initialLength = mockChatHistory.length; mockChatHistory = mockChatHistory.filter(chat => chat.id !== chatId); if (mockUserData.pinnedChats.has(chatId)) { mockUserData.pinnedChats.delete(chatId); setUserData({}); // Save updated pinned chats (which triggers UI update) } else { saveChatHistory(); // Only save if pinned chats weren't updated } return mockChatHistory.length < initialLength; // Return true if deleted }
// --- UI Update Logic --- function updateProfileUI() { const userData = getUserData();
// Update header profile button if (profileButton) { profileButton.textContent = userData.name.charAt(0).toUpperCase(); profileButton.title = userData.name; }
// Update large avatar if (profileAvatarLarge) { profileAvatarLarge.innerHTML = ''; // Clear existing content if (userData.avatar) { const img = document.createElement('img'); img.src = userData.avatar; img.alt = "User Avatar"; profileAvatarLarge.appendChild(img); } else { profileAvatarLarge.textContent = userData.name.charAt(0).toUpperCase(); } // Add the edit icon and input back dynamically const label = document.createElement('label'); label.htmlFor = 'avatarUpload'; // Important: ensures label clicks input label.className = 'profile-avatar-edit-icon'; label.title = 'Change Avatar'; label.innerHTML = '<i class="fas fa-camera"></i>'; // Create a *new* input element and assign its ID, then append to label const newInput = document.createElement('input'); newInput.type = 'file'; newInput.id = 'avatarUpload'; // Reuse the ID newInput.accept = 'image/*'; newInput.style.display = 'none'; label.appendChild(newInput); profileAvatarLarge.appendChild(label);
// Re-assign the global avatarUpload reference to the new element avatarUpload = newInput; // Re-attach event listener for the dynamically created input avatarUpload.addEventListener('change', handleAvatarUpload); }
// Update username displays if (profileUsernameDisplay) profileUsernameDisplay.textContent = userData.name; if (accountName) accountName.textContent = userData.name; if (profileEmailDisplay) profileEmailDisplay.textContent = userData.email; if (accountEmail) accountEmail.textContent = userData.email;
// Update About Me display if (profileAboutMeDisplay) { profileAboutMeDisplay.textContent = userData.aboutMe || 'Tell us something about yourself...'; // Add/remove placeholder class for italicized gray text profileAboutMeDisplay.classList.toggle('placeholder', !userData.aboutMe); }
// Ensure auth controls are set for a "logged in" state if (signInRegisterButton) signInRegisterButton.style.display = 'none'; if (profileControls) profileControls.style.display = 'block';
// Update chat history list based on current filters renderChatHistory(chatHistorySearchInput.value); }
// --- Edit Profile Functions --- function handleAvatarUpload(event) { const file = event.target.files[0]; if (file) { const reader = new FileReader(); reader.onload = function(e) { setUserData({ avatar: e.target.result }); showToast('Avatar updated successfully!', 'success'); }; reader.onerror = function() { showToast('Failed to read file.', 'error'); }; reader.readAsDataURL(file); } else { showToast('No file selected.', 'warning'); } }
function toggleUsernameEdit(show) { if (show) { profileUsernameDisplay.style.display = 'none'; editUsernameIcon.style.display = 'none'; usernameInputContainer.style.display = 'flex'; // Use flex for button alignment usernameEditInput.value = getUserData().name; usernameEditInput.focus(); usernameEditInput.setSelectionRange(usernameEditInput.value.length, usernameEditInput.value.length); // Put cursor at end } else { profileUsernameDisplay.style.display = 'block'; editUsernameIcon.style.display = 'inline-block'; usernameInputContainer.style.display = 'none'; } }
function toggleAboutMeEdit(show) { if (show) { profileAboutMeDisplay.style.display = 'none'; editAboutMeIcon.style.display = 'none'; aboutMeInputContainer.style.display = 'flex'; // Use flex-direction: column in CSS aboutMeEditInput.value = getUserData().aboutMe; aboutMeEditInput.focus(); aboutMeEditInput.setSelectionRange(aboutMeEditInput.value.length, aboutMeEditInput.value.length); // Put cursor at end } else { profileAboutMeDisplay.style.display = 'block'; editAboutMeIcon.style.display = 'inline-block'; aboutMeInputContainer.style.display = 'none'; } }
// --- Chat History Rendering and Management ---
function renderChatHistory(searchTerm = '') { const chatHistory = getChatHistory(); chatHistoryList.innerHTML = ''; // Clear existing list
// Filter let filteredChats = chatHistory.filter(chat => chat.title.toLowerCase().includes(searchTerm.toLowerCase()) || Array.from(chat.tags).some(tag => tag.toLowerCase().includes(searchTerm.toLowerCase())) );
// Separate pinned and unpinned chats let pinnedChats = []; let unpinnedChats = [];
filteredChats.forEach(chat => { // Check against mockUserData.pinnedChats Set if (mockUserData.pinnedChats.has(chat.id)) { pinnedChats.push(chat); } else { unpinnedChats.push(chat); } });
// Sort (always newest first for simplicity after removing sort dropdown) const sortFunction = (a, b) => { const dateA = new Date(a.lastActive); const dateB = new Date(b.lastActive); return dateB.getTime() - dateA.getTime(); // Newest first };
pinnedChats.sort(sortFunction); unpinnedChats.sort(sortFunction);
// Combine pinned and unpinned (pinned always come first) const chatsToDisplay = [...pinnedChats, ...unpinnedChats];
if (chatsToDisplay.length === 0) { emptyChatHistoryMessage.style.display = 'block'; } else { emptyChatHistoryMessage.style.display = 'none'; chatsToDisplay.forEach(chat => { const chatItem = document.createElement('div'); chatItem.className = 'chat-history-item'; chatItem.dataset.chatId = chat.id; // Store chat ID on the element if (mockUserData.pinnedChats.has(chat.id)) { chatItem.classList.add('pinned'); }
// Format last active time let lastActiveText = ''; try { const lastActiveDate = new Date(chat.lastActive); const now = new Date(); const diffMs = now.getTime() - lastActiveDate.getTime(); const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
if (diffDays === 0 && lastActiveDate.toDateString() === now.toDateString()) { lastActiveText = `Today, ${lastActiveDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`; } else if (diffDays === 1 || (diffDays === 0 && lastActiveDate.getDate() === now.getDate() - 1)) { lastActiveText = `Yesterday, ${lastActiveDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`; } else if (diffDays < 7) { lastActiveText = `${lastActiveDate.toLocaleDateString('en-US', { weekday: 'short' })}, ${lastActiveDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`; } else { lastActiveText = lastActiveDate.toLocaleDateString(); } } catch (e) { lastActiveText = chat.date; // Fallback if date is invalid or missing }
chatItem.innerHTML = ` <div class="chat-title-wrapper"> <span class="chat-title">${chat.title}</span> ${mockUserData.pinnedChats.has(chat.id) ? '<i class="fas fa-thumbtack pinned-icon" title="Pinned"></i>' : ''} </div> <div class="chat-meta"> <span class="chat-date">${chat.date}</span> <span class="chat-history-last-active">Last active: ${lastActiveText}</span> </div> <div class="chat-tags"> ${Array.from(chat.tags).map(tag => `<span>${tag}</span>`).join('')} </div> `; chatHistoryList.appendChild(chatItem); }); } }
// --- Context Menu Functions --- function showContextMenu(x, y, chatItem) { // Ensure menu doesn't go off-screen let posX = x; let posY = y;
// Adjust X if too close to right edge const menuWidth = chatContextMenu.offsetWidth; if (posX + menuWidth > window.innerWidth - 20) { // 20px padding from right posX = window.innerWidth - menuWidth - 20; } // Adjust Y if too close to bottom edge const menuHeight = chatContextMenu.offsetHeight; if (posY + menuHeight > window.innerHeight - 20) { // 20px padding from bottom posY = window.innerHeight - menuHeight - 20; }
chatContextMenu.style.left = `${posX}px`; chatContextMenu.style.top = `${posY}px`; chatContextMenu.classList.add('show'); currentChatContextItem = chatItem; // Store the clicked item
const chatId = parseInt(currentChatContextItem.dataset.chatId); const pinUnpinLink = chatContextMenu.querySelector('[data-action="pin"], [data-action="unpin"]'); if (mockUserData.pinnedChats.has(chatId)) { pinUnpinLink.innerHTML = '<i class="fas fa-thumbtack"></i> Unpin'; pinUnpinLink.dataset.action = 'unpin'; } else { pinUnpinLink.innerHTML = '<i class="fas fa-thumbtack"></i> Pin'; pinUnpinLink.dataset.action = 'pin'; } }
function hideContextMenu() { chatContextMenu.classList.remove('show'); currentChatContextItem = null; }
// --- Tag Modal Functions (New) --- function showTagModal(chatId, currentTags) { currentChatIdForTagging = chatId; selectedTags = new Set(currentTags); // Initialize selected tags from the chat's current tags
// Clear previous selections and populate options tagOptions.innerHTML = ''; // Extendable list of available tags const availableTags = ['Work', 'Personal', 'Creative', 'Ideas', 'Learning', 'Research', 'Drafts', 'Notes', 'Projects', 'Finance', 'Health'];
availableTags.forEach(tag => { const tagDiv = document.createElement('div'); tagDiv.className = 'tag-option'; tagDiv.dataset.tag = tag; tagDiv.textContent = tag; if (selectedTags.has(tag)) { tagDiv.classList.add('selected'); } tagDiv.addEventListener('click', () => { if (selectedTags.has(tag)) { selectedTags.delete(tag); tagDiv.classList.remove('selected'); } else { selectedTags.add(tag); tagDiv.classList.add('selected'); } }); tagOptions.appendChild(tagDiv); });
tagModal.classList.add('show'); // Store the element that triggered the modal for focus management tagModal.triggeringElement = document.activeElement; }
function hideTagModal() { tagModal.classList.remove('show'); currentChatIdForTagging = null; selectedTags = new Set(); // Reset selected tags if (tagModal.triggeringElement) tagModal.triggeringElement.focus(); // Return focus tagModal.triggeringElement = null; }
// --- Event Listeners ---
// Dropdown menu toggle profileButton.addEventListener('click', function(event) { event.stopPropagation(); // Prevent document click from closing immediately profileDropdown.classList.toggle('show'); });
// Close dropdown and context menu if clicked outside document.addEventListener('click', function(event) { if (!profileDropdown.contains(event.target) && !profileButton.contains(event.target)) { profileDropdown.classList.remove('show'); } if (!chatContextMenu.contains(event.target) && !event.target.closest('.chat-history-item')) { hideContextMenu(); } });
// Prevent context menu from closing if right-clicking the menu itself chatContextMenu.addEventListener('contextmenu', function(event) { event.preventDefault(); });
// Navigation from dropdown (Mock functionality) if (profileLink) { profileLink.addEventListener('click', (e) => { e.preventDefault(); profileDropdown.classList.remove('show'); showToast('You are already on your profile page!', 'info'); }); } if (profileSettingsButton) { profileSettingsButton.addEventListener('click', function(e) { e.preventDefault(); showToast('Profile settings coming soon!', 'info'); }); } if (settingsLink) { settingsLink.addEventListener('click', (e) => { e.preventDefault(); showToast('Settings page is under development!', 'info'); profileDropdown.classList.remove('show'); }); }
// Logout (from header dropdown) - removed, using onclick for profile logout
// Handle profile settings button on the profile page
// Profile logout is now handled by onclick in HTML
// Username Edit Listeners editUsernameIcon.addEventListener('click', () => toggleUsernameEdit(true)); usernameSaveButton.addEventListener('click', function() { const newUsername = usernameEditInput.value.trim(); if (newUsername) { setUserData({ name: newUsername }); toggleUsernameEdit(false); showToast('Username updated successfully!', 'success'); } else { showToast('Username cannot be empty!', 'error'); } }); usernameEditInput.addEventListener('keypress', function(e) { if (e.key === 'Enter') { usernameSaveButton.click(); // Trigger save button click on Enter } });
// About Me Edit Listeners editAboutMeIcon.addEventListener('click', () => toggleAboutMeEdit(true)); aboutMeSaveButton.addEventListener('click', function() { const newAboutMe = aboutMeEditInput.value.trim(); setUserData({ aboutMe: newAboutMe }); // Allow empty string for about me toggleAboutMeEdit(false); showToast('About Me section updated!', 'success'); }); aboutMeEditInput.addEventListener('keypress', function(e) { if (e.key === 'Enter' && !e.shiftKey) { // Allow Shift+Enter for new line e.preventDefault(); // Prevent default Enter behavior (new line) aboutMeSaveButton.click(); } });
// Chat History Search Listener chatHistorySearchInput.addEventListener('input', () => renderChatHistory(chatHistorySearchInput.value));
// Chat History Context Menu Listeners (Right-click) chatHistoryList.addEventListener('contextmenu', function(event) { const chatItem = event.target.closest('.chat-history-item'); if (chatItem) { event.preventDefault(); // Prevent default browser context menu showContextMenu(event.clientX, event.clientY, chatItem); } });
// Handle actions from the chat context menu chatContextMenu.addEventListener('click', function(event) { event.preventDefault(); // Prevent default link behavior const actionElement = event.target.closest('.chat-context-menu-item'); if (actionElement && currentChatContextItem) { const action = actionElement.dataset.action; const chatId = parseInt(currentChatContextItem.dataset.chatId);
switch (action) { case 'delete': showConfirmDialog('Are you sure you want to delete this conversation? This action cannot be undone.', 'Delete Conversation') .then(result => { if (result) { if (deleteChatFromHistory(chatId)) { showToast('Conversation deleted.', 'success'); renderChatHistory(chatHistorySearchInput.value); // Re-render after deletion } else { showToast('Failed to delete conversation.', 'error'); } } }); break; case 'share': showPromptDialog('Enter email or username to share with:', '', 'Share Conversation') .then(input => { if (input !== null) { // Check for null (cancelled) if (input.trim() !== '') { showToast(`Conversation shared with "${input}". (Mock)`, 'success'); } else { showToast('Share cancelled. No recipient provided.', 'warning'); } } }); break; case 'pin': mockUserData.pinnedChats.add(chatId); setUserData({}); // Save updated pinned chats (triggers UI update) showToast('Conversation pinned!', 'success'); // renderChatHistory is called by setUserData break; case 'unpin': mockUserData.pinnedChats.delete(chatId); setUserData({}); // Save updated pinned chats (triggers UI update) showToast('Conversation unpinned!', 'info'); // renderChatHistory is called by setUserData break; case 'tag': const chatToTag = mockChatHistory.find(chat => chat.id === chatId); if (chatToTag) { showTagModal(chatId, chatToTag.tags); } break; } hideContextMenu(); // Always hide after an action } });
// Handle clicks on chat items (to potentially open a conversation) chatHistoryList.addEventListener('click', function(event) { const chatItem = event.target.closest('.chat-history-item'); if (chatItem) { const chatId = chatItem.dataset.chatId; showToast(`Opening conversation: ${chatItem.querySelector('.chat-title').textContent} (ID: ${chatId}). (Mock)`, 'info'); // In a real application, you would navigate to the chat page: // window.location.href = `chat.html?chatId=${chatId}`; } });
// Tag Modal Listeners (New) tagSaveButton.addEventListener('click', function() { if (currentChatIdForTagging !== null) { // Update the chat with the new set of tags updateChatInHistory(currentChatIdForTagging, { tags: Array.from(selectedTags) }); showToast('Tags updated successfully!', 'success'); hideTagModal(); renderChatHistory(chatHistorySearchInput.value); // Re-render to reflect new tags } });
tagCancelButton.addEventListener('click', hideTagModal);
// Close Tag Modal on overlay click tagModal.addEventListener('click', function(event) { if (event.target === tagModal) { hideTagModal(); } });
// Initial UI setup updateProfileUI(); // Call once on load to populate existing data }); </script></body></html>auth.html+335-56
chat.html+139-100
profile.htmlAdded+2090