Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +87 -27
templates/index.html
CHANGED
@@ -5,7 +5,55 @@
|
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Biryani Hub Registration</title>
|
7 |
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
8 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
</head>
|
10 |
<body>
|
11 |
<div class="container">
|
@@ -28,12 +76,13 @@
|
|
28 |
|
29 |
<script>
|
30 |
let recognition;
|
|
|
31 |
let isNameCaptured = false;
|
32 |
let isEmailCaptured = false;
|
33 |
|
34 |
if ('webkitSpeechRecognition' in window) {
|
35 |
recognition = new webkitSpeechRecognition();
|
36 |
-
recognition.continuous = false;
|
37 |
recognition.interimResults = false;
|
38 |
recognition.lang = 'en-US';
|
39 |
} else {
|
@@ -42,50 +91,61 @@
|
|
42 |
|
43 |
function speak(text, callback) {
|
44 |
const speech = new SpeechSynthesisUtterance(text);
|
45 |
-
speech.onend = callback;
|
46 |
window.speechSynthesis.speak(speech);
|
47 |
}
|
48 |
|
49 |
-
function
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
|
55 |
-
function
|
56 |
const status = document.getElementById('status');
|
57 |
-
const nameInput = document.getElementById('name');
|
58 |
const emailInput = document.getElementById('email');
|
59 |
-
|
60 |
recognition.start();
|
61 |
recognition.onresult = function(event) {
|
62 |
-
|
63 |
|
64 |
-
//
|
65 |
-
transcript = transcript.replace(/\s+/g, '');
|
66 |
-
|
67 |
if (isNameCaptured && !isEmailCaptured) {
|
68 |
-
|
69 |
-
cleanedEmail =
|
70 |
-
emailInput.value = cleanedEmail
|
71 |
status.textContent = 'Registration complete.';
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
75 |
} else if (!isNameCaptured) {
|
|
|
76 |
nameInput.value = transcript;
|
77 |
-
status.textContent = 'Listening for your email...';
|
78 |
-
recognition.stop();
|
79 |
-
isNameCaptured = true;
|
80 |
-
|
81 |
-
recognition.start();
|
82 |
-
});
|
83 |
}
|
84 |
};
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
window.onload = function () {
|
88 |
-
setTimeout(startProcess, 4000);
|
89 |
};
|
90 |
</script>
|
91 |
</body>
|
|
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Biryani Hub Registration</title>
|
7 |
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
8 |
+
<style>
|
9 |
+
body {
|
10 |
+
font-family: 'Roboto', sans-serif;
|
11 |
+
background: linear-gradient(135deg, #f4c542, #ff8f6a); /* Light gradient background */
|
12 |
+
margin: 0;
|
13 |
+
display: flex;
|
14 |
+
justify-content: center;
|
15 |
+
align-items: center;
|
16 |
+
height: 100vh;
|
17 |
+
text-align: center;
|
18 |
+
}
|
19 |
+
.container {
|
20 |
+
background: lightblue;
|
21 |
+
padding: 40px 50px;
|
22 |
+
border-radius: 10px;
|
23 |
+
width: 400px;
|
24 |
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
25 |
+
}
|
26 |
+
h1 {
|
27 |
+
font-size: 30px;
|
28 |
+
font-weight: bold;
|
29 |
+
color: #ff6a00; /* Bright orange for title */
|
30 |
+
}
|
31 |
+
label {
|
32 |
+
font-size: 18px;
|
33 |
+
margin-top: 20px;
|
34 |
+
display: block;
|
35 |
+
text-align: left;
|
36 |
+
}
|
37 |
+
input[type="text"] {
|
38 |
+
width: 100%;
|
39 |
+
padding: 10px;
|
40 |
+
font-size: 16px;
|
41 |
+
border: 1px solid #ccc;
|
42 |
+
border-radius: 5px;
|
43 |
+
margin-top: 8px;
|
44 |
+
}
|
45 |
+
.info {
|
46 |
+
margin-top: 20px;
|
47 |
+
font-size: 16px;
|
48 |
+
color: #ff6a00;
|
49 |
+
font-weight: bold;
|
50 |
+
}
|
51 |
+
.status {
|
52 |
+
font-size: 14px;
|
53 |
+
color: gray;
|
54 |
+
margin-top: 20px;
|
55 |
+
}
|
56 |
+
</style>
|
57 |
</head>
|
58 |
<body>
|
59 |
<div class="container">
|
|
|
76 |
|
77 |
<script>
|
78 |
let recognition;
|
79 |
+
let isListening = false;
|
80 |
let isNameCaptured = false;
|
81 |
let isEmailCaptured = false;
|
82 |
|
83 |
if ('webkitSpeechRecognition' in window) {
|
84 |
recognition = new webkitSpeechRecognition();
|
85 |
+
recognition.continuous = false; // Stop after capturing each input
|
86 |
recognition.interimResults = false;
|
87 |
recognition.lang = 'en-US';
|
88 |
} else {
|
|
|
91 |
|
92 |
function speak(text, callback) {
|
93 |
const speech = new SpeechSynthesisUtterance(text);
|
94 |
+
speech.onend = callback; // Once the speech ends, call the next function
|
95 |
window.speechSynthesis.speak(speech);
|
96 |
}
|
97 |
|
98 |
+
function startListeningForName() {
|
99 |
+
const status = document.getElementById('status');
|
100 |
+
const nameInput = document.getElementById('name');
|
101 |
+
status.textContent = "Listening for your name...";
|
102 |
+
recognition.start();
|
103 |
+
recognition.onresult = function(event) {
|
104 |
+
const transcript = event.results[0][0].transcript.trim();
|
105 |
+
nameInput.value = transcript;
|
106 |
+
recognition.stop();
|
107 |
+
// Now, prompt for email
|
108 |
+
speak("Tell me your email", startListeningForEmail);
|
109 |
+
};
|
110 |
}
|
111 |
|
112 |
+
function startListeningForEmail() {
|
113 |
const status = document.getElementById('status');
|
|
|
114 |
const emailInput = document.getElementById('email');
|
115 |
+
status.textContent = "Listening for your email...";
|
116 |
recognition.start();
|
117 |
recognition.onresult = function(event) {
|
118 |
+
const transcript = event.results[0][0].transcript.trim();
|
119 |
|
120 |
+
// If name is captured, we now capture email
|
|
|
|
|
121 |
if (isNameCaptured && !isEmailCaptured) {
|
122 |
+
// Correct email input format by removing spaces and handling @ properly
|
123 |
+
const cleanedEmail = transcript.replace(/\s/g, '').replace(/\bat\b/g, '@'); // Replace "at" with "@"
|
124 |
+
emailInput.value = cleanedEmail; // Set the email field with cleaned input
|
125 |
status.textContent = 'Registration complete.';
|
126 |
+
|
127 |
+
// After registration, refresh the page after 20 seconds
|
128 |
+
setTimeout(() => location.reload(), 20000); // Refresh after 20 seconds
|
129 |
+
isEmailCaptured = true; // Mark email as captured
|
130 |
} else if (!isNameCaptured) {
|
131 |
+
// If name is not yet captured, capture name first
|
132 |
nameInput.value = transcript;
|
133 |
+
status.textContent = 'Listening for your email...'; // Prompt for email
|
134 |
+
recognition.stop(); // Stop listening for name
|
135 |
+
isNameCaptured = true; // Mark name as captured
|
136 |
+
recognition.start(); // Start listening for email
|
|
|
|
|
137 |
}
|
138 |
};
|
139 |
}
|
140 |
|
141 |
+
function startProcess() {
|
142 |
+
speak("Welcome to Biryani Hub", function() {
|
143 |
+
speak("Tell me your name", startListeningForName);
|
144 |
+
});
|
145 |
+
}
|
146 |
+
|
147 |
window.onload = function () {
|
148 |
+
setTimeout(startProcess, 4000); // Start process after 4 seconds
|
149 |
};
|
150 |
</script>
|
151 |
</body>
|