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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fa" dir="rtl">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>سامانه اطلاعات اتوبوس</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700&display=swap" rel="stylesheet">
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/moment-jalaali@0.9.2/build/moment-jalaali.js"></script>
|
| 10 |
+
<style>
|
| 11 |
+
body {
|
| 12 |
+
font-family: 'Vazirmatn', sans-serif;
|
| 13 |
+
background: linear-gradient(45deg, #3490dc, #6574cd, #9561e2, #f66d9b);
|
| 14 |
+
background-size: 400% 400%;
|
| 15 |
+
animation: gradientBG 15s ease infinite;
|
| 16 |
+
}
|
| 17 |
+
@keyframes gradientBG {
|
| 18 |
+
0% { background-position: 0% 50%; }
|
| 19 |
+
50% { background-position: 100% 50%; }
|
| 20 |
+
100% { background-position: 0% 50%; }
|
| 21 |
+
}
|
| 22 |
+
.glass {
|
| 23 |
+
background: rgba(255, 255, 255, 0.25);
|
| 24 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
| 25 |
+
backdrop-filter: blur(4px);
|
| 26 |
+
-webkit-backdrop-filter: blur(4px);
|
| 27 |
+
border-radius: 10px;
|
| 28 |
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
| 29 |
+
}
|
| 30 |
+
.loading {
|
| 31 |
+
width: 50px;
|
| 32 |
+
height: 50px;
|
| 33 |
+
border: 5px solid #f3f3f3;
|
| 34 |
+
border-top: 5px solid #3498db;
|
| 35 |
+
border-radius: 50%;
|
| 36 |
+
animation: spin 1s linear infinite;
|
| 37 |
+
}
|
| 38 |
+
@keyframes spin {
|
| 39 |
+
0% { transform: rotate(0deg); }
|
| 40 |
+
100% { transform: rotate(360deg); }
|
| 41 |
+
}
|
| 42 |
+
.bus-icon {
|
| 43 |
+
animation: drive 5s linear infinite;
|
| 44 |
+
}
|
| 45 |
+
@keyframes drive {
|
| 46 |
+
0% { transform: translateX(-100%); }
|
| 47 |
+
100% { transform: translateX(100%); }
|
| 48 |
+
}
|
| 49 |
+
</style>
|
| 50 |
+
</head>
|
| 51 |
+
<body class="min-h-screen flex flex-col">
|
| 52 |
+
<header class="glass text-white p-4 mb-8">
|
| 53 |
+
<div class="container mx-auto flex justify-between items-center">
|
| 54 |
+
<h1 class="text-2xl font-bold">سامانه اطلاعات اتوبوس</h1>
|
| 55 |
+
<div id="clock" class="text-xl font-semibold"></div>
|
| 56 |
+
</div>
|
| 57 |
+
</header>
|
| 58 |
+
|
| 59 |
+
<main class="flex-grow container mx-auto px-4 py-8">
|
| 60 |
+
<div class="glass p-6 mb-8 max-w-3xl mx-auto">
|
| 61 |
+
<form id="search-form" class="mb-4">
|
| 62 |
+
<div class="flex flex-col sm:flex-row">
|
| 63 |
+
<input type="text" id="station-id" class="flex-grow px-4 py-2 rounded-lg sm:rounded-l-none border-2 border-blue-500 focus:outline-none focus:border-blue-600 mb-2 sm:mb-0" placeholder="کد ایستگاه را وارد کنید" required>
|
| 64 |
+
<button type="submit" class="px-6 py-2 bg-blue-500 text-white rounded-lg sm:rounded-r-lg hover:bg-blue-600 transition-colors duration-200">جستجو</button>
|
| 65 |
+
</div>
|
| 66 |
+
</form>
|
| 67 |
+
<div id="error" class="text-red-500"></div>
|
| 68 |
+
<div class="relative overflow-hidden h-8">
|
| 69 |
+
<svg class="bus-icon h-8 w-8 text-blue-500 absolute" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 70 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7v8a2 2 0 002 2h6M8 7V5a2 2 0 012-2h4a2 2 0 012 2v2M8 7H6a2 2 0 00-2 2v9a2 2 0 002 2h12a2 2 0 002-2V9a2 2 0 00-2-2h-2M9 7h6" />
|
| 71 |
+
</svg>
|
| 72 |
+
</div>
|
| 73 |
+
</div>
|
| 74 |
+
|
| 75 |
+
<div id="loading" class="hidden flex justify-center items-center mb-4">
|
| 76 |
+
<div class="loading"></div>
|
| 77 |
+
</div>
|
| 78 |
+
|
| 79 |
+
<div id="result" class="glass p-6 max-w-3xl mx-auto"></div>
|
| 80 |
+
</main>
|
| 81 |
+
|
| 82 |
+
<footer class="glass text-white p-4 mt-8">
|
| 83 |
+
<div class="container mx-auto text-center">
|
| 84 |
+
<p>© ۱۴۰۳ سامانه اطلاعات اتوبوس. تمامی حقوق محفوظ است.</p>
|
| 85 |
+
</div>
|
| 86 |
+
</footer>
|
| 87 |
+
|
| 88 |
+
<script>
|
| 89 |
+
const form = document.getElementById('search-form');
|
| 90 |
+
const stationIdInput = document.getElementById('station-id');
|
| 91 |
+
const errorDiv = document.getElementById('error');
|
| 92 |
+
const resultDiv = document.getElementById('result');
|
| 93 |
+
const loadingDiv = document.getElementById('loading');
|
| 94 |
+
const clockDiv = document.getElementById('clock');
|
| 95 |
+
|
| 96 |
+
form.addEventListener('submit', async (e) => {
|
| 97 |
+
e.preventDefault();
|
| 98 |
+
const stationId = stationIdInput.value.trim();
|
| 99 |
+
|
| 100 |
+
if (!stationId) {
|
| 101 |
+
showError('لطفاً کد ایستگاه را وارد کنید.');
|
| 102 |
+
return;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
try {
|
| 106 |
+
showLoading();
|
| 107 |
+
const data = await fetchStationData(stationId);
|
| 108 |
+
hideLoading();
|
| 109 |
+
showResult(data);
|
| 110 |
+
} catch (error) {
|
| 111 |
+
hideLoading();
|
| 112 |
+
showError('خطایی در دریافت اطلاعات رخ داد. لطفاً دوباره تلاش کنید.');
|
| 113 |
+
}
|
| 114 |
+
});
|
| 115 |
+
|
| 116 |
+
function showError(message) {
|
| 117 |
+
errorDiv.textContent = message;
|
| 118 |
+
resultDiv.innerHTML = '';
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
function showLoading() {
|
| 122 |
+
loadingDiv.classList.remove('hidden');
|
| 123 |
+
resultDiv.innerHTML = '';
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
function hideLoading() {
|
| 127 |
+
loadingDiv.classList.add('hidden');
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
function showResult(data) {
|
| 131 |
+
errorDiv.textContent = '';
|
| 132 |
+
let html = '<h2 class="text-xl font-semibold mb-4">اطلاعات ایستگاه</h2>';
|
| 133 |
+
html += '<div class="overflow-x-auto"><table class="w-full table-auto">';
|
| 134 |
+
html += '<thead><tr class="bg-blue-100"><th class="px-4 py-2">مسیر</th><th class="px-4 py-2">اطلاعات</th></tr></thead><tbody>';
|
| 135 |
+
|
| 136 |
+
data.forEach((item, index) => {
|
| 137 |
+
html += `<tr class="${index % 2 === 0 ? 'bg-white' : 'bg-blue-50'}">`;
|
| 138 |
+
html += `<td class="border px-4 py-2 font-semibold">مسیر ${item.route_code}</td>`;
|
| 139 |
+
html += `<td class="border px-4 py-2">
|
| 140 |
+
<p><span class="font-medium">زمان تقریبی رسیدن:</span> ${item.eta}</p>
|
| 141 |
+
<p><span class="font-medium">مقصد:</span> ${item.destination_name}</p>
|
| 142 |
+
<p><span class="font-medium">اتوبوس:</span> ${item.bus}</p>
|
| 143 |
+
<p><span class="font-medium">نوع:</span> ${item.route_type}</p>
|
| 144 |
+
</td>`;
|
| 145 |
+
html += '</tr>';
|
| 146 |
+
});
|
| 147 |
+
|
| 148 |
+
html += '</tbody></table></div>';
|
| 149 |
+
resultDiv.innerHTML = html;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
function updateClock() {
|
| 153 |
+
const now = moment();
|
| 154 |
+
const jalaliDate = now.format('jYYYY/jMM/jDD');
|
| 155 |
+
const time = now.format('HH:mm:ss');
|
| 156 |
+
clockDiv.textContent = `${jalaliDate} ${time}`;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
setInterval(updateClock, 1000);
|
| 160 |
+
updateClock();
|
| 161 |
+
|
| 162 |
+
async function fetchStationData(stationId) {
|
| 163 |
+
const response = await fetch(`http://server1.ththt.ir:9204/api/update_eta/${stationId}`);
|
| 164 |
+
if (!response.ok) {
|
| 165 |
+
throw new Error('Network response was not ok');
|
| 166 |
+
}
|
| 167 |
+
return await response.json();
|
| 168 |
+
}
|
| 169 |
+
</script>
|
| 170 |
+
</body>
|
| 171 |
+
</html>
|