| Current Path : /home/h/e/l/helpink/www/ |
| Current File : /home/h/e/l/helpink/www/bob.html |
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Bob – Assistant Help In Brussels</title>
<style>
body { font-family: Arial, sans-serif; background:#f3f5f7; }
.container {
max-width: 700px; margin: 60px auto; background: #fff; padding: 30px;
border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}
h1 { margin-top: 0; }
.small { color:#666; font-size:14px; }
textarea {
width: 100%; min-height: 120px; padding: 12px; font-size: 15px;
border-radius: 6px; border: 1px solid #ccc; resize: vertical;
}
button {
margin-top: 15px; background: #1e88e5; color: #fff; border: none;
padding: 12px 20px; font-size: 15px; border-radius: 6px; cursor: pointer;
}
button:hover { background: #1565c0; }
#response {
margin-top: 25px; background: #f6f8fa; padding: 15px; border-radius: 6px;
}
</style>
</head>
<body>
<div class="container">
<h1>Bob – Assistant Help In Brussels</h1>
<p class="small">
Pose ta question en langage naturel.<br>
Ex : <i>« aide CPAS »</i> ou <i>« aide juridique »</i> ou <i>« repas »</i>
</p>
<textarea id="question" placeholder="Écris ta question ici…"></textarea>
<button onclick="askBob()">Demande à Bob</button>
<div id="response" style="display:none;"></div>
</div>
<script>
async function askBob() {
const q = document.getElementById('question').value.trim();
if (!q) return;
const box = document.getElementById('response');
box.style.display = 'block';
box.innerHTML = "⏳ Bob réfléchit…";
try {
const r = await fetch('bob.php', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ question: q })
});
const text = await r.text();
let data;
try { data = JSON.parse(text); }
catch(e) { throw new Error("Réponse non-JSON: " + text.slice(0,200)); }
if (!r.ok || data.ok === false) {
box.innerHTML = "<b>Erreur :</b><br>" + (data.error || ("HTTP " + r.status));
return;
}
box.innerHTML = "<b>Bob :</b><br><br>" + data.reply;
} catch (e) {
box.innerHTML = "<b>Erreur :</b><br>" + e.message;
}
}
</script>
</body>
</html>