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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="my">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>မြန်မာမြို့များ ရှာဖွေရေးစနစ်</title>
|
| 7 |
+
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
| 8 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.0/css/all.min.css">
|
| 9 |
+
<link href="https://fonts.googleapis.com/css2?family=Padauk:wght@400;700&display=swap" rel="stylesheet">
|
| 10 |
+
<style>
|
| 11 |
+
:root {
|
| 12 |
+
--primary-color: #8B4513; /* မြန်မာ့ရိုးရာ သစ်သားအရောင် */
|
| 13 |
+
--secondary-color: #FFD700; /* ရွှေရောင် */
|
| 14 |
+
--accent-color: #006400; /* အဝါရောင် */
|
| 15 |
+
--light-bg: #FFF8DC; /* နုရောင် */
|
| 16 |
+
--dark-text: #4A4A4A; /* ကာလာမီးသွေးရောင် */
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
body {
|
| 20 |
+
font-family: 'Padauk', 'Myanmar Text', sans-serif;
|
| 21 |
+
background-color: var(--light-bg);
|
| 22 |
+
color: var(--dark-text);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
.header-bg {
|
| 26 |
+
background-image: url('https://media.istockphoto.com/id/506266414/photo/shwedagon-pagoda-in-yangon-city-myanmar.jpg?s=612x612&w=0&k=20&c=SgArPmR0cLjRUJmqYIGgItn79Ti5r7VWjtSuM-0Jf1I=');
|
| 27 |
+
background-size: cover;
|
| 28 |
+
background-position: center;
|
| 29 |
+
position: relative;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
.header-overlay {
|
| 33 |
+
background-color: rgba(0, 0, 0, 0.5);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.search-container {
|
| 37 |
+
background-color: white;
|
| 38 |
+
border: 2px solid var(--primary-color);
|
| 39 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.search-results {
|
| 43 |
+
max-height: 300px;
|
| 44 |
+
overflow-y: auto;
|
| 45 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.region-card {
|
| 49 |
+
border-left: 4px solid var(--primary-color);
|
| 50 |
+
transition: all 0.3s ease;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.region-card:hover {
|
| 54 |
+
border-left-width: 8px;
|
| 55 |
+
background-color: rgba(139, 69, 19, 0.05);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.city-item {
|
| 59 |
+
border-left: 2px solid var(--secondary-color);
|
| 60 |
+
transition: all 0.3s ease;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
.city-item:hover {
|
| 64 |
+
background-color: rgba(255, 215, 0, 0.2);
|
| 65 |
+
border-left-width: 4px;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.btn-primary {
|
| 69 |
+
background-color: var(--primary-color);
|
| 70 |
+
border-color: var(--primary-color);
|
| 71 |
+
color: white;
|
| 72 |
+
transition: all 0.3s ease;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.btn-primary:hover {
|
| 76 |
+
background-color: #6b340f;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.btn-secondary {
|
| 80 |
+
background-color: var(--secondary-color);
|
| 81 |
+
border-color: var(--secondary-color);
|
| 82 |
+
color: var(--dark-text);
|
| 83 |
+
transition: all 0.3s ease;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
.btn-secondary:hover {
|
| 87 |
+
background-color: #e6c200;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.loading {
|
| 91 |
+
animation: spin 1s infinite linear;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
@keyframes spin {
|
| 95 |
+
from { transform: rotate(0deg); }
|
| 96 |
+
to { transform: rotate(360deg); }
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.badge {
|
| 100 |
+
background-color: var(--primary-color);
|
| 101 |
+
color: white;
|
| 102 |
+
font-size: 0.8rem;
|
| 103 |
+
padding: 3px 8px;
|
| 104 |
+
border-radius: 9999px;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
.myanmar-pattern {
|
| 108 |
+
background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%238b4513' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
@media (max-width: 640px) {
|
| 112 |
+
.search-box {
|
| 113 |
+
width: 100%;
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
</style>
|
| 117 |
+
</head>
|
| 118 |
+
<body class="myanmar-pattern">
|
| 119 |
+
<!-- Header Section -->
|
| 120 |
+
<header class="header-bg w-full">
|
| 121 |
+
<div class="header-overlay py-12 px-4 sm:px-6 lg:px-8 text-center">
|
| 122 |
+
<h1 class="text-4xl sm:text-5xl font-bold text-white shadow-text mb-4">မြန်မာမြို့များ ရှာဖွေရေးစနစ်</h1>
|
| 123 |
+
<p class="text-xl text-gray-200 mb-8">တိုင်းဒေသကြီးနှင့် ပြည်နယ်အသီးသီးမှ မြို့များ</p>
|
| 124 |
+
|
| 125 |
+
<!-- Search Box -->
|
| 126 |
+
<div class="max-w-xl mx-auto relative">
|
| 127 |
+
<div class="search-container flex items-center rounded-lg overflow-hidden">
|
| 128 |
+
<input
|
| 129 |
+
type="text"
|
| 130 |
+
id="search-input"
|
| 131 |
+
class="py-3 px-4 w-full focus:outline-none"
|
| 132 |
+
placeholder="မြို့အမည်ဖြင့် ရှာဖွေရန်..."
|
| 133 |
+
/>
|
| 134 |
+
<button id="search-button" class="btn-primary p-3">
|
| 135 |
+
<i class="fas fa-search"></i>
|
| 136 |
+
</button>
|
| 137 |
+
</div>
|
| 138 |
+
<div id="search-results-container" class="search-results absolute w-full bg-white rounded-b-lg hidden z-10"></div>
|
| 139 |
+
</div>
|
| 140 |
+
</div>
|
| 141 |
+
</header>
|
| 142 |
+
|
| 143 |
+
<!-- Main Content -->
|
| 144 |
+
<main class="container mx-auto py-8 px-4">
|
| 145 |
+
<div class="flex flex-col sm:flex-row gap-6">
|
| 146 |
+
<!-- Regions List -->
|
| 147 |
+
<div class="w-full sm:w-1/4">
|
| 148 |
+
<div class="bg-white rounded-lg shadow-md p-4 mb-6">
|
| 149 |
+
<h2 class="text-xl font-bold mb-4 text-center">တိုင်းဒေသကြီး/ပြည်နယ်များ</h2>
|
| 150 |
+
<div id="regions-list" class="space-y-2">
|
| 151 |
+
<!-- Regions will be loaded here -->
|
| 152 |
+
<div class="animate-pulse">
|
| 153 |
+
<div class="h-8 bg-gray-200 rounded w-full mb-2"></div>
|
| 154 |
+
<div class="h-8 bg-gray-200 rounded w-full mb-2"></div>
|
| 155 |
+
<div class="h-8 bg-gray-200 rounded w-full mb-2"></div>
|
| 156 |
+
</div>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
|
| 161 |
+
<!-- Cities Display -->
|
| 162 |
+
<div class="w-full sm:w-3/4">
|
| 163 |
+
<div class="bg-white rounded-lg shadow-md p-4">
|
| 164 |
+
<div class="flex justify-between items-center mb-4">
|
| 165 |
+
<h2 class="text-xl font-bold" id="region-title">မြို့များစာရင်း</h2>
|
| 166 |
+
<span class="badge" id="cities-count">0 မြို့</span>
|
| 167 |
+
</div>
|
| 168 |
+
<div id="cities-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
|
| 169 |
+
<!-- Cities will be loaded here -->
|
| 170 |
+
<div class="animate-pulse">
|
| 171 |
+
<div class="h-10 bg-gray-200 rounded w-full mb-2"></div>
|
| 172 |
+
<div class="h-10 bg-gray-200 rounded w-full mb-2"></div>
|
| 173 |
+
<div class="h-10 bg-gray-200 rounded w-full mb-2"></div>
|
| 174 |
+
</div>
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
+
</div>
|
| 179 |
+
</main>
|
| 180 |
+
|
| 181 |
+
<!-- Footer -->
|
| 182 |
+
<footer class="bg-gray-800 text-white py-6 px-4">
|
| 183 |
+
<div class="container mx-auto text-center">
|
| 184 |
+
<p>မြန်မာမြို့များ ရှာဖွေရေးစနစ် © ၂၀၂၄</p>
|
| 185 |
+
<p class="text-sm text-gray-400 mt-2">Firebase Database နှင့် ချိတ်ဆက်ထားပါသည်</p>
|
| 186 |
+
</div>
|
| 187 |
+
</footer>
|
| 188 |
+
|
| 189 |
+
<!-- Firebase SDKs -->
|
| 190 |
+
<script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-app-compat.js"></script>
|
| 191 |
+
<script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-database-compat.js"></script>
|
| 192 |
+
|
| 193 |
+
<script>
|
| 194 |
+
// Firebase configuration
|
| 195 |
+
const firebaseConfig = {
|
| 196 |
+
apiKey: "AIzaSyB49vRPX8YaWuTP5GS3lsBDqdAaz_hJYAw",
|
| 197 |
+
authDomain: "onlineshop-849c8.firebaseapp.com",
|
| 198 |
+
databaseURL: "https://onlineshop-849c8.firebaseio.com",
|
| 199 |
+
projectId: "onlineshop-849c8",
|
| 200 |
+
storageBucket: "onlineshop-849c8.appspot.com",
|
| 201 |
+
messagingSenderId: "883512833370",
|
| 202 |
+
appId: "1:883512833370:web:a1c8412b158f8744afef63"
|
| 203 |
+
};
|
| 204 |
+
|
| 205 |
+
// Initialize Firebase
|
| 206 |
+
const app = firebase.initializeApp(firebaseConfig);
|
| 207 |
+
const database = firebase.database();
|
| 208 |
+
|
| 209 |
+
// Myanmar regional data (hardcoded in case Firebase connection fails)
|
| 210 |
+
const myanmarData = {
|
| 211 |
+
"မန္တလေးတိုင်း": [
|
| 212 |
+
"မန္တလေး", "ရမည်းသင်း", "ပျော်ဘွယ်", "သာစည်", "ကျောက်ဆည်",
|
| 213 |
+
"ကျောက်ပန်းတောင်း", "မိတ္ထီလာ", "သဲတော", "ဝမ်းတွင်း", "ပြင်ဦးလွင်",
|
| 214 |
+
"ပုဂံ", "ညောင်ဦး", "မလှိုင်", "စဉ့်ကိုင်", "ကူမဲ",
|
| 215 |
+
"နွားထိုးကြီး", "မြင်းခြံ", "မတ္ထရာ", "မိုးညို", "အုတ်ဖို",
|
| 216 |
+
"သဲကုန်း", "ဆင်ပေါင်"
|
| 217 |
+
],
|
| 218 |
+
"ပဲခူးတိုင်း": [
|
| 219 |
+
"ပဲခူး", "တောင်ငူ", "ကြို့ပင်ကောက်", "သာယာဝတီ", "သုံးဆယ်",
|
| 220 |
+
"လက်ပံတန်��", "ပြည်", "ပေါင်းတည်", "နတ်လင်း", "ဒိုက်ဦး",
|
| 221 |
+
"အောက်မင်းလှ", "အထက်မင်းလှ", "ရွှေတောင်", "ဝေါ", "ရေနီ",
|
| 222 |
+
"ဇီးကုန်း", "အုတ်တွင်း", "ရေတာရှည်", "ဆိပ်ဖြူ", "ရေစကြို", ဖြူး,
|
| 223 |
+
"ပခုက္ကူ"
|
| 224 |
+
],
|
| 225 |
+
"ဧရာဝတီတိုင်း": [
|
| 226 |
+
"ပုသိမ်", "ဟသ္ဂာတ", "မြောင်းမြ", "ပန်းတနော်", "ဇလွန်",
|
| 227 |
+
"ကျုံပျော်", "ရွှေကြည်", "ငါးသိုင်းချောင်း", "မအူပင်", "ဖျာပုံ",
|
| 228 |
+
"ဝါးခယ်မ", "ဘိုကလေး", "လပွတ္တာ", "ကြံခင်း", "မြန်အောင်",
|
| 229 |
+
"ငဖဲ", "စကု", "စလေ"
|
| 230 |
+
],
|
| 231 |
+
"မကွေးတိုင်း": [
|
| 232 |
+
"သာပေါင်း", "ချောင်းသာ", "ကျောင်းကုန်း", "ညောင်တုန်း", "ဓနုဖြူ",
|
| 233 |
+
"အိမ်မဲ", "အထောင်", "ဒေးဒရဲ", "အဂ္ဂပူ", "ကျုံမငေး",
|
| 234 |
+
"ထူးကြီး", "အသုတ်", "ဆားမလောက်", "ရွှေလောင်", "ဒါးက"
|
| 235 |
+
],
|
| 236 |
+
"နေပြည်တော်": [
|
| 237 |
+
"မကွေး", "ချောက်", "မင်းဘူး", "အောင်လံ", "သရက်",
|
| 238 |
+
"တောင်တွင်းကြီး", "ရေနံချောင်း", "ဆက်သွား", "ဂွေးချို", "ပွင့်ဖြူ",
|
| 239 |
+
"နတ်မောက်", "စလင်း", "ဆင်ဖြူကျွန်း", "မြို့သစ်", "ကံမ"
|
| 240 |
+
],
|
| 241 |
+
"ရှမ်းပြည်နယ်": [
|
| 242 |
+
"တပ်ကုန်း", "ဘောဂသီရိ", "ပျဥ်းမနား", "လယ်ဝေး", "အောင်ပန်း",
|
| 243 |
+
"ဟဲဟိုး", "ညောင်ရွှေ", "လွိုင်လင်", "ပင်းတယ", "ပင်လောင်း",
|
| 244 |
+
"လားရှိုး", "နောင်ချို"
|
| 245 |
+
]
|
| 246 |
+
};
|
| 247 |
+
|
| 248 |
+
// DOM elements
|
| 249 |
+
const searchInput = document.getElementById('search-input');
|
| 250 |
+
const searchButton = document.getElementById('search-button');
|
| 251 |
+
const searchResultsContainer = document.getElementById('search-results-container');
|
| 252 |
+
const regionsList = document.getElementById('regions-list');
|
| 253 |
+
const citiesContainer = document.getElementById('cities-container');
|
| 254 |
+
const regionTitle = document.getElementById('region-title');
|
| 255 |
+
const citiesCount = document.getElementById('cities-count');
|
| 256 |
+
|
| 257 |
+
// Load data and initialize app
|
| 258 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 259 |
+
initializeApp();
|
| 260 |
+
});
|
| 261 |
+
|
| 262 |
+
// Initialize the application
|
| 263 |
+
function initializeApp() {
|
| 264 |
+
loadRegions();
|
| 265 |
+
setupSearchFunctionality();
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
// Load regions from Firebase or fallback to hardcoded data
|
| 269 |
+
function loadRegions() {
|
| 270 |
+
try {
|
| 271 |
+
database.ref('/regions').once('value')
|
| 272 |
+
.then(snapshot => {
|
| 273 |
+
const data = snapshot.val() || myanmarData;
|
| 274 |
+
renderRegions(data);
|
| 275 |
+
})
|
| 276 |
+
.catch(error => {
|
| 277 |
+
console.error("Firebase data fetch error:", error);
|
| 278 |
+
renderRegions(myanmarData);
|
| 279 |
+
});
|
| 280 |
+
} catch (error) {
|
| 281 |
+
console.error("Firebase error:", error);
|
| 282 |
+
renderRegions(myanmarData);
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
// Render the regions in the sidebar
|
| 287 |
+
function renderRegions(data) {
|
| 288 |
+
regionsList.innerHTML = '';
|
| 289 |
+
|
| 290 |
+
Object.keys(data).forEach(region => {
|
| 291 |
+
const regionDiv = document.createElement('div');
|
| 292 |
+
regionDiv.className = 'region-card p-3 mb-2 rounded bg-white cursor-pointer hover:shadow';
|
| 293 |
+
regionDiv.innerHTML = `
|
| 294 |
+
<div class="flex justify-between items-center">
|
| 295 |
+
<span class="font-medium">${region}</span>
|
| 296 |
+
<span class="text-sm text-gray-500">${data[region].length} မြို့</span>
|
| 297 |
+
</div>
|
| 298 |
+
`;
|
| 299 |
+
|
| 300 |
+
regionDiv.addEventListener('click', () => {
|
| 301 |
+
loadCitiesByRegion(region, data[region]);
|
| 302 |
+
});
|
| 303 |
+
|
| 304 |
+
regionsList.appendChild(regionDiv);
|
| 305 |
+
});
|
| 306 |
+
|
| 307 |
+
// Load the first region by default
|
| 308 |
+
const firstRegion = Object.keys(data)[0];
|
| 309 |
+
loadCitiesByRegion(firstRegion, data[firstRegion]);
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
// Load cities for a specific region
|
| 313 |
+
function loadCitiesByRegion(region, cities) {
|
| 314 |
+
regionTitle.textContent = `${region} မြို့များစာရင်း`;
|
| 315 |
+
citiesCount.textContent = `${cities.length} မြို့`;
|
| 316 |
+
|
| 317 |
+
citiesContainer.innerHTML = '';
|
| 318 |
+
cities.forEach(city => {
|
| 319 |
+
const cityDiv = document.createElement('div');
|
| 320 |
+
cityDiv.className = 'city-item p-3 bg-white rounded hover:shadow';
|
| 321 |
+
cityDiv.innerHTML = `
|
| 322 |
+
<div class="flex items-center">
|
| 323 |
+
<i class="fas fa-city text-yellow-600 mr-2"></i>
|
| 324 |
+
<span>${city}</span>
|
| 325 |
+
</div>
|
| 326 |
+
`;
|
| 327 |
+
citiesContainer.appendChild(cityDiv);
|
| 328 |
+
});
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
// Set up search functionality
|
| 332 |
+
function setupSearchFunctionality() {
|
| 333 |
+
// Search input event listener
|
| 334 |
+
searchInput.addEventListener('input', handleSearch);
|
| 335 |
+
|
| 336 |
+
// Search button click
|
| 337 |
+
searchButton.addEventListener('click', handleSearch);
|
| 338 |
+
|
| 339 |
+
// Close search results when clicking outside
|
| 340 |
+
document.addEventListener('click', function(e) {
|
| 341 |
+
if (!searchInput.contains(e.target) && !searchResultsContainer.contains(e.target)) {
|
| 342 |
+
searchResultsContainer.classList.add('hidden');
|
| 343 |
+
}
|
| 344 |
+
});
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
// Handle search input
|
| 348 |
+
function handleSearch() {
|
| 349 |
+
const searchText = searchInput.value.trim();
|
| 350 |
+
|
| 351 |
+
if (searchText.length < 1) {
|
| 352 |
+
searchResultsContainer.classList.add('hidden');
|
| 353 |
+
return;
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
// Search in all regions
|
| 357 |
+
const results = searchCities(searchText);
|
| 358 |
+
renderSearchResults(results);
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
// Search for cities in all regions
|
| 362 |
+
function searchCities(searchText) {
|
| 363 |
+
const results = [];
|
| 364 |
+
const searchLower = searchText.toLowerCase();
|
| 365 |
+
|
| 366 |
+
try {
|
| 367 |
+
// Try to search in Firebase data
|
| 368 |
+
database.ref('/regions').once('value')
|
| 369 |
+
.then(snapshot => {
|
| 370 |
+
const data = snapshot.val() || myanmarData;
|
| 371 |
+
performSearch(data);
|
| 372 |
+
})
|
| 373 |
+
.catch(error => {
|
| 374 |
+
console.error("Firebase search error:", error);
|
| 375 |
+
performSearch(myanmarData);
|
| 376 |
+
});
|
| 377 |
+
} catch (error) {
|
| 378 |
+
console.error("Firebase error during search:", error);
|
| 379 |
+
performSearch(myanmarData);
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
// Perform the actual search
|
| 383 |
+
function performSearch(data) {
|
| 384 |
+
Object.keys(data).forEach(region => {
|
| 385 |
+
data[region].forEach(city => {
|
| 386 |
+
if (city.toLowerCase().includes(searchLower)) {
|
| 387 |
+
results.push({ city, region });
|
| 388 |
+
}
|
| 389 |
+
});
|
| 390 |
+
});
|
| 391 |
+
|
| 392 |
+
renderSearchResults(results);
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
// For initial rendering, use hardcoded data
|
| 396 |
+
Object.keys(myanmarData).forEach(region => {
|
| 397 |
+
myanmarData[region].forEach(city => {
|
| 398 |
+
if (city.toLowerCase().includes(searchLower)) {
|
| 399 |
+
results.push({ city, region });
|
| 400 |
+
}
|
| 401 |
+
});
|
| 402 |
+
});
|
| 403 |
+
|
| 404 |
+
return results;
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
// Render search results
|
| 408 |
+
function renderSearchResults(results) {
|
| 409 |
+
if (results.length === 0) {
|
| 410 |
+
searchResultsContainer.innerHTML = `
|
| 411 |
+
<div class="p-3 text-center text-gray-500">
|
| 412 |
+
<i class="fas fa-search mr-2"></i>
|
| 413 |
+
ရှာဖွေတွေ့ရှိမှု မရှိပါ
|
| 414 |
+
</div>
|
| 415 |
+
`;
|
| 416 |
+
} else {
|
| 417 |
+
searchResultsContainer.innerHTML = '';
|
| 418 |
+
|
| 419 |
+
results.forEach(result => {
|
| 420 |
+
const resultDiv = document.createElement('div');
|
| 421 |
+
resultDiv.className = 'p-3 hover:bg-gray-100 cursor-pointer border-b border-gray-100';
|
| 422 |
+
resultDiv.innerHTML = `
|
| 423 |
+
<div class="font-medium">${result.city}</div>
|
| 424 |
+
<div class="text-sm text-gray-500">${result.region}</div>
|
| 425 |
+
`;
|
| 426 |
+
|
| 427 |
+
resultDiv.addEventListener('click', () => {
|
| 428 |
+
// Load the associated region and city
|
| 429 |
+
try {
|
| 430 |
+
database.ref('/regions').once('value')
|
| 431 |
+
.then(snapshot => {
|
| 432 |
+
const data = snapshot.val() || myanmarData;
|
| 433 |
+
loadCitiesByRegion(result.region, data[result.region]);
|
| 434 |
+
searchResultsContainer.classList.add('hidden');
|
| 435 |
+
})
|
| 436 |
+
.catch(error => {
|
| 437 |
+
console.error("Error loading city region:", error);
|
| 438 |
+
loadCitiesByRegion(result.region, myanmarData[result.region]);
|
| 439 |
+
searchResultsContainer.classList.add('hidden');
|
| 440 |
+
});
|
| 441 |
+
} catch (error) {
|
| 442 |
+
console.error("Firebase error when clicking result:", error);
|
| 443 |
+
loadCitiesByRegion(result.region, myanmarData[result.region]);
|
| 444 |
+
searchResultsContainer.classList.add('hidden');
|
| 445 |
+
}
|
| 446 |
+
});
|
| 447 |
+
|
| 448 |
+
searchResultsContainer.appendChild(resultDiv);
|
| 449 |
+
});
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
searchResultsContainer.classList.remove('hidden');
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
// Handle loading errors
|
| 456 |
+
window.addEventListener('error', function(e) {
|
| 457 |
+
console.error('Error loading resource:', e.target.src || e.target.href);
|
| 458 |
+
});
|
| 459 |
+
</script>
|
| 460 |
+
</body>
|
| 461 |
+
</html>
|