lokesh341's picture
Update templates/index.html
28591dd verified
raw
history blame
3.52 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Biryani Hub</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
<div class="container">
<h2>Welcome to Biryani Hub ๐Ÿฝ๏ธ ๐Ÿ—</h2>
<!-- Voice Input Section -->
<div class="voice-section">
<label for="name">Your Name</label>
<input type="text" id="name" placeholder="Your name will appear here..." disabled>
<label for="email">Your Email</label>
<input type="email" id="voice-email" placeholder="Your email will appear here..." disabled>
<label for="phone">Your Mobile Number</label>
<input type="text" id="voice-phone" placeholder="Your mobile number will appear here..." disabled>
<p><span class="listening">Listening ๐ŸŽ™๏ธ...</span></p>
<button onclick="startVoiceRecognition()">Start Voice Recognition</button>
</div>
<!-- Login Section -->
<div class="login-section">
<h2>Login to Biryani Hub</h2>
<label for="login-email">Email</label>
<input type="email" id="login-email" placeholder="Enter your email">
<label for="login-phone">Phone Number</label>
<input type="text" id="login-phone" placeholder="Enter your phone number">
<button onclick="login()">Login</button>
</div>
</div>
<script>
// Initialize Speech Recognition (for voice assistance)
var recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
// Start Voice Recognition when button is clicked
function startVoiceRecognition() {
recognition.start();
recognition.onresult = function(event) {
let transcript = event.results[0][0].transcript;
if (document.activeElement.id === "name") {
document.getElementById("name").value = transcript;
} else if (document.activeElement.id === "voice-email") {
document.getElementById("voice-email").value = transcript;
} else if (document.activeElement.id === "voice-phone") {
document.getElementById("voice-phone").value = transcript;
}
}
}
// Login function (manual)
function login() {
let email = document.getElementById('login-email').value;
let phone = document.getElementById('login-phone').value;
fetch('/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: email, phone_number: phone })
})
.then(response => response.json())
.then(data => {
if (data.success) {
localStorage.setItem('userName', data.user.Name);
localStorage.setItem('userEmail', email);
localStorage.setItem('userPhone', phone);
window.location.href = "/dashboard";
} else {
alert('Invalid credentials! Please contact admin to register in Salesforce.');
}
})
.catch(error => {
alert('Error logging in!');
});
}
</script>
</body>
</html>