|
<!DOCTYPE html> |
|
<html lang="fr"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title>Chatbot Islamique</title> |
|
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"> |
|
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"> |
|
<style> |
|
|
|
|
|
|
|
#suggestions { |
|
margin-top: 20px; |
|
} |
|
|
|
.suggestion { |
|
display: inline-block; |
|
margin: 5px; |
|
cursor: pointer; |
|
color: #007bff; |
|
} |
|
|
|
|
|
.icon { |
|
font-size: 36px; |
|
margin-right: 10px; |
|
} |
|
|
|
|
|
body.dark-mode { |
|
background-color: #343a40; |
|
color: white; |
|
} |
|
|
|
|
|
.loader { |
|
border: 4px solid #f3f3f3; |
|
border-top: 4px solid #3498db; |
|
border-radius: 50%; |
|
width: 20px; |
|
height: 20px; |
|
animation: spin 2s linear infinite; |
|
} |
|
|
|
@keyframes spin { |
|
0% { transform: rotate(0deg); } |
|
100% { transform: rotate(360deg); } |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div class="container"> |
|
<div class="card mt-5"> |
|
<div class="card-header"> |
|
<span class="icon">☰</span> Chatbot Islamique |
|
</div> |
|
<div class="card-body"> |
|
<div class="text-center"> |
|
<strong>Connecté actuellement :</strong> |
|
<p id="randomNumber" class="mt-2"></p> |
|
</div> |
|
<div class="form-group mt-4"> |
|
<label for="question">Posez votre question :</label> |
|
<div class="input-group"> |
|
<textarea class="form-control" id="question" rows="3" placeholder="Entrez votre question"></textarea> |
|
<div class="input-group-append"> |
|
<button class="btn btn-outline-secondary" type="button" id="clearBtn"><i class="fas fa-times"></i></button> |
|
</div> |
|
</div> |
|
</div> |
|
<div class="text-center"> |
|
<button type="button" class="btn btn-primary" id="submitBtn">Obtenir la réponse</button> |
|
</div> |
|
<div id="loading" class="text-center mt-4" style="display: none;"> |
|
<div class="spinner-border text-primary" role="status"> |
|
<span class="sr-only">Chargement...</span> |
|
</div> |
|
</div> |
|
<div class="mt-4 text-center"> |
|
<strong>Réponse :</strong> |
|
<p id="answer" class="mt-2"></p> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div id="suggestions"> |
|
<strong>Suggestions de questions :</strong> |
|
<div class="suggestion">Qu'est-ce que le Ramadan ?</div> |
|
<div class="suggestion">Quelles sont les cinq prières quotidiennes ?</div> |
|
<div class="suggestion">Quel est le livre saint de l'islam ?</div> |
|
|
|
</div> |
|
|
|
<div id="about" class="mt-5"> |
|
<h2>À Propos</h2> |
|
<p>Cette application de chatbot islamique a été créée par Youssouf pour répondre à vos questions sur l'islam. Posez simplement votre question dans la zone prévue et appuyez sur le bouton "Obtenir la réponse" pour obtenir une réponse.c'est aussi simple que ça ! </p> |
|
</div> |
|
</div> |
|
|
|
|
|
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> |
|
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> |
|
|
|
<script> |
|
|
|
function insertSuggestion(suggestion) { |
|
document.getElementById('question').value = suggestion; |
|
} |
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
const suggestions = document.querySelectorAll('.suggestion'); |
|
suggestions.forEach(suggestion => { |
|
suggestion.addEventListener('click', function() { |
|
const question = suggestion.innerText; |
|
insertSuggestion(question); |
|
}); |
|
}); |
|
}); |
|
|
|
|
|
document.getElementById('submitBtn').addEventListener('click', function() { |
|
const question = document.getElementById('question').value; |
|
getAnswer(question); |
|
}); |
|
|
|
|
|
document.getElementById('clearBtn').addEventListener('click', function() { |
|
document.getElementById('question').value = ''; |
|
}); |
|
|
|
|
|
|
|
function getAnswer(question) { |
|
|
|
document.getElementById('loading').style.display = 'block'; |
|
|
|
document.getElementById('answer').innerHTML = ''; |
|
fetch('https://docfile-my.hf.space/run/predict', { |
|
method: 'POST', |
|
headers: { |
|
'Content-Type': 'application/json' |
|
}, |
|
body: JSON.stringify({ |
|
data: [question] |
|
}) |
|
}) |
|
.then(response => response.json()) |
|
.then(data => { |
|
var answer = data.data[0]; |
|
document.getElementById('answer').innerHTML = answer; |
|
}) |
|
.catch(error => { |
|
console.error('Une erreur s\'est produite :', error); |
|
}) |
|
.finally(() => { |
|
|
|
document.getElementById('loading').style.display = 'none'; |
|
}); |
|
} |
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
var randomNumber = Math.floor(Math.random() * 19) + 2; |
|
document.getElementById('randomNumber').innerHTML = randomNumber; |
|
}); |
|
|
|
document.getElementById('submitBtn').addEventListener('click', function() { |
|
var question = document.getElementById('question').value; |
|
getAnswer(question); |
|
}); |
|
</script> |
|
</body> |
|
</html> |
|
|