Update templates/index.html
Browse files- templates/index.html +356 -32
templates/index.html
CHANGED
|
@@ -2,51 +2,314 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<
|
|
|
|
| 6 |
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
body {
|
| 8 |
-
font-family:
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
}
|
| 12 |
-
|
|
|
|
| 13 |
color: #2c3e50;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
display: block;
|
| 17 |
-
margin-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
width: 100%;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
}
|
|
|
|
| 20 |
textarea {
|
| 21 |
-
height:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
margin-top: 2rem;
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
</style>
|
| 30 |
</head>
|
| 31 |
<body>
|
| 32 |
-
<
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
<script>
|
| 52 |
document.getElementById("chatForm").addEventListener("submit", async (e) => {
|
|
@@ -54,9 +317,28 @@
|
|
| 54 |
|
| 55 |
const message = document.getElementById("message").value;
|
| 56 |
const lang = document.getElementById("lang").value;
|
| 57 |
-
|
| 58 |
const responseBox = document.getElementById("response");
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
try {
|
| 62 |
const res = await fetch("/chat", {
|
|
@@ -68,11 +350,53 @@
|
|
| 68 |
});
|
| 69 |
|
| 70 |
const data = await res.json();
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
} catch (err) {
|
| 73 |
-
responseBox.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
}
|
| 75 |
});
|
| 76 |
</script>
|
| 77 |
</body>
|
| 78 |
-
</html>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Hal Chat - Smart Farming Assistant</title>
|
| 7 |
<style>
|
| 8 |
+
* {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
body {
|
| 15 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 16 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 17 |
+
min-height: 100vh;
|
| 18 |
+
display: flex;
|
| 19 |
+
align-items: center;
|
| 20 |
+
justify-content: center;
|
| 21 |
+
padding: 1rem;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.container {
|
| 25 |
+
background: rgba(255, 255, 255, 0.95);
|
| 26 |
+
backdrop-filter: blur(10px);
|
| 27 |
+
border-radius: 20px;
|
| 28 |
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
|
| 29 |
+
width: 100%;
|
| 30 |
+
max-width: 600px;
|
| 31 |
+
padding: 2.5rem;
|
| 32 |
+
transition: all 0.3s ease;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.container:hover {
|
| 36 |
+
transform: translateY(-5px);
|
| 37 |
+
box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
.header {
|
| 41 |
+
text-align: center;
|
| 42 |
+
margin-bottom: 2.5rem;
|
| 43 |
}
|
| 44 |
+
|
| 45 |
+
.header h1 {
|
| 46 |
color: #2c3e50;
|
| 47 |
+
font-size: 2.2rem;
|
| 48 |
+
margin-bottom: 0.5rem;
|
| 49 |
+
background: linear-gradient(135deg, #667eea, #764ba2);
|
| 50 |
+
-webkit-background-clip: text;
|
| 51 |
+
-webkit-text-fill-color: transparent;
|
| 52 |
+
background-clip: text;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
.header .subtitle {
|
| 56 |
+
color: #7f8c8d;
|
| 57 |
+
font-size: 1rem;
|
| 58 |
+
display: flex;
|
| 59 |
+
align-items: center;
|
| 60 |
+
justify-content: center;
|
| 61 |
+
gap: 0.5rem;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.farm-icon {
|
| 65 |
+
width: 24px;
|
| 66 |
+
height: 24px;
|
| 67 |
+
background: linear-gradient(135deg, #27ae60, #2ecc71);
|
| 68 |
+
border-radius: 50%;
|
| 69 |
+
display: inline-flex;
|
| 70 |
+
align-items: center;
|
| 71 |
+
justify-content: center;
|
| 72 |
+
color: white;
|
| 73 |
+
font-size: 12px;
|
| 74 |
}
|
| 75 |
+
|
| 76 |
+
.form-group {
|
| 77 |
+
margin-bottom: 1.5rem;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
label {
|
| 81 |
display: block;
|
| 82 |
+
margin-bottom: 0.5rem;
|
| 83 |
+
color: #2c3e50;
|
| 84 |
+
font-weight: 600;
|
| 85 |
+
font-size: 0.95rem;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
textarea, select, button {
|
| 89 |
width: 100%;
|
| 90 |
+
border: 2px solid #e0e6ed;
|
| 91 |
+
border-radius: 12px;
|
| 92 |
+
padding: 1rem;
|
| 93 |
+
font-size: 1rem;
|
| 94 |
+
transition: all 0.3s ease;
|
| 95 |
+
background: white;
|
| 96 |
}
|
| 97 |
+
|
| 98 |
textarea {
|
| 99 |
+
height: 120px;
|
| 100 |
+
resize: vertical;
|
| 101 |
+
font-family: inherit;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
textarea:focus, select:focus {
|
| 105 |
+
outline: none;
|
| 106 |
+
border-color: #667eea;
|
| 107 |
+
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
select {
|
| 111 |
+
cursor: pointer;
|
| 112 |
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667eea' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
|
| 113 |
+
background-repeat: no-repeat;
|
| 114 |
+
background-position: right 1rem center;
|
| 115 |
+
appearance: none;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
button {
|
| 119 |
+
background: linear-gradient(135deg, #667eea, #764ba2);
|
| 120 |
+
color: white;
|
| 121 |
+
border: none;
|
| 122 |
+
cursor: pointer;
|
| 123 |
+
font-weight: 600;
|
| 124 |
+
text-transform: uppercase;
|
| 125 |
+
letter-spacing: 0.5px;
|
| 126 |
+
position: relative;
|
| 127 |
+
overflow: hidden;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
button:hover {
|
| 131 |
+
transform: translateY(-2px);
|
| 132 |
+
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
button:active {
|
| 136 |
+
transform: translateY(0);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
button:disabled {
|
| 140 |
+
opacity: 0.7;
|
| 141 |
+
cursor: not-allowed;
|
| 142 |
+
transform: none;
|
| 143 |
+
box-shadow: none;
|
| 144 |
}
|
| 145 |
+
|
| 146 |
+
.loading-spinner {
|
| 147 |
+
display: none;
|
| 148 |
+
width: 20px;
|
| 149 |
+
height: 20px;
|
| 150 |
+
border: 2px solid rgba(255, 255, 255, 0.3);
|
| 151 |
+
border-radius: 50%;
|
| 152 |
+
border-top-color: white;
|
| 153 |
+
animation: spin 1s ease-in-out infinite;
|
| 154 |
+
margin-right: 0.5rem;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
@keyframes spin {
|
| 158 |
+
to { transform: rotate(360deg); }
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
.response-container {
|
| 162 |
margin-top: 2rem;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
.response-box {
|
| 166 |
+
background: #f8f9fa;
|
| 167 |
+
border: 2px solid #e9ecef;
|
| 168 |
+
border-radius: 12px;
|
| 169 |
+
padding: 1.5rem;
|
| 170 |
+
min-height: 60px;
|
| 171 |
+
display: flex;
|
| 172 |
+
align-items: center;
|
| 173 |
+
justify-content: center;
|
| 174 |
+
color: #6c757d;
|
| 175 |
+
transition: all 0.3s ease;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
.response-box.has-content {
|
| 179 |
+
background: linear-gradient(135deg, #f8f9fa, #e9ecef);
|
| 180 |
+
border-color: #667eea;
|
| 181 |
+
color: #2c3e50;
|
| 182 |
+
text-align: left;
|
| 183 |
+
align-items: flex-start;
|
| 184 |
+
justify-content: flex-start;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
.response-box.loading {
|
| 188 |
+
background: linear-gradient(135deg, #667eea, #764ba2);
|
| 189 |
+
color: white;
|
| 190 |
+
animation: pulse 2s ease-in-out infinite;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
@keyframes pulse {
|
| 194 |
+
0%, 100% { opacity: 1; }
|
| 195 |
+
50% { opacity: 0.8; }
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
.thinking-dots {
|
| 199 |
+
display: inline-flex;
|
| 200 |
+
gap: 4px;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
.thinking-dots span {
|
| 204 |
+
width: 6px;
|
| 205 |
+
height: 6px;
|
| 206 |
+
border-radius: 50%;
|
| 207 |
+
background: white;
|
| 208 |
+
animation: bounce 1.4s ease-in-out infinite both;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
|
| 212 |
+
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
|
| 213 |
+
|
| 214 |
+
@keyframes bounce {
|
| 215 |
+
0%, 80%, 100% { transform: scale(0); }
|
| 216 |
+
40% { transform: scale(1); }
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.language-flag {
|
| 220 |
+
display: inline-block;
|
| 221 |
+
width: 20px;
|
| 222 |
+
height: 15px;
|
| 223 |
+
border-radius: 2px;
|
| 224 |
+
margin-right: 8px;
|
| 225 |
+
vertical-align: middle;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
.flag-en { background: linear-gradient(to bottom, #012169 33%, white 33%, white 66%, #C8102E 66%); }
|
| 229 |
+
.flag-hi { background: linear-gradient(to bottom, #FF9933 33%, white 33%, white 66%, #138808 66%); }
|
| 230 |
+
.flag-mr { background: linear-gradient(to bottom, #FF9933 33%, white 33%, white 66%, #138808 66%); }
|
| 231 |
+
.flag-te { background: linear-gradient(to bottom, #FF9933 33%, white 33%, white 66%, #138808 66%); }
|
| 232 |
+
.flag-bn { background: linear-gradient(to bottom, #006A4E 50%, #F42A41 50%); }
|
| 233 |
+
|
| 234 |
+
@media (max-width: 768px) {
|
| 235 |
+
.container {
|
| 236 |
+
padding: 1.5rem;
|
| 237 |
+
margin: 1rem;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
.header h1 {
|
| 241 |
+
font-size: 1.8rem;
|
| 242 |
+
}
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
.feature-pills {
|
| 246 |
+
display: flex;
|
| 247 |
+
flex-wrap: wrap;
|
| 248 |
+
gap: 0.5rem;
|
| 249 |
+
margin-bottom: 1.5rem;
|
| 250 |
+
justify-content: center;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
.pill {
|
| 254 |
+
background: rgba(102, 126, 234, 0.1);
|
| 255 |
+
color: #667eea;
|
| 256 |
+
padding: 0.4rem 0.8rem;
|
| 257 |
+
border-radius: 20px;
|
| 258 |
+
font-size: 0.8rem;
|
| 259 |
+
font-weight: 500;
|
| 260 |
}
|
| 261 |
</style>
|
| 262 |
</head>
|
| 263 |
<body>
|
| 264 |
+
<div class="container">
|
| 265 |
+
<div class="header">
|
| 266 |
+
<h1>🌾 Hal Smart Farming</h1>
|
| 267 |
+
<div class="subtitle">
|
| 268 |
+
<span class="farm-icon">🚜</span>
|
| 269 |
+
Your AI-Powered Agricultural Assistant
|
| 270 |
+
</div>
|
| 271 |
+
</div>
|
| 272 |
+
|
| 273 |
+
<div class="feature-pills">
|
| 274 |
+
<span class="pill">Crop Guidance</span>
|
| 275 |
+
<span class="pill">Weather Insights</span>
|
| 276 |
+
<span class="pill">Pest Control</span>
|
| 277 |
+
<span class="pill">Soil Health</span>
|
| 278 |
+
</div>
|
| 279 |
+
|
| 280 |
+
<form id="chatForm">
|
| 281 |
+
<div class="form-group">
|
| 282 |
+
<label for="message">💬 Ask your farming question:</label>
|
| 283 |
+
<textarea
|
| 284 |
+
id="message"
|
| 285 |
+
placeholder="e.g., How can I improve millet yield in sandy soil? What's the best time to plant jowar?"
|
| 286 |
+
required
|
| 287 |
+
></textarea>
|
| 288 |
+
</div>
|
| 289 |
|
| 290 |
+
<div class="form-group">
|
| 291 |
+
<label for="lang">🌍 Response Language:</label>
|
| 292 |
+
<select id="lang">
|
| 293 |
+
<option value="en"><span class="language-flag flag-en"></span>English</option>
|
| 294 |
+
<option value="hi"><span class="language-flag flag-hi"></span>Hindi (हिंदी)</option>
|
| 295 |
+
<option value="mr"><span class="language-flag flag-mr"></span>Marathi (मराठी)</option>
|
| 296 |
+
<option value="te"><span class="language-flag flag-te"></span>Telugu (తెలుగు)</option>
|
| 297 |
+
<option value="bn"><span class="language-flag flag-bn"></span>Bengali (বাংলা)</option>
|
| 298 |
+
</select>
|
| 299 |
+
</div>
|
| 300 |
|
| 301 |
+
<button type="submit" id="submitBtn">
|
| 302 |
+
<span class="loading-spinner"></span>
|
| 303 |
+
<span class="button-text">Get Smart Advice</span>
|
| 304 |
+
</button>
|
| 305 |
+
</form>
|
| 306 |
|
| 307 |
+
<div class="response-container">
|
| 308 |
+
<div id="response" class="response-box">
|
| 309 |
+
Ask me anything about farming, crops, weather, or agricultural practices!
|
| 310 |
+
</div>
|
| 311 |
+
</div>
|
| 312 |
+
</div>
|
| 313 |
|
| 314 |
<script>
|
| 315 |
document.getElementById("chatForm").addEventListener("submit", async (e) => {
|
|
|
|
| 317 |
|
| 318 |
const message = document.getElementById("message").value;
|
| 319 |
const lang = document.getElementById("lang").value;
|
|
|
|
| 320 |
const responseBox = document.getElementById("response");
|
| 321 |
+
const submitBtn = document.getElementById("submitBtn");
|
| 322 |
+
const spinner = submitBtn.querySelector(".loading-spinner");
|
| 323 |
+
const buttonText = submitBtn.querySelector(".button-text");
|
| 324 |
+
|
| 325 |
+
// Update button state
|
| 326 |
+
submitBtn.disabled = true;
|
| 327 |
+
spinner.style.display = "inline-block";
|
| 328 |
+
buttonText.textContent = "Thinking...";
|
| 329 |
+
|
| 330 |
+
// Update response box
|
| 331 |
+
responseBox.className = "response-box loading";
|
| 332 |
+
responseBox.innerHTML = `
|
| 333 |
+
<div style="display: flex; align-items: center; gap: 10px;">
|
| 334 |
+
<span>Analyzing your farming question</span>
|
| 335 |
+
<div class="thinking-dots">
|
| 336 |
+
<span></span>
|
| 337 |
+
<span></span>
|
| 338 |
+
<span></span>
|
| 339 |
+
</div>
|
| 340 |
+
</div>
|
| 341 |
+
`;
|
| 342 |
|
| 343 |
try {
|
| 344 |
const res = await fetch("/chat", {
|
|
|
|
| 350 |
});
|
| 351 |
|
| 352 |
const data = await res.json();
|
| 353 |
+
|
| 354 |
+
responseBox.className = "response-box has-content";
|
| 355 |
+
responseBox.innerHTML = `
|
| 356 |
+
<div style="border-left: 4px solid #667eea; padding-left: 1rem;">
|
| 357 |
+
<strong style="color: #667eea; display: block; margin-bottom: 0.5rem;">🤖 Hal's Advice:</strong>
|
| 358 |
+
<div style="line-height: 1.6;">${data.response || data.error}</div>
|
| 359 |
+
</div>
|
| 360 |
+
`;
|
| 361 |
} catch (err) {
|
| 362 |
+
responseBox.className = "response-box has-content";
|
| 363 |
+
responseBox.innerHTML = `
|
| 364 |
+
<div style="border-left: 4px solid #e74c3c; padding-left: 1rem;">
|
| 365 |
+
<strong style="color: #e74c3c; display: block; margin-bottom: 0.5rem;">⚠️ Connection Error:</strong>
|
| 366 |
+
<div style="color: #e74c3c;">Unable to connect to the server. Please check your internet connection and try again.</div>
|
| 367 |
+
</div>
|
| 368 |
+
`;
|
| 369 |
+
} finally {
|
| 370 |
+
// Reset button state
|
| 371 |
+
submitBtn.disabled = false;
|
| 372 |
+
spinner.style.display = "none";
|
| 373 |
+
buttonText.textContent = "Get Smart Advice";
|
| 374 |
+
}
|
| 375 |
+
});
|
| 376 |
+
|
| 377 |
+
// Auto-resize textarea
|
| 378 |
+
const textarea = document.getElementById("message");
|
| 379 |
+
textarea.addEventListener("input", function() {
|
| 380 |
+
this.style.height = "auto";
|
| 381 |
+
this.style.height = Math.min(this.scrollHeight, 200) + "px";
|
| 382 |
+
});
|
| 383 |
+
|
| 384 |
+
// Add some sample questions on click
|
| 385 |
+
const sampleQuestions = [
|
| 386 |
+
"How can I increase millet productivity in drought conditions?",
|
| 387 |
+
"What are the best organic fertilizers for jowar cultivation?",
|
| 388 |
+
"How to identify and control pest attacks in finger millet?",
|
| 389 |
+
"When is the optimal time to harvest pearl millet?",
|
| 390 |
+
"What soil preparation is needed for foxtail millet?"
|
| 391 |
+
];
|
| 392 |
+
|
| 393 |
+
let questionIndex = 0;
|
| 394 |
+
textarea.addEventListener("focus", function() {
|
| 395 |
+
if (!this.value) {
|
| 396 |
+
this.placeholder = sampleQuestions[questionIndex % sampleQuestions.length];
|
| 397 |
+
questionIndex++;
|
| 398 |
}
|
| 399 |
});
|
| 400 |
</script>
|
| 401 |
</body>
|
| 402 |
+
</html>
|