Done !
| Server IP : 46.105.57.169 / Your IP : 216.73.216.67 Web Server : Apache System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaumee ( 152031) PHP Version : 8.5.7 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/v/e/r/verseaumee/chatblueversion/assets/ |
Upload File : |
(()=>{const app=document.querySelector('#app'),thread=document.querySelector('#thread'),prompt=document.querySelector('#prompt'),modal=document.querySelector('#limitModal'),theme=document.querySelector('#theme');if(!app||!thread||!prompt)return;let dark=localStorage.getItem('bvx_theme')==='dark';function paint(){app.dataset.theme=dark?'dark':'light';if(theme)theme.textContent=dark?'☀':'◐'}paint();if(theme)theme.onclick=()=>{dark=!dark;localStorage.setItem('bvx_theme',dark?'dark':'light');paint()};
const welcome=()=>`<div class="welcome"><div class="xMark">X</div><h1>How can I help?</h1><p>Explore African history, science, innovation and development.</p><div class="suggestions"><button>Explain the Mali Empire<span>↗</span></button><button>African discoveries in medicine<span>↗</span></button><button>How can Africa lead in solar energy?<span>↗</span></button><button>Tell me about Great Zimbabwe<span>↗</span></button></div></div>`;
function bindSuggestions(){document.querySelectorAll('.suggestions button').forEach(b=>b.onclick=()=>{prompt.value=b.textContent.replace('↗','').trim();prompt.focus()})}bindSuggestions();
function reset(){BVX.conversationId=null;thread.innerHTML=welcome();thread.classList.add('empty');bindSuggestions();prompt.value=''}document.querySelector('#newChat')?.addEventListener('click',reset);document.querySelector('#clearChat')?.addEventListener('click',reset);document.querySelector('.modalClose')?.addEventListener('click',()=>modal.hidden=true);document.querySelector('#guestAccount')?.addEventListener('click',()=>{if(BVX.remaining===0)modal.hidden=false});if(!BVX.loggedIn&&BVX.remaining===0)modal.hidden=false;
async function loadConversation(id){const r=await fetch('api/conversation.php?id='+encodeURIComponent(id));const d=await r.json();if(!r.ok)return;BVX.conversationId=d.id;thread.classList.remove('empty');thread.innerHTML=d.messages.map(m=>m.role==='user'?`<article class="user"><p>${esc(m.content)}</p></article>`:`<article class="assistant"><b>X</b><div><p>${esc(m.content)}</p><small>blueversionX</small></div></article>`).join('');thread.scrollTop=thread.scrollHeight}
function bindHistory(button){button.onclick=()=>loadConversation(button.dataset.id)}document.querySelectorAll('.historyItem').forEach(bindHistory);
function addHistory(id,title){const recent=document.querySelector('#recent');recent.querySelector('.noHistory')?.remove();if(recent.querySelector('[data-id="'+CSS.escape(id)+'"]'))return;const b=document.createElement('button');b.className='historyItem';b.dataset.id=id;b.innerHTML='◌ <span>'+esc(title.slice(0,80))+'</span>';recent.prepend(b);bindHistory(b)}
document.querySelector('#send').onclick=send;prompt.onkeydown=e=>{if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();send()}};
async function send(){const q=prompt.value.trim();if(!q)return;if(!BVX.loggedIn&&BVX.remaining<=0){modal.hidden=false;return}const wasNew=!BVX.conversationId;thread.querySelector('.welcome')?.remove();thread.classList.remove('empty');thread.insertAdjacentHTML('beforeend',`<article class="user"><p>${esc(q)}</p></article><article class="assistant loading"><b>X</b><div><p>Thinking…</p><small>blueversionX</small></div></article>`);prompt.value='';const loading=thread.querySelector('.loading');try{const r=await fetch('api/chat.php',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({prompt:q,conversation_id:BVX.conversationId})});const d=await r.json();loading.classList.remove('loading');loading.querySelector('p').textContent=d.text||d.error||'Please try again.';if(d.conversation_id){BVX.conversationId=d.conversation_id;if(wasNew)addHistory(d.conversation_id,q)}if(d.remaining!==null&&d.remaining!==undefined){BVX.remaining=d.remaining;const gc=document.querySelector('#guestCount'),ln=document.querySelector('#limitNotice');if(gc)gc.textContent=`${d.remaining} of 10 free questions left`;if(ln)ln.textContent=`${d.remaining} free questions remaining.`}if(d.registration_required)modal.hidden=false;thread.scrollTop=thread.scrollHeight}catch(e){loading.querySelector('p').textContent='blueversionX could not connect. Try again.'}}
function esc(s){const d=document.createElement('div');d.textContent=s;return d.innerHTML}})();