CSNET commited on
Commit
b263139
·
verified ·
1 Parent(s): 9080d1c

ลองสร้าง html5 ที่ใช้ NDVI กับไร่จริงในประเทศไทยมาซัก 1 แปลงให้ดูให้เห็นภาพหน่อย

Browse files
Files changed (7) hide show
  1. README.md +8 -5
  2. components/footer.js +314 -0
  3. components/navbar.js +296 -0
  4. components/ndvi-legend.js +386 -0
  5. index.html +408 -19
  6. script.js +328 -0
  7. style.css +183 -19
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Thairice Ndvi Visualizer
3
- emoji: 🚀
4
- colorFrom: red
5
- colorTo: purple
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: ThaiRice NDVI Visualizer 🌾
3
+ colorFrom: yellow
4
+ colorTo: blue
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
components/footer.js ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomFooter extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ :host {
7
+ display: block;
8
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
9
+ }
10
+
11
+ .footer {
12
+ background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
13
+ color: #f9fafb;
14
+ padding: 3rem 0 2rem;
15
+ border-top: 1px solid rgba(16, 185, 129, 0.2);
16
+ }
17
+
18
+ .footer-container {
19
+ max-width: 1280px;
20
+ margin: 0 auto;
21
+ padding: 0 1rem;
22
+ }
23
+
24
+ .footer-content {
25
+ display: grid;
26
+ grid-template-columns: repeat(1, 1fr);
27
+ gap: 2rem;
28
+ margin-bottom: 3rem;
29
+ }
30
+
31
+ @media (min-width: 768px) {
32
+ .footer-content {
33
+ grid-template-columns: repeat(4, 1fr);
34
+ }
35
+ }
36
+
37
+ .footer-section h3 {
38
+ font-size: 1.125rem;
39
+ font-weight: 600;
40
+ margin-bottom: 1.5rem;
41
+ color: #10b981;
42
+ }
43
+
44
+ .footer-links {
45
+ display: flex;
46
+ flex-direction: column;
47
+ gap: 0.75rem;
48
+ }
49
+
50
+ .footer-link {
51
+ color: #d1d5db;
52
+ text-decoration: none;
53
+ font-size: 0.875rem;
54
+ transition: color 0.2s ease;
55
+ display: flex;
56
+ align-items: center;
57
+ gap: 0.5rem;
58
+ }
59
+
60
+ .footer-link:hover {
61
+ color: #10b981;
62
+ }
63
+
64
+ .footer-link i {
65
+ width: 1rem;
66
+ height: 1rem;
67
+ }
68
+
69
+ .footer-info {
70
+ color: #9ca3af;
71
+ font-size: 0.875rem;
72
+ line-height: 1.5;
73
+ }
74
+
75
+ .footer-social {
76
+ display: flex;
77
+ gap: 1rem;
78
+ margin-top: 1.5rem;
79
+ }
80
+
81
+ .social-link {
82
+ display: inline-flex;
83
+ align-items: center;
84
+ justify-content: center;
85
+ width: 2.5rem;
86
+ height: 2.5rem;
87
+ background: rgba(255, 255, 255, 0.1);
88
+ border-radius: 50%;
89
+ color: #f9fafb;
90
+ transition: all 0.2s ease;
91
+ }
92
+
93
+ .social-link:hover {
94
+ background: #10b981;
95
+ transform: translateY(-2px);
96
+ }
97
+
98
+ .footer-bottom {
99
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
100
+ padding-top: 2rem;
101
+ text-align: center;
102
+ }
103
+
104
+ .footer-bottom-content {
105
+ display: flex;
106
+ flex-direction: column;
107
+ align-items: center;
108
+ gap: 1rem;
109
+ }
110
+
111
+ @media (min-width: 640px) {
112
+ .footer-bottom-content {
113
+ flex-direction: row;
114
+ justify-content: space-between;
115
+ }
116
+ }
117
+
118
+ .copyright {
119
+ color: #9ca3af;
120
+ font-size: 0.875rem;
121
+ }
122
+
123
+ .footer-legal {
124
+ display: flex;
125
+ gap: 1.5rem;
126
+ }
127
+
128
+ .legal-link {
129
+ color: #9ca3af;
130
+ text-decoration: none;
131
+ font-size: 0.875rem;
132
+ transition: color 0.2s ease;
133
+ }
134
+
135
+ .legal-link:hover {
136
+ color: #10b981;
137
+ }
138
+
139
+ .back-to-top {
140
+ position: fixed;
141
+ bottom: 2rem;
142
+ right: 2rem;
143
+ width: 3rem;
144
+ height: 3rem;
145
+ background: #10b981;
146
+ color: white;
147
+ border-radius: 50%;
148
+ display: flex;
149
+ align-items: center;
150
+ justify-content: center;
151
+ cursor: pointer;
152
+ box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
153
+ transition: all 0.3s ease;
154
+ opacity: 0;
155
+ transform: translateY(20px);
156
+ z-index: 100;
157
+ }
158
+
159
+ .back-to-top.visible {
160
+ opacity: 1;
161
+ transform: translateY(0);
162
+ }
163
+
164
+ .back-to-top:hover {
165
+ background: #059669;
166
+ transform: translateY(-2px);
167
+ box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
168
+ }
169
+ </style>
170
+
171
+ <footer class="footer">
172
+ <div class="footer-container">
173
+ <div class="footer-content">
174
+ <div class="footer-section">
175
+ <h3>ThaiRice NDVI</h3>
176
+ <p class="footer-info">
177
+ Advanced NDVI monitoring platform for Thai rice farmers.
178
+ Real-time vegetation health analysis and actionable insights.
179
+ </p>
180
+ <div class="footer-social">
181
+ <a href="#" class="social-link" aria-label="Facebook">
182
+ <i data-feather="facebook"></i>
183
+ </a>
184
+ <a href="#" class="social-link" aria-label="Twitter">
185
+ <i data-feather="twitter"></i>
186
+ </a>
187
+ <a href="#" class="social-link" aria-label="LinkedIn">
188
+ <i data-feather="linkedin"></i>
189
+ </a>
190
+ <a href="#" class="social-link" aria-label="GitHub">
191
+ <i data-feather="github"></i>
192
+ </a>
193
+ </div>
194
+ </div>
195
+
196
+ <div class="footer-section">
197
+ <h3>Platform</h3>
198
+ <div class="footer-links">
199
+ <a href="#ndvi-map" class="footer-link">
200
+ <i data-feather="map"></i>
201
+ NDVI Maps
202
+ </a>
203
+ <a href="#field-details" class="footer-link">
204
+ <i data-feather="bar-chart-2"></i>
205
+ Analytics
206
+ </a>
207
+ <a href="#recommendations" class="footer-link">
208
+ <i data-feather="clipboard"></i>
209
+ Recommendations
210
+ </a>
211
+ <a href="/fields" class="footer-link">
212
+ <i data-feather="grid"></i>
213
+ All Fields
214
+ </a>
215
+ </div>
216
+ </div>
217
+
218
+ <div class="footer-section">
219
+ <h3>Resources</h3>
220
+ <div class="footer-links">
221
+ <a href="/documentation" class="footer-link">
222
+ <i data-feather="book"></i>
223
+ Documentation
224
+ </a>
225
+ <a href="/api" class="footer-link">
226
+ <i data-feather="code"></i>
227
+ API Reference
228
+ </a>
229
+ <a href="/blog" class="footer-link">
230
+ <i data-feather="edit"></i>
231
+ Blog
232
+ </a>
233
+ <a href="/support" class="footer-link">
234
+ <i data-feather="help-circle"></i>
235
+ Support
236
+ </a>
237
+ </div>
238
+ </div>
239
+
240
+ <div class="footer-section">
241
+ <h3>Contact</h3>
242
+ <div class="footer-links">
243
+ <a href="mailto:info@thairice-ndvi.com" class="footer-link">
244
+ <i data-feather="mail"></i>
245
+ info@thairice-ndvi.com
246
+ </a>
247
+ <a href="tel:+6621234567" class="footer-link">
248
+ <i data-feather="phone"></i>
249
+ +66 2 123 4567
250
+ </a>
251
+ <div class="footer-link">
252
+ <i data-feather="map-pin"></i>
253
+ <span>Bangkok, Thailand</span>
254
+ </div>
255
+ </div>
256
+ </div>
257
+ </div>
258
+
259
+ <div class="footer-bottom">
260
+ <div class="footer-bottom-content">
261
+ <div class="copyright">
262
+ © 2023 ThaiRice NDVI Visualizer. All rights reserved.
263
+ </div>
264
+ <div class="footer-legal">
265
+ <a href="/privacy" class="legal-link">Privacy Policy</a>
266
+ <a href="/terms" class="legal-link">Terms of Service</a>
267
+ <a href="/cookies" class="legal-link">Cookie Policy</a>
268
+ </div>
269
+ </div>
270
+ </div>
271
+ </div>
272
+
273
+ <div class="back-to-top" id="backToTop">
274
+ <i data-feather="arrow-up"></i>
275
+ </div>
276
+ </footer>
277
+ `;
278
+
279
+ // Initialize back to top button
280
+ this.initializeBackToTop();
281
+
282
+ // Replace feather icons
283
+ setTimeout(() => {
284
+ if (window.feather) {
285
+ window.feather.replace();
286
+ }
287
+ }, 100);
288
+ }
289
+
290
+ initializeBackToTop() {
291
+ const backToTop = this.shadowRoot.getElementById('backToTop');
292
+
293
+ if (backToTop) {
294
+ // Show/hide button based on scroll position
295
+ window.addEventListener('scroll', () => {
296
+ if (window.pageYOffset > 300) {
297
+ backToTop.classList.add('visible');
298
+ } else {
299
+ backToTop.classList.remove('visible');
300
+ }
301
+ });
302
+
303
+ // Scroll to top when clicked
304
+ backToTop.addEventListener('click', () => {
305
+ window.scrollTo({
306
+ top: 0,
307
+ behavior: 'smooth'
308
+ });
309
+ });
310
+ }
311
+ }
312
+ }
313
+
314
+ customElements.define('custom-footer', CustomFooter);
components/navbar.js ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomNavbar extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ :host {
7
+ display: block;
8
+ position: sticky;
9
+ top: 0;
10
+ z-index: 1000;
11
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
12
+ }
13
+
14
+ .navbar {
15
+ background: rgba(255, 255, 255, 0.95);
16
+ backdrop-filter: blur(10px);
17
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
18
+ border-bottom: 1px solid rgba(16, 185, 129, 0.1);
19
+ }
20
+
21
+ .nav-container {
22
+ max-width: 1280px;
23
+ margin: 0 auto;
24
+ padding: 0 1rem;
25
+ }
26
+
27
+ .nav-content {
28
+ display: flex;
29
+ align-items: center;
30
+ justify-content: space-between;
31
+ height: 4rem;
32
+ }
33
+
34
+ .logo {
35
+ display: flex;
36
+ align-items: center;
37
+ gap: 0.75rem;
38
+ text-decoration: none;
39
+ color: #111827;
40
+ font-weight: 700;
41
+ font-size: 1.5rem;
42
+ }
43
+
44
+ .logo-icon {
45
+ color: #10b981;
46
+ width: 2rem;
47
+ height: 2rem;
48
+ }
49
+
50
+ .nav-links {
51
+ display: flex;
52
+ align-items: center;
53
+ gap: 2rem;
54
+ }
55
+
56
+ .nav-link {
57
+ color: #4b5563;
58
+ text-decoration: none;
59
+ font-weight: 500;
60
+ font-size: 0.95rem;
61
+ padding: 0.5rem 0;
62
+ position: relative;
63
+ transition: color 0.2s ease;
64
+ }
65
+
66
+ .nav-link:hover {
67
+ color: #10b981;
68
+ }
69
+
70
+ .nav-link.active {
71
+ color: #10b981;
72
+ }
73
+
74
+ .nav-link.active::after {
75
+ content: '';
76
+ position: absolute;
77
+ bottom: 0;
78
+ left: 0;
79
+ right: 0;
80
+ height: 2px;
81
+ background: linear-gradient(90deg, #10b981, #059669);
82
+ border-radius: 1px;
83
+ }
84
+
85
+ .mobile-menu-btn {
86
+ display: none;
87
+ background: none;
88
+ border: none;
89
+ color: #4b5563;
90
+ cursor: pointer;
91
+ padding: 0.5rem;
92
+ border-radius: 0.375rem;
93
+ }
94
+
95
+ .mobile-menu-btn:hover {
96
+ background: #f3f4f6;
97
+ }
98
+
99
+ .mobile-menu {
100
+ display: none;
101
+ background: white;
102
+ border-top: 1px solid #e5e7eb;
103
+ padding: 1rem;
104
+ animation: slideDown 0.3s ease;
105
+ }
106
+
107
+ .mobile-nav-links {
108
+ display: flex;
109
+ flex-direction: column;
110
+ gap: 0.5rem;
111
+ }
112
+
113
+ .mobile-nav-link {
114
+ color: #4b5563;
115
+ text-decoration: none;
116
+ padding: 0.75rem 1rem;
117
+ border-radius: 0.5rem;
118
+ font-weight: 500;
119
+ transition: background-color 0.2s ease;
120
+ }
121
+
122
+ .mobile-nav-link:hover {
123
+ background: #f3f4f6;
124
+ }
125
+
126
+ .mobile-nav-link.active {
127
+ background: #d1fae5;
128
+ color: #065f46;
129
+ }
130
+
131
+ @keyframes slideDown {
132
+ from {
133
+ opacity: 0;
134
+ transform: translateY(-10px);
135
+ }
136
+ to {
137
+ opacity: 1;
138
+ transform: translateY(0);
139
+ }
140
+ }
141
+
142
+ @media (max-width: 768px) {
143
+ .nav-links {
144
+ display: none;
145
+ }
146
+
147
+ .mobile-menu-btn {
148
+ display: block;
149
+ }
150
+
151
+ .mobile-menu.active {
152
+ display: block;
153
+ }
154
+ }
155
+
156
+ @media (min-width: 769px) {
157
+ .mobile-menu {
158
+ display: none !important;
159
+ }
160
+ }
161
+ </style>
162
+
163
+ <nav class="navbar">
164
+ <div class="nav-container">
165
+ <div class="nav-content">
166
+ <a href="/" class="logo">
167
+ <i data-feather="leaf" class="logo-icon"></i>
168
+ <span>ThaiRice NDVI</span>
169
+ </a>
170
+
171
+ <div class="nav-links">
172
+ <a href="#ndvi-map" class="nav-link active">
173
+ <i data-feather="map" style="width: 1.25rem; height: 1.25rem; margin-right: 0.5rem;"></i>
174
+ Map
175
+ </a>
176
+ <a href="#field-details" class="nav-link">
177
+ <i data-feather="bar-chart-2" style="width: 1.25rem; height: 1.25rem; margin-right: 0.5rem;"></i>
178
+ Analytics
179
+ </a>
180
+ <a href="#recommendations" class="nav-link">
181
+ <i data-feather="clipboard" style="width: 1.25rem; height: 1.25rem; margin-right: 0.5rem;"></i>
182
+ Recommendations
183
+ </a>
184
+ <a href="/fields" class="nav-link">
185
+ <i data-feather="grid" style="width: 1.25rem; height: 1.25rem; margin-right: 0.5rem;"></i>
186
+ All Fields
187
+ </a>
188
+ <button class="bg-green-600 hover:bg-green-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 transform hover:-translate-y-0.5 shadow-md hover:shadow-lg" onclick="exportNDVIReport()">
189
+ <i data-feather="download" style="width: 1.25rem; height: 1.25rem; margin-right: 0.5rem;"></i>
190
+ Export Report
191
+ </button>
192
+ </div>
193
+
194
+ <button class="mobile-menu-btn" id="mobileMenuBtn">
195
+ <i data-feather="menu" style="width: 1.5rem; height: 1.5rem;"></i>
196
+ </button>
197
+ </div>
198
+
199
+ <div class="mobile-menu" id="mobileMenu">
200
+ <div class="mobile-nav-links">
201
+ <a href="#ndvi-map" class="mobile-nav-link active">
202
+ <i data-feather="map" style="width: 1.25rem; height: 1.25rem; margin-right: 0.75rem;"></i>
203
+ Map
204
+ </a>
205
+ <a href="#field-details" class="mobile-nav-link">
206
+ <i data-feather="bar-chart-2" style="width: 1.25rem; height: 1.25rem; margin-right: 0.75rem;"></i>
207
+ Analytics
208
+ </a>
209
+ <a href="#recommendations" class="mobile-nav-link">
210
+ <i data-feather="clipboard" style="width: 1.25rem; height: 1.25rem; margin-right: 0.75rem;"></i>
211
+ Recommendations
212
+ </a>
213
+ <a href="/fields" class="mobile-nav-link">
214
+ <i data-feather="grid" style="width: 1.25rem; height: 1.25rem; margin-right: 0.75rem;"></i>
215
+ All Fields
216
+ </a>
217
+ <button class="bg-green-600 hover:bg-green-700 text-white font-medium py-3 px-4 rounded-lg transition duration-200 mt-2 flex items-center justify-center" onclick="exportNDVIReport()">
218
+ <i data-feather="download" style="width: 1.25rem; height: 1.25rem; margin-right: 0.75rem;"></i>
219
+ Export Report
220
+ </button>
221
+ </div>
222
+ </div>
223
+ </div>
224
+ </nav>
225
+ `;
226
+
227
+ // Initialize mobile menu
228
+ this.initializeMobileMenu();
229
+
230
+ // Update active link based on scroll
231
+ this.initializeScrollSpy();
232
+
233
+ // Replace feather icons
234
+ setTimeout(() => {
235
+ if (window.feather) {
236
+ window.feather.replace();
237
+ }
238
+ }, 100);
239
+ }
240
+
241
+ initializeMobileMenu() {
242
+ const mobileMenuBtn = this.shadowRoot.getElementById('mobileMenuBtn');
243
+ const mobileMenu = this.shadowRoot.getElementById('mobileMenu');
244
+
245
+ if (mobileMenuBtn && mobileMenu) {
246
+ mobileMenuBtn.addEventListener('click', () => {
247
+ mobileMenu.classList.toggle('active');
248
+ const icon = mobileMenuBtn.querySelector('i');
249
+ if (mobileMenu.classList.contains('active')) {
250
+ icon.setAttribute('data-feather', 'x');
251
+ } else {
252
+ icon.setAttribute('data-feather', 'menu');
253
+ }
254
+ window.feather.replace();
255
+ });
256
+
257
+ // Close menu when clicking on a link
258
+ const mobileLinks = mobileMenu.querySelectorAll('.mobile-nav-link');
259
+ mobileLinks.forEach(link => {
260
+ link.addEventListener('click', () => {
261
+ mobileMenu.classList.remove('active');
262
+ const icon = mobileMenuBtn.querySelector('i');
263
+ icon.setAttribute('data-feather', 'menu');
264
+ window.feather.replace();
265
+ });
266
+ });
267
+ }
268
+ }
269
+
270
+ initializeScrollSpy() {
271
+ const navLinks = this.shadowRoot.querySelectorAll('.nav-link, .mobile-nav-link');
272
+ const sections = ['ndvi-map', 'field-details', 'recommendations'];
273
+
274
+ const observer = new IntersectionObserver((entries) => {
275
+ entries.forEach(entry => {
276
+ if (entry.isIntersecting) {
277
+ const id = entry.target.id;
278
+
279
+ navLinks.forEach(link => {
280
+ link.classList.remove('active');
281
+ if (link.getAttribute('href') === `#${id}`) {
282
+ link.classList.add('active');
283
+ }
284
+ });
285
+ }
286
+ });
287
+ }, { threshold: 0.5 });
288
+
289
+ sections.forEach(section => {
290
+ const element = document.getElementById(section);
291
+ if (element) observer.observe(element);
292
+ });
293
+ }
294
+ }
295
+
296
+ customElements.define('custom-navbar', CustomNavbar);
components/ndvi-legend.js ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomNdvilegend extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ :host {
7
+ display: block;
8
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
9
+ }
10
+
11
+ .legend-container {
12
+ background: white;
13
+ border-radius: 0.75rem;
14
+ padding: 1.5rem;
15
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
16
+ border: 1px solid #e5e7eb;
17
+ }
18
+
19
+ .legend-header {
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: space-between;
23
+ margin-bottom: 1.25rem;
24
+ }
25
+
26
+ .legend-title {
27
+ font-size: 1.125rem;
28
+ font-weight: 600;
29
+ color: #111827;
30
+ display: flex;
31
+ align-items: center;
32
+ gap: 0.5rem;
33
+ }
34
+
35
+ .legend-title i {
36
+ color: #10b981;
37
+ }
38
+
39
+ .ndvi-value {
40
+ font-size: 1.5rem;
41
+ font-weight: 700;
42
+ color: #059669;
43
+ background: #d1fae5;
44
+ padding: 0.25rem 0.75rem;
45
+ border-radius: 0.5rem;
46
+ }
47
+
48
+ .gradient-container {
49
+ position: relative;
50
+ height: 2rem;
51
+ border-radius: 0.5rem;
52
+ overflow: hidden;
53
+ margin-bottom: 1rem;
54
+ background: linear-gradient(90deg,
55
+ #d32f2f 0%,
56
+ #f57c00 20%,
57
+ #fbc02d 40%,
58
+ #7cb342 60%,
59
+ #388e3c 80%,
60
+ #1b5e20 100%);
61
+ }
62
+
63
+ .gradient-labels {
64
+ display: flex;
65
+ justify-content: space-between;
66
+ margin-bottom: 1.5rem;
67
+ }
68
+
69
+ .gradient-label {
70
+ font-size: 0.75rem;
71
+ color: #6b7280;
72
+ font-weight: 500;
73
+ }
74
+
75
+ .health-levels {
76
+ display: grid;
77
+ grid-template-columns: repeat(3, 1fr);
78
+ gap: 1rem;
79
+ }
80
+
81
+ @media (min-width: 640px) {
82
+ .health-levels {
83
+ grid-template-columns: repeat(6, 1fr);
84
+ }
85
+ }
86
+
87
+ .health-level {
88
+ text-align: center;
89
+ padding: 0.75rem;
90
+ border-radius: 0.5rem;
91
+ transition: all 0.2s ease;
92
+ cursor: help;
93
+ }
94
+
95
+ .health-level:hover {
96
+ transform: translateY(-2px);
97
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
98
+ }
99
+
100
+ .health-level.critical {
101
+ background: #fee2e2;
102
+ border: 1px solid #fecaca;
103
+ }
104
+
105
+ .health-level.poor {
106
+ background: #ffedd5;
107
+ border: 1px solid #fed7aa;
108
+ }
109
+
110
+ .health-level.moderate {
111
+ background: #fef3c7;
112
+ border: 1px solid #fde68a;
113
+ }
114
+
115
+ .health-level.fair {
116
+ background: #dcfce7;
117
+ border: 1px solid #bbf7d0;
118
+ }
119
+
120
+ .health-level.good {
121
+ background: #bbf7d0;
122
+ border: 1px solid #86efac;
123
+ }
124
+
125
+ .health-level.excellent {
126
+ background: #86efac;
127
+ border: 1px solid #4ade80;
128
+ }
129
+
130
+ .health-color {
131
+ width: 1.5rem;
132
+ height: 1.5rem;
133
+ border-radius: 50%;
134
+ margin: 0 auto 0.5rem;
135
+ }
136
+
137
+ .critical .health-color {
138
+ background: #d32f2f;
139
+ }
140
+
141
+ .poor .health-color {
142
+ background: #f57c00;
143
+ }
144
+
145
+ .moderate .health-color {
146
+ background: #fbc02d;
147
+ }
148
+
149
+ .fair .health-color {
150
+ background: #7cb342;
151
+ }
152
+
153
+ .good .health-color {
154
+ background: #388e3c;
155
+ }
156
+
157
+ .excellent .health-color {
158
+ background: #1b5e20;
159
+ }
160
+
161
+ .health-name {
162
+ font-size: 0.875rem;
163
+ font-weight: 600;
164
+ color: #111827;
165
+ margin-bottom: 0.25rem;
166
+ }
167
+
168
+ .health-range {
169
+ font-size: 0.75rem;
170
+ color: #6b7280;
171
+ }
172
+
173
+ .health-description {
174
+ font-size: 0.75rem;
175
+ color: #6b7280;
176
+ margin-top: 0.5rem;
177
+ line-height: 1.4;
178
+ }
179
+
180
+ .current-marker {
181
+ position: absolute;
182
+ top: -0.5rem;
183
+ width: 2px;
184
+ height: 3rem;
185
+ background: #111827;
186
+ transform: translateX(-50%);
187
+ }
188
+
189
+ .current-marker::after {
190
+ content: 'Current';
191
+ position: absolute;
192
+ top: -1.5rem;
193
+ left: 50%;
194
+ transform: translateX(-50%);
195
+ font-size: 0.75rem;
196
+ font-weight: 600;
197
+ color: #111827;
198
+ white-space: nowrap;
199
+ }
200
+
201
+ .current-marker::before {
202
+ content: '';
203
+ position: absolute;
204
+ top: -0.5rem;
205
+ left: 50%;
206
+ transform: translateX(-50%);
207
+ width: 0;
208
+ height: 0;
209
+ border-left: 0.5rem solid transparent;
210
+ border-right: 0.5rem solid transparent;
211
+ border-top: 0.5rem solid #111827;
212
+ }
213
+
214
+ .tooltip {
215
+ position: absolute;
216
+ background: #111827;
217
+ color: white;
218
+ padding: 0.5rem 0.75rem;
219
+ border-radius: 0.375rem;
220
+ font-size: 0.75rem;
221
+ white-space: nowrap;
222
+ z-index: 1000;
223
+ pointer-events: none;
224
+ opacity: 0;
225
+ transition: opacity 0.2s ease;
226
+ }
227
+
228
+ .tooltip::after {
229
+ content: '';
230
+ position: absolute;
231
+ top: 100%;
232
+ left: 50%;
233
+ transform: translateX(-50%);
234
+ border-width: 0.375rem;
235
+ border-style: solid;
236
+ border-color: #111827 transparent transparent transparent;
237
+ }
238
+ </style>
239
+
240
+ <div class="legend-container">
241
+ <div class="legend-header">
242
+ <div class="legend-title">
243
+ <i data-feather="layers"></i>
244
+ NDVI Health Legend
245
+ </div>
246
+ <div class="ndvi-value">0.62</div>
247
+ </div>
248
+
249
+ <div class="gradient-container" id="gradientBar">
250
+ <div class="current-marker" style="left: 62%;"></div>
251
+ </div>
252
+
253
+ <div class="gradient-labels">
254
+ <span class="gradient-label">0.0</span>
255
+ <span class="gradient-label">0.2</span>
256
+ <span class="gradient-label">0.4</span>
257
+ <span class="gradient-label">0.6</span>
258
+ <span class="gradient-label">0.8</span>
259
+ <span class="gradient-label">1.0</span>
260
+ </div>
261
+
262
+ <div class="health-levels">
263
+ <div class="health-level critical" data-tooltip="No vegetation, bare soil">
264
+ <div class="health-color"></div>
265
+ <div class="health-name">Critical</div>
266
+ <div class="health-range">0.0 - 0.2</div>
267
+ <div class="health-description">No vegetation</div>
268
+ </div>
269
+
270
+ <div class="health-level poor" data-tooltip="Sparse vegetation, stressed">
271
+ <div class="health-color"></div>
272
+ <div class="health-name">Poor</div>
273
+ <div class="health-range">0.2 - 0.3</div>
274
+ <div class="health-description">Sparse vegetation</div>
275
+ </div>
276
+
277
+ <div class="health-level moderate" data-tooltip="Moderate vegetation">
278
+ <div class="health-color"></div>
279
+ <div class="health-name">Moderate</div>
280
+ <div class="health-range">0.3 - 0.5</div>
281
+ <div class="health-description">Moderate growth</div>
282
+ </div>
283
+
284
+ <div class="health-level fair" data-tooltip="Healthy vegetation">
285
+ <div class="health-color"></div>
286
+ <div class="health-name">Fair</div>
287
+ <div class="health-range">0.5 - 0.6</div>
288
+ <div class="health-description">Healthy growth</div>
289
+ </div>
290
+
291
+ <div class="health-level good" data-tooltip="Very healthy vegetation">
292
+ <div class="health-color"></div>
293
+ <div class="health-name">Good</div>
294
+ <div class="health-range">0.6 - 0.8</div>
295
+ <div class="health-description">Very healthy</div>
296
+ </div>
297
+
298
+ <div class="health-level excellent" data-tooltip="Dense, thriving vegetation">
299
+ <div class="health-color"></div>
300
+ <div class="health-name">Excellent</div>
301
+ <div class="health-range">0.8 - 1.0</div>
302
+ <div class="health-description">Thriving growth</div>
303
+ </div>
304
+ </div>
305
+ </div>
306
+ `;
307
+
308
+ // Initialize tooltips
309
+ this.initializeTooltips();
310
+
311
+ // Update current marker position
312
+ this.updateCurrentMarker();
313
+
314
+ // Replace feather icons
315
+ setTimeout(() => {
316
+ if (window.feather) {
317
+ window.feather.replace();
318
+ }
319
+ }, 100);
320
+ }
321
+
322
+ initializeTooltips() {
323
+ const healthLevels = this.shadowRoot.querySelectorAll('.health-level');
324
+
325
+ healthLevels.forEach(level => {
326
+ const tooltipText = level.getAttribute('data-tooltip');
327
+
328
+ level.addEventListener('mouseenter', (e) => {
329
+ const tooltip = document.createElement('div');
330
+ tooltip.className = 'tooltip';
331
+ tooltip.textContent = tooltipText;
332
+
333
+ const rect = level.getBoundingClientRect();
334
+ tooltip.style.left = `${rect.left + rect.width/2}px`;
335
+ tooltip.style.top = `${rect.top - 10}px`;
336
+ tooltip.style.transform = 'translateX(-50%) translateY(-100%)';
337
+
338
+ document.body.appendChild(tooltip);
339
+
340
+ // Show tooltip
341
+ setTimeout(() => {
342
+ tooltip.style.opacity = '1';
343
+ }, 10);
344
+
345
+ level._tooltip = tooltip;
346
+ });
347
+
348
+ level.addEventListener('mouseleave', () => {
349
+ if (level._tooltip) {
350
+ level._tooltip.remove();
351
+ level._tooltip = null;
352
+ }
353
+ });
354
+ });
355
+ }
356
+
357
+ updateCurrentMarker() {
358
+ const currentNDVI = 0.62; // This could be dynamic
359
+ const marker = this.shadowRoot.querySelector('.current-marker');
360
+ const ndviValue = this.shadowRoot.querySelector('.ndvi-value');
361
+
362
+ if (marker) {
363
+ const position = currentNDVI * 100;
364
+ marker.style.left = `${position}%`;
365
+
366
+ // Update color based on NDVI value
367
+ let color;
368
+ if (currentNDVI < 0.2) color = '#d32f2f';
369
+ else if (currentNDVI < 0.3) color = '#f57c00';
370
+ else if (currentNDVI < 0.5) color = '#fbc02d';
371
+ else if (currentNDVI < 0.6) color = '#7cb342';
372
+ else if (currentNDVI < 0.8) color = '#388e3c';
373
+ else color = '#1b5e20';
374
+
375
+ marker.style.background = color;
376
+ marker.style.setProperty('--marker-color', color);
377
+
378
+ // Update the displayed value
379
+ if (ndviValue) {
380
+ ndviValue.textContent = currentNDVI.toFixed(2);
381
+ }
382
+ }
383
+ }
384
+ }
385
+
386
+ customElements.define('custom-ndvi-legend', CustomNdvilegend);
index.html CHANGED
@@ -1,19 +1,408 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE 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>ThaiRice NDVI Visualizer - Real-time Crop Health Monitoring</title>
7
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://unpkg.com/feather-icons"></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
11
+ <link rel="stylesheet" href="style.css">
12
+ <script src="components/navbar.js"></script>
13
+ <script src="components/footer.js"></script>
14
+ <script src="components/ndvi-legend.js"></script>
15
+ </head>
16
+ <body class="bg-gray-50 text-gray-800">
17
+ <!-- Navigation -->
18
+ <custom-navbar></custom-navbar>
19
+
20
+ <!-- Hero Section -->
21
+ <section class="relative bg-gradient-to-r from-green-600 to-emerald-800 text-white py-16 md:py-24">
22
+ <div class="container mx-auto px-4">
23
+ <div class="max-w-3xl mx-auto text-center">
24
+ <h1 class="text-4xl md:text-6xl font-bold mb-6">ThaiRice NDVI Visualizer</h1>
25
+ <p class="text-xl md:text-2xl mb-8 opacity-90">Real-time Normalized Difference Vegetation Index monitoring for rice fields in Thailand</p>
26
+ <div class="flex flex-wrap justify-center gap-4">
27
+ <a href="#ndvi-map" class="bg-white text-green-700 hover:bg-green-50 font-semibold py-3 px-8 rounded-lg shadow-lg transition duration-300 transform hover:-translate-y-1">
28
+ <i data-feather="map" class="inline mr-2"></i> View NDVI Map
29
+ </a>
30
+ <a href="#field-details" class="bg-transparent border-2 border-white hover:bg-white/20 font-semibold py-3 px-8 rounded-lg transition duration-300">
31
+ <i data-feather="info" class="inline mr-2"></i> Field Details
32
+ </a>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ <div class="absolute bottom-0 left-0 right-0">
37
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320">
38
+ <path fill="#f9fafb" fill-opacity="1" d="M0,96L48,112C96,128,192,160,288,160C384,160,480,128,576,112C672,96,768,96,864,112C960,128,1056,160,1152,160C1248,160,1344,128,1392,112L1440,96L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"></path>
39
+ </svg>
40
+ </div>
41
+ </section>
42
+
43
+ <!-- Main Content -->
44
+ <main class="container mx-auto px-4 py-12">
45
+ <!-- NDVI Map Section -->
46
+ <section id="ndvi-map" class="mb-20">
47
+ <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8">
48
+ <div>
49
+ <h2 class="text-3xl font-bold text-gray-900 mb-2">Rice Field NDVI Analysis</h2>
50
+ <p class="text-gray-600">Field ID: TH-RF-2023-042 • Last updated: Today, 14:30</p>
51
+ </div>
52
+ <div class="mt-4 md:mt-0">
53
+ <div class="inline-flex items-center bg-white rounded-lg shadow p-3">
54
+ <i data-feather="calendar" class="text-green-600 mr-2"></i>
55
+ <span class="font-medium">Growing Season: June - November 2023</span>
56
+ </div>
57
+ </div>
58
+ </div>
59
+
60
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
61
+ <!-- Map Visualization -->
62
+ <div class="lg:col-span-2">
63
+ <div class="bg-white rounded-2xl shadow-xl overflow-hidden border border-gray-200">
64
+ <div class="bg-gray-100 p-4 border-b border-gray-200">
65
+ <div class="flex items-center justify-between">
66
+ <h3 class="text-xl font-semibold text-gray-800">
67
+ <i data-feather="map-pin" class="inline mr-2 text-green-600"></i>
68
+ Rice Field Location: Suphan Buri Province
69
+ </h3>
70
+ <span class="bg-green-100 text-green-800 text-sm font-medium px-3 py-1 rounded-full">
71
+ 15.3 Hectares
72
+ </span>
73
+ </div>
74
+ </div>
75
+ <div class="relative">
76
+ <!-- NDVI Map Image -->
77
+ <div class="relative h-96 overflow-hidden">
78
+ <img src="http://static.photos/agriculture/1200x630/78" alt="Rice Field NDVI Map" class="w-full h-full object-cover">
79
+ <div class="absolute inset-0 bg-gradient-to-t from-black/30 to-transparent"></div>
80
+ <!-- Map Overlay Elements -->
81
+ <div class="absolute top-4 left-4 bg-white/90 backdrop-blur-sm rounded-lg p-3 shadow-lg">
82
+ <div class="flex items-center">
83
+ <div class="w-3 h-3 rounded-full bg-green-500 mr-2"></div>
84
+ <span class="font-medium">Healthy Vegetation</span>
85
+ </div>
86
+ </div>
87
+ <div class="absolute bottom-4 right-4 bg-white/90 backdrop-blur-sm rounded-lg p-3 shadow-lg">
88
+ <div class="text-sm">
89
+ <div class="font-semibold text-gray-800">NDVI Range: 0.4 - 0.8</div>
90
+ <div class="text-gray-600">Average: 0.62</div>
91
+ </div>
92
+ </div>
93
+ </div>
94
+
95
+ <!-- Map Controls -->
96
+ <div class="absolute bottom-4 left-4 flex space-x-2">
97
+ <button class="bg-white hover:bg-gray-100 text-gray-800 p-2 rounded-lg shadow-md transition duration-200">
98
+ <i data-feather="zoom-in"></i>
99
+ </button>
100
+ <button class="bg-white hover:bg-gray-100 text-gray-800 p-2 rounded-lg shadow-md transition duration-200">
101
+ <i data-feather="zoom-out"></i>
102
+ </button>
103
+ <button class="bg-white hover:bg-gray-100 text-gray-800 p-2 rounded-lg shadow-md transition duration-200">
104
+ <i data-feather="maximize"></i>
105
+ </button>
106
+ </div>
107
+ </div>
108
+ <div class="p-6">
109
+ <custom-ndvi-legend></custom-ndvi-legend>
110
+ </div>
111
+ </div>
112
+ </div>
113
+
114
+ <!-- Field Statistics -->
115
+ <div class="space-y-6">
116
+ <!-- Overall Health Card -->
117
+ <div class="bg-white rounded-2xl shadow-xl p-6 border border-gray-200">
118
+ <div class="flex items-center justify-between mb-4">
119
+ <h3 class="text-xl font-semibold text-gray-800">Field Health Score</h3>
120
+ <i data-feather="activity" class="text-green-600"></i>
121
+ </div>
122
+ <div class="text-center mb-6">
123
+ <div class="inline-flex items-center justify-center w-32 h-32 rounded-full bg-gradient-to-r from-green-500 to-emerald-600 shadow-lg">
124
+ <span class="text-4xl font-bold text-white">82%</span>
125
+ </div>
126
+ <p class="text-gray-600 mt-4">Excellent growing conditions</p>
127
+ </div>
128
+ <div class="space-y-4">
129
+ <div>
130
+ <div class="flex justify-between text-sm mb-1">
131
+ <span class="text-gray-600">Vegetation Density</span>
132
+ <span class="font-medium text-green-700">High</span>
133
+ </div>
134
+ <div class="w-full bg-gray-200 rounded-full h-2">
135
+ <div class="bg-green-600 h-2 rounded-full" style="width: 85%"></div>
136
+ </div>
137
+ </div>
138
+ <div>
139
+ <div class="flex justify-between text-sm mb-1">
140
+ <span class="text-gray-600">Water Stress</span>
141
+ <span class="font-medium text-green-700">Low</span>
142
+ </div>
143
+ <div class="w-full bg-gray-200 rounded-full h-2">
144
+ <div class="bg-green-500 h-2 rounded-full" style="width: 22%"></div>
145
+ </div>
146
+ </div>
147
+ </div>
148
+ </div>
149
+
150
+ <!-- Quick Actions -->
151
+ <div class="bg-gradient-to-br from-green-50 to-emerald-50 rounded-2xl shadow-lg p-6 border border-green-100">
152
+ <h3 class="text-xl font-semibold text-gray-800 mb-4">Quick Actions</h3>
153
+ <div class="space-y-3">
154
+ <button class="w-full flex items-center justify-between bg-white hover:bg-green-50 text-gray-800 p-3 rounded-lg border border-green-200 transition duration-200 group">
155
+ <div class="flex items-center">
156
+ <i data-feather="download" class="text-green-600 mr-3"></i>
157
+ <span>Download NDVI Report</span>
158
+ </div>
159
+ <i data-feather="chevron-right" class="text-gray-400 group-hover:text-green-600"></i>
160
+ </button>
161
+ <button class="w-full flex items-center justify-between bg-white hover:bg-green-50 text-gray-800 p-3 rounded-lg border border-green-200 transition duration-200 group">
162
+ <div class="flex items-center">
163
+ <i data-feather="share-2" class="text-green-600 mr-3"></i>
164
+ <span>Share with Team</span>
165
+ </div>
166
+ <i data-feather="chevron-right" class="text-gray-400 group-hover:text-green-600"></i>
167
+ </button>
168
+ <button class="w-full flex items-center justify-between bg-white hover:bg-green-50 text-gray-800 p-3 rounded-lg border border-green-200 transition duration-200 group">
169
+ <div class="flex items-center">
170
+ <i data-feather="bell" class="text-green-600 mr-3"></i>
171
+ <span>Set Health Alerts</span>
172
+ </div>
173
+ <i data-feather="chevron-right" class="text-gray-400 group-hover:text-green-600"></i>
174
+ </button>
175
+ </div>
176
+ </div>
177
+ </div>
178
+ </div>
179
+ </section>
180
+
181
+ <!-- Field Details Section -->
182
+ <section id="field-details" class="mb-20">
183
+ <h2 class="text-3xl font-bold text-gray-900 mb-8">Field Details & Historical Data</h2>
184
+
185
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-10">
186
+ <!-- Info Cards -->
187
+ <div class="bg-white rounded-xl shadow-lg p-6 border border-gray-200 hover:shadow-xl transition duration-300">
188
+ <div class="flex items-center mb-4">
189
+ <div class="bg-blue-100 p-3 rounded-lg mr-4">
190
+ <i data-feather="map-pin" class="text-blue-600"></i>
191
+ </div>
192
+ <div>
193
+ <h4 class="font-semibold text-gray-800">Location</h4>
194
+ <p class="text-gray-600 text-sm">Suphan Buri, Thailand</p>
195
+ </div>
196
+ </div>
197
+ <p class="text-gray-700">Lat: 14.4745° N, Long: 100.1175° E</p>
198
+ </div>
199
+
200
+ <div class="bg-white rounded-xl shadow-lg p-6 border border-gray-200 hover:shadow-xl transition duration-300">
201
+ <div class="flex items-center mb-4">
202
+ <div class="bg-green-100 p-3 rounded-lg mr-4">
203
+ <i data-feather="droplet" class="text-green-600"></i>
204
+ </div>
205
+ <div>
206
+ <h4 class="font-semibold text-gray-800">Rice Variety</h4>
207
+ <p class="text-gray-600 text-sm">Hom Mali 105</p>
208
+ </div>
209
+ </div>
210
+ <p class="text-gray-700">Premium Jasmine Rice</p>
211
+ </div>
212
+
213
+ <div class="bg-white rounded-xl shadow-lg p-6 border border-gray-200 hover:shadow-xl transition duration-300">
214
+ <div class="flex items-center mb-4">
215
+ <div class="bg-amber-100 p-3 rounded-lg mr-4">
216
+ <i data-feather="sun" class="text-amber-600"></i>
217
+ </div>
218
+ <div>
219
+ <h4 class="font-semibold text-gray-800">Planting Date</h4>
220
+ <p class="text-gray-600 text-sm">June 15, 2023</p>
221
+ </div>
222
+ </div>
223
+ <p class="text-gray-700">Day 87 of growth cycle</p>
224
+ </div>
225
+
226
+ <div class="bg-white rounded-xl shadow-lg p-6 border border-gray-200 hover:shadow-xl transition duration-300">
227
+ <div class="flex items-center mb-4">
228
+ <div class="bg-purple-100 p-3 rounded-lg mr-4">
229
+ <i data-feather="trending-up" class="text-purple-600"></i>
230
+ </div>
231
+ <div>
232
+ <h4 class="font-semibold text-gray-800">Expected Yield</h4>
233
+ <p class="text-gray-600 text-sm">8.2 tons/hectare</p>
234
+ </div>
235
+ </div>
236
+ <p class="text-gray-700">+12% vs. regional average</p>
237
+ </div>
238
+ </div>
239
+
240
+ <!-- Historical Chart -->
241
+ <div class="bg-white rounded-2xl shadow-xl p-6 border border-gray-200">
242
+ <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8">
243
+ <div>
244
+ <h3 class="text-2xl font-bold text-gray-900 mb-2">NDVI Trend (Last 30 Days)</h3>
245
+ <p class="text-gray-600">Tracking vegetation health throughout the growing season</p>
246
+ </div>
247
+ <div class="mt-4 md:mt-0">
248
+ <div class="inline-flex bg-gray-100 rounded-lg p-1">
249
+ <button class="px-4 py-2 rounded-md bg-white shadow text-gray-800 font-medium">30D</button>
250
+ <button class="px-4 py-2 rounded-md text-gray-600 hover:text-gray-800 font-medium">90D</button>
251
+ <button class="px-4 py-2 rounded-md text-gray-600 hover:text-gray-800 font-medium">1Y</button>
252
+ </div>
253
+ </div>
254
+ </div>
255
+
256
+ <!-- Chart Container -->
257
+ <div class="h-80 relative">
258
+ <!-- Simulated Chart -->
259
+ <div class="absolute inset-0 flex items-end">
260
+ <!-- Chart bars simulation -->
261
+ <div class="flex-1 h-full flex items-end justify-around px-4">
262
+ <div class="w-8 bg-gradient-to-t from-red-400 to-red-300 rounded-t-lg" style="height: 40%"></div>
263
+ <div class="w-8 bg-gradient-to-t from-orange-400 to-orange-300 rounded-t-lg" style="height: 55%"></div>
264
+ <div class="w-8 bg-gradient-to-t from-yellow-400 to-yellow-300 rounded-t-lg" style="height: 65%"></div>
265
+ <div class="w-8 bg-gradient-to-t from-green-400 to-green-300 rounded-t-lg" style="height: 75%"></div>
266
+ <div class="w-8 bg-gradient-to-t from-green-500 to-green-400 rounded-t-lg" style="height: 82%"></div>
267
+ <div class="w-8 bg-gradient-to-t from-green-600 to-green-500 rounded-t-lg" style="height: 85%"></div>
268
+ <div class="w-8 bg-gradient-to-t from-green-700 to-green-600 rounded-t-lg" style="height: 88%"></div>
269
+ </div>
270
+ </div>
271
+
272
+ <!-- Chart Labels -->
273
+ <div class="absolute bottom-0 left-0 right-0 border-t border-gray-200 pt-2">
274
+ <div class="flex justify-around text-sm text-gray-500">
275
+ <span>Week 1</span>
276
+ <span>Week 2</span>
277
+ <span>Week 3</span>
278
+ <span>Week 4</span>
279
+ </div>
280
+ </div>
281
+
282
+ <!-- Current NDVI Indicator -->
283
+ <div class="absolute top-8 right-8 bg-white border border-green-200 rounded-lg p-4 shadow-lg">
284
+ <div class="text-center">
285
+ <div class="text-2xl font-bold text-green-700">0.62</div>
286
+ <div class="text-sm text-gray-600">Current NDVI</div>
287
+ <div class="text-xs text-green-600 mt-1">
288
+ <i data-feather="trending-up" class="inline w-4 h-4"></i>
289
+ +0.08 from last week
290
+ </div>
291
+ </div>
292
+ </div>
293
+ </div>
294
+
295
+ <!-- Chart Legend -->
296
+ <div class="flex flex-wrap justify-center gap-6 mt-8 pt-6 border-t border-gray-200">
297
+ <div class="flex items-center">
298
+ <div class="w-4 h-4 rounded-full bg-red-400 mr-2"></div>
299
+ <span class="text-sm text-gray-700">Low Vegetation (0.0-0.2)</span>
300
+ </div>
301
+ <div class="flex items-center">
302
+ <div class="w-4 h-4 rounded-full bg-green-400 mr-2"></div>
303
+ <span class="text-sm text-gray-700">Moderate (0.2-0.5)</span>
304
+ </div>
305
+ <div class="flex items-center">
306
+ <div class="w-4 h-4 rounded-full bg-green-600 mr-2"></div>
307
+ <span class="text-sm text-gray-700">High (0.5-0.8)</span>
308
+ </div>
309
+ </div>
310
+ </div>
311
+ </section>
312
+
313
+ <!-- Recommendations Section -->
314
+ <section class="mb-20">
315
+ <h2 class="text-3xl font-bold text-gray-900 mb-8">AI-Powered Recommendations</h2>
316
+
317
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
318
+ <div class="bg-gradient-to-br from-blue-50 to-white rounded-2xl shadow-lg p-6 border border-blue-100">
319
+ <div class="flex items-center mb-4">
320
+ <div class="bg-blue-100 p-3 rounded-lg mr-4">
321
+ <i data-feather="droplet" class="text-blue-600"></i>
322
+ </div>
323
+ <div>
324
+ <h3 class="text-xl font-semibold text-gray-800">Irrigation</h3>
325
+ <p class="text-blue-600 text-sm">Optimal Schedule</p>
326
+ </div>
327
+ </div>
328
+ <p class="text-gray-700 mb-4">Water levels are optimal. Next irrigation recommended in 48 hours.</p>
329
+ <div class="text-sm text-gray-600">
330
+ <i data-feather="check-circle" class="inline mr-1 text-green-500 w-4 h-4"></i>
331
+ Soil moisture: 78%
332
+ </div>
333
+ </div>
334
+
335
+ <div class="bg-gradient-to-br from-amber-50 to-white rounded-2xl shadow-lg p-6 border border-amber-100">
336
+ <div class="flex items-center mb-4">
337
+ <div class="bg-amber-100 p-3 rounded-lg mr-4">
338
+ <i data-feather="package" class="text-amber-600"></i>
339
+ </div>
340
+ <div>
341
+ <h3 class="text-xl font-semibold text-gray-800">Fertilization</h3>
342
+ <p class="text-amber-600 text-sm">Scheduled Next Week</p>
343
+ </div>
344
+ </div>
345
+ <p class="text-gray-700 mb-4">Nitrogen levels showing slight decline. Apply NPK 16-16-8 at 25kg/hectare.</p>
346
+ <div class="text-sm text-gray-600">
347
+ <i data-feather="alert-circle" class="inline mr-1 text-amber-500 w-4 h-4"></i>
348
+ Nitrogen index: 0.42
349
+ </div>
350
+ </div>
351
+
352
+ <div class="bg-gradient-to-br from-green-50 to-white rounded-2xl shadow-lg p-6 border border-green-100">
353
+ <div class="flex items-center mb-4">
354
+ <div class="bg-green-100 p-3 rounded-lg mr-4">
355
+ <i data-feather="shield" class="text-green-600"></i>
356
+ </div>
357
+ <div>
358
+ <h3 class="text-xl font-semibold text-gray-800">Pest Control</h3>
359
+ <p class="text-green-600 text-sm">Low Risk</p>
360
+ </div>
361
+ </div>
362
+ <p class="text-gray-700 mb-4">No signs of pest infestation detected. Continue regular monitoring.</p>
363
+ <div class="text-sm text-gray-600">
364
+ <i data-feather="check-circle" class="inline mr-1 text-green-500 w-4 h-4"></i>
365
+ Last inspection: 5 days ago
366
+ </div>
367
+ </div>
368
+ </div>
369
+ </section>
370
+ </main>
371
+
372
+ <!-- Footer -->
373
+ <custom-footer></custom-footer>
374
+
375
+ <!-- Scripts -->
376
+ <script src="script.js"></script>
377
+ <script>
378
+ feather.replace();
379
+
380
+ // Initialize tooltips
381
+ document.addEventListener('DOMContentLoaded', function() {
382
+ const tooltipTriggers = document.querySelectorAll('[data-tooltip]');
383
+ tooltipTriggers.forEach(trigger => {
384
+ trigger.addEventListener('mouseenter', function(e) {
385
+ const tooltip = document.createElement('div');
386
+ tooltip.className = 'absolute z-50 px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm tooltip';
387
+ tooltip.textContent = this.getAttribute('data-tooltip');
388
+ document.body.appendChild(tooltip);
389
+
390
+ const rect = this.getBoundingClientRect();
391
+ tooltip.style.left = `${rect.left + rect.width/2 - tooltip.offsetWidth/2}px`;
392
+ tooltip.style.top = `${rect.top - tooltip.offsetHeight - 10}px`;
393
+
394
+ this._tooltip = tooltip;
395
+ });
396
+
397
+ trigger.addEventListener('mouseleave', function() {
398
+ if (this._tooltip) {
399
+ this._tooltip.remove();
400
+ this._tooltip = null;
401
+ }
402
+ });
403
+ });
404
+ });
405
+ </script>
406
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
407
+ </body>
408
+ </html>
script.js ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // ThaiRice NDVI Visualizer - Main JavaScript
2
+
3
+ // Initialize application
4
+ document.addEventListener('DOMContentLoaded', function() {
5
+ console.log('ThaiRice NDVI Visualizer initialized');
6
+
7
+ // Initialize components
8
+ initNDVIInteractions();
9
+ initDateDisplay();
10
+ initHealthScoreAnimation();
11
+ initChartSimulation();
12
+
13
+ // Set up service worker for offline functionality
14
+ if ('serviceWorker' in navigator) {
15
+ navigator.serviceWorker.register('/sw.js').catch(console.error);
16
+ }
17
+ });
18
+
19
+ // NDVI Map Interactions
20
+ function initNDVIInteractions() {
21
+ const mapControls = document.querySelectorAll('.map-control');
22
+ const ndviImage = document.querySelector('img[alt="Rice Field NDVI Map"]');
23
+
24
+ mapControls.forEach(control => {
25
+ control.addEventListener('click', function(e) {
26
+ e.preventDefault();
27
+ const action = this.querySelector('i').getAttribute('data-feather');
28
+
29
+ switch(action) {
30
+ case 'zoom-in':
31
+ simulateZoom(1.2);
32
+ break;
33
+ case 'zoom-out':
34
+ simulateZoom(0.8);
35
+ break;
36
+ case 'maximize':
37
+ toggleFullscreen(ndviImage);
38
+ break;
39
+ }
40
+
41
+ // Add click feedback
42
+ this.classList.add('scale-95');
43
+ setTimeout(() => this.classList.remove('scale-95'), 150);
44
+ });
45
+ });
46
+ }
47
+
48
+ // Simulate zoom effect
49
+ function simulateZoom(factor) {
50
+ const mapContainer = document.querySelector('.relative.h-96');
51
+ const img = mapContainer.querySelector('img');
52
+
53
+ // Store current transform
54
+ const currentTransform = img.style.transform || 'scale(1)';
55
+ const currentScale = parseFloat(currentTransform.match(/scale\(([^)]+)\)/)?.[1] || 1);
56
+ const newScale = currentScale * factor;
57
+
58
+ // Limit zoom range
59
+ if (newScale < 0.5 || newScale > 3) return;
60
+
61
+ img.style.transform = `scale(${newScale})`;
62
+ img.style.transition = 'transform 0.3s ease';
63
+
64
+ // Update controls state
65
+ updateZoomControls(newScale);
66
+ }
67
+
68
+ function updateZoomControls(scale) {
69
+ const zoomIn = document.querySelector('[data-feather="zoom-in"]').closest('button');
70
+ const zoomOut = document.querySelector('[data-feather="zoom-out"]').closest('button');
71
+
72
+ zoomIn.disabled = scale >= 3;
73
+ zoomOut.disabled = scale <= 0.5;
74
+ }
75
+
76
+ function toggleFullscreen(element) {
77
+ if (!document.fullscreenElement) {
78
+ if (element.requestFullscreen) {
79
+ element.requestFullscreen();
80
+ } else if (element.webkitRequestFullscreen) {
81
+ element.webkitRequestFullscreen();
82
+ } else if (element.msRequestFullscreen) {
83
+ element.msRequestFullscreen();
84
+ }
85
+ } else {
86
+ if (document.exitFullscreen) {
87
+ document.exitFullscreen();
88
+ } else if (document.webkitExitFullscreen) {
89
+ document.webkitExitFullscreen();
90
+ } else if (document.msExitFullscreen) {
91
+ document.msExitFullscreen();
92
+ }
93
+ }
94
+ }
95
+
96
+ // Initialize date display
97
+ function initDateDisplay() {
98
+ const dateElements = document.querySelectorAll('[data-date-format]');
99
+ const now = new Date();
100
+
101
+ dateElements.forEach(element => {
102
+ const format = element.getAttribute('data-date-format');
103
+ let formattedDate;
104
+
105
+ switch(format) {
106
+ case 'relative':
107
+ formattedDate = getRelativeDate(now);
108
+ break;
109
+ case 'full':
110
+ formattedDate = now.toLocaleDateString('en-US', {
111
+ weekday: 'long',
112
+ year: 'numeric',
113
+ month: 'long',
114
+ day: 'numeric'
115
+ });
116
+ break;
117
+ default:
118
+ formattedDate = now.toLocaleDateString();
119
+ }
120
+
121
+ if (element.tagName === 'INPUT') {
122
+ element.value = formattedDate;
123
+ } else {
124
+ element.textContent = formattedDate;
125
+ }
126
+ });
127
+ }
128
+
129
+ function getRelativeDate(date) {
130
+ const now = new Date();
131
+ const diffMs = now - date;
132
+ const diffMins = Math.floor(diffMs / 60000);
133
+ const diffHours = Math.floor(diffMins / 60);
134
+ const diffDays = Math.floor(diffHours / 24);
135
+
136
+ if (diffMins < 1) return 'Just now';
137
+ if (diffMins < 60) return `${diffMins} minutes ago`;
138
+ if (diffHours < 24) return `${diffHours} hours ago`;
139
+ if (diffDays === 1) return 'Yesterday';
140
+ if (diffDays < 7) return `${diffDays} days ago`;
141
+
142
+ return date.toLocaleDateString();
143
+ }
144
+
145
+ // Animate health score
146
+ function initHealthScoreAnimation() {
147
+ const healthScore = document.querySelector('.inline-flex.items-center.justify-center');
148
+ if (!healthScore) return;
149
+
150
+ // Add animation class
151
+ healthScore.classList.add('pulse-slow');
152
+
153
+ // Simulate real-time updates
154
+ setInterval(() => {
155
+ const randomChange = Math.random() * 0.02 - 0.01; // +/- 1%
156
+ const currentScore = parseFloat(healthScore.querySelector('span').textContent);
157
+ const newScore = Math.min(100, Math.max(0, currentScore + randomChange));
158
+
159
+ healthScore.querySelector('span').textContent = `${newScore.toFixed(1)}%`;
160
+
161
+ // Update gradient based on score
162
+ updateHealthGradient(newScore);
163
+ }, 10000); // Update every 10 seconds
164
+ }
165
+
166
+ function updateHealthGradient(score) {
167
+ const healthIndicator = document.querySelector('.health-indicator');
168
+ if (!healthIndicator) return;
169
+
170
+ let color;
171
+ if (score >= 80) color = '#10b981'; // Green
172
+ else if (score >= 60) color = '#f59e0b'; // Amber
173
+ else color = '#ef4444'; // Red
174
+
175
+ healthIndicator.style.setProperty('--indicator-color', color);
176
+ }
177
+
178
+ // Simulate chart data updates
179
+ function initChartSimulation() {
180
+ const chartBars = document.querySelectorAll('.bg-gradient-to-t');
181
+ if (!chartBars.length) return;
182
+
183
+ // Animate bars on load
184
+ setTimeout(() => {
185
+ chartBars.forEach((bar, index) => {
186
+ bar.style.height = bar.style.height || getComputedStyle(bar).height;
187
+ bar.style.height = '0';
188
+
189
+ setTimeout(() => {
190
+ bar.style.transition = 'height 0.8s ease';
191
+ bar.style.height = bar.dataset.originalHeight || bar.style.height;
192
+ }, index * 100);
193
+ });
194
+ }, 500);
195
+
196
+ // Simulate real-time updates
197
+ setInterval(() => {
198
+ const currentNDVI = document.querySelector('.text-2xl.font-bold.text-green-700');
199
+ if (!currentNDVI) return;
200
+
201
+ const currentValue = parseFloat(currentNDVI.textContent);
202
+ const randomChange = (Math.random() * 0.04 - 0.02); // +/- 0.02
203
+ const newValue = Math.min(0.9, Math.max(0.1, currentValue + randomChange));
204
+
205
+ // Animate the change
206
+ animateValue(currentNDVI, currentValue, newValue, 1000);
207
+
208
+ // Update trend indicator
209
+ updateTrendIndicator(randomChange);
210
+
211
+ }, 15000); // Update every 15 seconds
212
+ }
213
+
214
+ function animateValue(element, start, end, duration) {
215
+ const startTime = performance.now();
216
+
217
+ function update(currentTime) {
218
+ const elapsed = currentTime - startTime;
219
+ const progress = Math.min(elapsed / duration, 1);
220
+
221
+ const current = start + (end - start) * progress;
222
+ element.textContent = current.toFixed(2);
223
+
224
+ if (progress < 1) {
225
+ requestAnimationFrame(update);
226
+ }
227
+ }
228
+
229
+ requestAnimationFrame(update);
230
+ }
231
+
232
+ function updateTrendIndicator(change) {
233
+ const trendElement = document.querySelector('.text-xs.text-green-600.mt-1');
234
+ if (!trendElement) return;
235
+
236
+ const icon = trendElement.querySelector('i');
237
+ const text = trendElement.querySelector('span') || trendElement;
238
+
239
+ if (change > 0) {
240
+ icon.setAttribute('data-feather', 'trending-up');
241
+ text.textContent = `+${Math.abs(change).toFixed(2)} from last update`;
242
+ trendElement.className = 'text-xs text-green-600 mt-1';
243
+ } else if (change < 0) {
244
+ icon.setAttribute('data-feather', 'trending-down');
245
+ text.textContent = `-${Math.abs(change).toFixed(2)} from last update`;
246
+ trendElement.className = 'text-xs text-red-600 mt-1';
247
+ } else {
248
+ icon.setAttribute('data-feather', 'minus');
249
+ text.textContent = 'No change from last update';
250
+ trendElement.className = 'text-xs text-gray-600 mt-1';
251
+ }
252
+
253
+ feather.replace();
254
+ }
255
+
256
+ // Export functionality
257
+ function exportNDVIReport() {
258
+ const reportData = {
259
+ fieldId: 'TH-RF-2023-042',
260
+ location: 'Suphan Buri, Thailand',
261
+ area: '15.3 hectares',
262
+ ndviScore: document.querySelector('.text-4xl.font-bold.text-white')?.textContent || '82%',
263
+ currentNDVI: document.querySelector('.text-2xl.font-bold.text-green-700')?.textContent || '0.62',
264
+ lastUpdated: new Date().toISOString(),
265
+ recommendations: Array.from(document.querySelectorAll('.bg-gradient-to-br')).map(card => ({
266
+ category: card.querySelector('h3')?.textContent,
267
+ status: card.querySelector('p.text-sm')?.textContent,
268
+ details: card.querySelector('p.text-gray-700')?.textContent
269
+ }))
270
+ };
271
+
272
+ // Create download link
273
+ const dataStr = JSON.stringify(reportData, null, 2);
274
+ const dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);
275
+
276
+ const exportFileDefaultName = `ndvi-report-${reportData.fieldId}-${new Date().toISOString().split('T')[0]}.json`;
277
+
278
+ const linkElement = document.createElement('a');
279
+ linkElement.setAttribute('href', dataUri);
280
+ linkElement.setAttribute('download', exportFileDefaultName);
281
+ linkElement.click();
282
+
283
+ // Show notification
284
+ showNotification('Report exported successfully!', 'success');
285
+ }
286
+
287
+ // Notification system
288
+ function showNotification(message, type = 'info') {
289
+ const notification = document.createElement('div');
290
+ notification.className = `fixed top-4 right-4 z-50 px-6 py-4 rounded-lg shadow-lg transform transition-transform duration-300 translate-x-full ${
291
+ type === 'success' ? 'bg-green-500 text-white' :
292
+ type === 'error' ? 'bg-red-500 text-white' :
293
+ 'bg-blue-500 text-white'
294
+ }`;
295
+ notification.textContent = message;
296
+
297
+ document.body.appendChild(notification);
298
+
299
+ // Animate in
300
+ setTimeout(() => {
301
+ notification.classList.remove('translate-x-full');
302
+ }, 10);
303
+
304
+ // Auto remove after 5 seconds
305
+ setTimeout(() => {
306
+ notification.classList.add('translate-x-full');
307
+ setTimeout(() => notification.remove(), 300);
308
+ }, 5000);
309
+ }
310
+
311
+ // Error handling
312
+ window.addEventListener('error', function(e) {
313
+ console.error('Application error:', e.error);
314
+ showNotification('An error occurred. Please refresh the page.', 'error');
315
+ });
316
+
317
+ // Performance monitoring
318
+ if ('performance' in window) {
319
+ window.addEventListener('load', function() {
320
+ const timing = performance.timing;
321
+ const loadTime = timing.loadEventEnd - timing.navigationStart;
322
+ console.log(`Page loaded in ${loadTime}ms`);
323
+
324
+ if (loadTime > 3000) {
325
+ console.warn('Page load time exceeds 3 seconds');
326
+ }
327
+ });
328
+ }
style.css CHANGED
@@ -1,28 +1,192 @@
1
- body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
 
 
 
 
 
 
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
 
 
 
 
 
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
 
 
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ThaiRice NDVI Visualizer - Main Styles */
2
+
3
+ /* Custom Scrollbar */
4
+ ::-webkit-scrollbar {
5
+ width: 10px;
6
+ }
7
+
8
+ ::-webkit-scrollbar-track {
9
+ background: #f1f1f1;
10
+ }
11
+
12
+ ::-webkit-scrollbar-thumb {
13
+ background: #10b981;
14
+ border-radius: 5px;
15
+ }
16
+
17
+ ::-webkit-scrollbar-thumb:hover {
18
+ background: #059669;
19
+ }
20
+
21
+ /* Smooth Scrolling */
22
+ html {
23
+ scroll-behavior: smooth;
24
+ }
25
+
26
+ /* Custom Animations */
27
+ @keyframes fadeInUp {
28
+ from {
29
+ opacity: 0;
30
+ transform: translateY(20px);
31
+ }
32
+ to {
33
+ opacity: 1;
34
+ transform: translateY(0);
35
+ }
36
+ }
37
+
38
+ @keyframes pulse {
39
+ 0%, 100% {
40
+ opacity: 1;
41
+ }
42
+ 50% {
43
+ opacity: 0.7;
44
+ }
45
+ }
46
+
47
+ @keyframes gradientShift {
48
+ 0% {
49
+ background-position: 0% 50%;
50
+ }
51
+ 50% {
52
+ background-position: 100% 50%;
53
+ }
54
+ 100% {
55
+ background-position: 0% 50%;
56
+ }
57
+ }
58
+
59
+ /* Animation Classes */
60
+ .fade-in-up {
61
+ animation: fadeInUp 0.6s ease-out forwards;
62
+ }
63
+
64
+ .pulse-slow {
65
+ animation: pulse 2s infinite;
66
+ }
67
+
68
+ .gradient-shift {
69
+ background-size: 200% 200%;
70
+ animation: gradientShift 3s ease infinite;
71
  }
72
 
73
+ /* Custom Components */
74
+ .ndvi-gradient {
75
+ background: linear-gradient(90deg,
76
+ #d32f2f 0%,
77
+ #f57c00 20%,
78
+ #fbc02d 40%,
79
+ #7cb342 60%,
80
+ #388e3c 80%,
81
+ #1b5e20 100%);
82
  }
83
 
84
+ .health-indicator {
85
+ position: relative;
 
 
 
86
  }
87
 
88
+ .health-indicator::after {
89
+ content: '';
90
+ position: absolute;
91
+ top: -4px;
92
+ right: -4px;
93
+ width: 12px;
94
+ height: 12px;
95
+ border-radius: 50%;
96
+ background-color: #10b981;
97
+ border: 2px solid white;
98
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
99
  }
100
 
101
+ /* Map Controls */
102
+ .map-control {
103
+ transition: all 0.2s ease;
104
+ backdrop-filter: blur(10px);
105
  }
106
+
107
+ .map-control:hover {
108
+ transform: scale(1.05);
109
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
110
+ }
111
+
112
+ /* Card Hover Effects */
113
+ .hover-lift {
114
+ transition: all 0.3s ease;
115
+ }
116
+
117
+ .hover-lift:hover {
118
+ transform: translateY(-5px);
119
+ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
120
+ }
121
+
122
+ /* Loading States */
123
+ .loading-shimmer {
124
+ background: linear-gradient(90deg,
125
+ #f0f0f0 25%,
126
+ #e0e0e0 50%,
127
+ #f0f0f0 75%);
128
+ background-size: 200% 100%;
129
+ animation: shimmer 1.5s infinite;
130
+ }
131
+
132
+ @keyframes shimmer {
133
+ 0% {
134
+ background-position: -200% 0;
135
+ }
136
+ 100% {
137
+ background-position: 200% 0;
138
+ }
139
+ }
140
+
141
+ /* Tooltip Styles */
142
+ .tooltip {
143
+ position: fixed;
144
+ z-index: 9999;
145
+ pointer-events: none;
146
+ opacity: 0;
147
+ animation: tooltipFadeIn 0.2s ease forwards;
148
+ }
149
+
150
+ @keyframes tooltipFadeIn {
151
+ from {
152
+ opacity: 0;
153
+ transform: translateY(10px);
154
+ }
155
+ to {
156
+ opacity: 1;
157
+ transform: translateY(0);
158
+ }
159
+ }
160
+
161
+ /* Responsive Typography */
162
+ @media (max-width: 640px) {
163
+ .responsive-text {
164
+ font-size: 0.875rem;
165
+ }
166
+ }
167
+
168
+ /* Custom Borders */
169
+ .border-gradient {
170
+ border: 2px solid transparent;
171
+ background: linear-gradient(white, white) padding-box,
172
+ linear-gradient(90deg, #10b981, #059669) border-box;
173
+ }
174
+
175
+ /* Focus States */
176
+ .focus-ring:focus {
177
+ outline: none;
178
+ ring-width: 3px;
179
+ ring-color: rgba(16, 185, 129, 0.5);
180
+ ring-offset: 2px;
181
+ }
182
+
183
+ /* Print Styles */
184
+ @media print {
185
+ .no-print {
186
+ display: none !important;
187
+ }
188
+
189
+ .print-only {
190
+ display: block !important;
191
+ }
192
+ }