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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="zh-TW">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>7人共同空檔協調行事曆</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--primary-color: #4a90e2;
|
| 10 |
+
--success-color: #2ecc71;
|
| 11 |
+
--bg-color: #f4f7f6;
|
| 12 |
+
--card-bg: #ffffff;
|
| 13 |
+
--border-color: #e0e0e0;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
body {
|
| 17 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
| 18 |
+
background-color: var(--bg-color);
|
| 19 |
+
color: #333;
|
| 20 |
+
margin: 0;
|
| 21 |
+
padding: 20px;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.container {
|
| 25 |
+
max-width: 1200px;
|
| 26 |
+
margin: 0 auto;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
h1 {
|
| 30 |
+
text-align: center;
|
| 31 |
+
color: #2c3e50;
|
| 32 |
+
margin-bottom: 20px;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/* 頂部交集結果區塊 */
|
| 36 |
+
.intersection-card {
|
| 37 |
+
background-color: #e8f8f5;
|
| 38 |
+
border: 2px solid var(--success-color);
|
| 39 |
+
border-radius: 8px;
|
| 40 |
+
padding: 15px 20px;
|
| 41 |
+
margin-bottom: 25px;
|
| 42 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.intersection-card h2 {
|
| 46 |
+
margin-top: 0;
|
| 47 |
+
color: #27ae60;
|
| 48 |
+
font-size: 1.2rem;
|
| 49 |
+
display: flex;
|
| 50 |
+
align-items: center;
|
| 51 |
+
gap: 8px;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.available-tags {
|
| 55 |
+
display: flex;
|
| 56 |
+
flex-wrap: wrap;
|
| 57 |
+
gap: 10px;
|
| 58 |
+
margin-top: 10px;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.tag {
|
| 62 |
+
background-color: var(--success-color);
|
| 63 |
+
color: white;
|
| 64 |
+
padding: 6px 12px;
|
| 65 |
+
border-radius: 20px;
|
| 66 |
+
font-weight: bold;
|
| 67 |
+
font-size: 0.95rem;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.no-match {
|
| 71 |
+
color: #7f8c8d;
|
| 72 |
+
font-style: italic;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
/* 行事曆列表 */
|
| 76 |
+
.calendar-grid {
|
| 77 |
+
display: flex;
|
| 78 |
+
flex-direction: column;
|
| 79 |
+
gap: 15px;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
.date-card {
|
| 83 |
+
background: var(--card-bg);
|
| 84 |
+
border-radius: 8px;
|
| 85 |
+
border: 1px solid var(--border-color);
|
| 86 |
+
padding: 15px;
|
| 87 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.02);
|
| 88 |
+
transition: all 0.3s ease;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
.date-card.all-available {
|
| 92 |
+
border: 2px solid var(--success-color);
|
| 93 |
+
background-color: #f9fffb;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.date-header {
|
| 97 |
+
font-size: 1.1rem;
|
| 98 |
+
font-weight: bold;
|
| 99 |
+
color: #34495e;
|
| 100 |
+
margin-bottom: 12px;
|
| 101 |
+
padding-bottom: 8px;
|
| 102 |
+
border-bottom: 1px solid #eee;
|
| 103 |
+
display: flex;
|
| 104 |
+
justify-content: space-between;
|
| 105 |
+
align-items: center;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.status-badge {
|
| 109 |
+
font-size: 0.85rem;
|
| 110 |
+
padding: 3px 8px;
|
| 111 |
+
border-radius: 4px;
|
| 112 |
+
background-color: #eee;
|
| 113 |
+
color: #666;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
.date-card.all-available .status-badge {
|
| 117 |
+
background-color: var(--success-color);
|
| 118 |
+
color: white;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/* 七小欄 Grid Layout */
|
| 122 |
+
.members-grid {
|
| 123 |
+
display: grid;
|
| 124 |
+
grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
|
| 125 |
+
gap: 10px;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.member-col {
|
| 129 |
+
background: #f8f9fa;
|
| 130 |
+
border: 1px solid #e9ecef;
|
| 131 |
+
border-radius: 6px;
|
| 132 |
+
padding: 8px;
|
| 133 |
+
display: flex;
|
| 134 |
+
flex-direction: column;
|
| 135 |
+
gap: 6px;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.member-name-row {
|
| 139 |
+
display: flex;
|
| 140 |
+
align-items: center;
|
| 141 |
+
justify-content: space-between;
|
| 142 |
+
font-weight: bold;
|
| 143 |
+
color: #495057;
|
| 144 |
+
font-size: 0.95rem;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.member-col label {
|
| 148 |
+
display: flex;
|
| 149 |
+
align-items: center;
|
| 150 |
+
gap: 4px;
|
| 151 |
+
font-size: 0.8rem;
|
| 152 |
+
color: #6c757d;
|
| 153 |
+
cursor: pointer;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.member-col input[type="text"] {
|
| 157 |
+
width: 100%;
|
| 158 |
+
padding: 6px;
|
| 159 |
+
border: 1px solid #ced4da;
|
| 160 |
+
border-radius: 4px;
|
| 161 |
+
font-size: 0.85rem;
|
| 162 |
+
box-sizing: border-box;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
.member-col input[type="text"]:focus {
|
| 166 |
+
outline: none;
|
| 167 |
+
border-color: var(--primary-color);
|
| 168 |
+
box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
/* 響應式微調 */
|
| 172 |
+
@media (max-width: 768px) {
|
| 173 |
+
.members-grid {
|
| 174 |
+
grid-template-columns: repeat(2, 1fr);
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
</style>
|
| 178 |
+
|
| 179 |
+
<!-- Firebase 9 SDK (Compat 模式,方便單一檔案整合) -->
|
| 180 |
+
<script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-app-compat.js"></script>
|
| 181 |
+
<script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-database-compat.js"></script>
|
| 182 |
+
</head>
|
| 183 |
+
<body>
|
| 184 |
+
|
| 185 |
+
<div class="container">
|
| 186 |
+
<h1>📅 7人空檔時間協調行事曆 (8/14 - 9/2)</h1>
|
| 187 |
+
|
| 188 |
+
<!-- 共同有空交集區塊 -->
|
| 189 |
+
<div class="intersection-card">
|
| 190 |
+
<h2>🎉 全員皆有空的日期(交集):</h2>
|
| 191 |
+
<div id="intersection-results" class="available-tags">
|
| 192 |
+
<span class="no-match">計算中或目前尚無所有人都有空的日期...</span>
|
| 193 |
+
</div>
|
| 194 |
+
</div>
|
| 195 |
+
|
| 196 |
+
<!-- 日期清單區塊 -->
|
| 197 |
+
<div id="calendar" class="calendar-grid"></div>
|
| 198 |
+
</div>
|
| 199 |
+
|
| 200 |
+
<script>
|
| 201 |
+
// 1. 初始化 Firebase Realtime Database
|
| 202 |
+
const firebaseConfig = {
|
| 203 |
+
databaseURL: "https://bolobolobolomi-66014-default-rtdb.asia-southeast1.firebasedatabase.app/"
|
| 204 |
+
};
|
| 205 |
+
firebase.initializeApp(firebaseConfig);
|
| 206 |
+
const db = firebase.database();
|
| 207 |
+
const scheduleRef = db.ref("schedule_2026");
|
| 208 |
+
|
| 209 |
+
// 2. 設定參數
|
| 210 |
+
const members = ["桑", "吳", "張", "趙", "謝", "黃", "康"];
|
| 211 |
+
const startDate = new Date("2026-08-14");
|
| 212 |
+
const endDate = new Date("2026-09-02");
|
| 213 |
+
|
| 214 |
+
// 生成日期陣列 YYYY-MM-DD
|
| 215 |
+
const dateList = [];
|
| 216 |
+
let curr = new Date(startDate);
|
| 217 |
+
while (curr <= endDate) {
|
| 218 |
+
const year = curr.getFullYear();
|
| 219 |
+
const month = String(curr.getMonth() + 1).padStart(2, '0');
|
| 220 |
+
const day = String(curr.getDate()).padStart(2, '0');
|
| 221 |
+
const dateStr = `${year}-${month}-${day}`;
|
| 222 |
+
|
| 223 |
+
const weekDays = ["日", "一", "二", "三", "四", "五", "六"];
|
| 224 |
+
const dayOfWeek = weekDays[curr.getDay()];
|
| 225 |
+
|
| 226 |
+
dateList.push({ dateStr, displayStr: `${month}/${day} (${dayOfWeek})` });
|
| 227 |
+
curr.setDate(curr.getDate() + 1);
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
// 3. 渲染 HTML 結構
|
| 231 |
+
const calendarContainer = document.getElementById("calendar");
|
| 232 |
+
|
| 233 |
+
dateList.forEach(({ dateStr, displayStr }) => {
|
| 234 |
+
const dateCard = document.createElement("div");
|
| 235 |
+
dateCard.className = "date-card";
|
| 236 |
+
dateCard.id = `card-${dateStr}`;
|
| 237 |
+
|
| 238 |
+
let membersHTML = "";
|
| 239 |
+
members.forEach(name => {
|
| 240 |
+
membersHTML += `
|
| 241 |
+
<div class="member-col">
|
| 242 |
+
<div class="member-name-row">
|
| 243 |
+
<span>${name}</span>
|
| 244 |
+
<label>
|
| 245 |
+
<input type="checkbox" id="chk-${dateStr}-${name}" onchange="updateData('${dateStr}', '${name}')">
|
| 246 |
+
有空
|
| 247 |
+
</label>
|
| 248 |
+
</div>
|
| 249 |
+
<input type="text" id="txt-${dateStr}-${name}" placeholder="標註時間/備註..." onchange="updateData('${dateStr}', '${name}')" onkeydown="if(event.key==='Enter') this.blur()">
|
| 250 |
+
</div>
|
| 251 |
+
`;
|
| 252 |
+
});
|
| 253 |
+
|
| 254 |
+
dateCard.innerHTML = `
|
| 255 |
+
<div class="date-header">
|
| 256 |
+
<span>${displayStr}</span>
|
| 257 |
+
<span class="status-badge" id="badge-${dateStr}">填寫中</span>
|
| 258 |
+
</div>
|
| 259 |
+
<div class="members-grid">
|
| 260 |
+
${membersHTML}
|
| 261 |
+
</div>
|
| 262 |
+
`;
|
| 263 |
+
|
| 264 |
+
calendarContainer.appendChild(dateCard);
|
| 265 |
+
});
|
| 266 |
+
|
| 267 |
+
// 4. 更新 Firebase 資料
|
| 268 |
+
function updateData(dateStr, memberName) {
|
| 269 |
+
const isAvailable = document.getElementById(`chk-${dateStr}-${memberName}`).checked;
|
| 270 |
+
const textNote = document.getElementById(`txt-${dateStr}-${memberName}`).value;
|
| 271 |
+
|
| 272 |
+
scheduleRef.child(dateStr).child(memberName).set({
|
| 273 |
+
available: isAvailable,
|
| 274 |
+
note: textNote
|
| 275 |
+
});
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
// 5. 監聽 Firebase 資料庫變更並更新 UI
|
| 279 |
+
scheduleRef.on("value", (snapshot) => {
|
| 280 |
+
const data = snapshot.val() || {};
|
| 281 |
+
const fullAvailableDates = [];
|
| 282 |
+
|
| 283 |
+
dateList.forEach(({ dateStr, displayStr }) => {
|
| 284 |
+
const dateData = data[dateStr] || {};
|
| 285 |
+
let availableCount = 0;
|
| 286 |
+
|
| 287 |
+
members.forEach(name => {
|
| 288 |
+
const memberData = dateData[name] || { available: false, note: "" };
|
| 289 |
+
|
| 290 |
+
const chkEl = document.getElementById(`chk-${dateStr}-${name}`);
|
| 291 |
+
const txtEl = document.getElementById(`txt-${dateStr}-${name}`);
|
| 292 |
+
|
| 293 |
+
// 避免覆蓋正在輸入中的 input content
|
| 294 |
+
if (document.activeElement !== txtEl) {
|
| 295 |
+
txtEl.value = memberData.note || "";
|
| 296 |
+
}
|
| 297 |
+
chkEl.checked = !!memberData.available;
|
| 298 |
+
|
| 299 |
+
if (memberData.available) {
|
| 300 |
+
availableCount++;
|
| 301 |
+
}
|
| 302 |
+
});
|
| 303 |
+
|
| 304 |
+
const cardEl = document.getElementById(`card-${dateStr}`);
|
| 305 |
+
const badgeEl = document.getElementById(`badge-${dateStr}`);
|
| 306 |
+
|
| 307 |
+
// 比對交集:7 個人都勾選有空
|
| 308 |
+
if (availableCount === members.length) {
|
| 309 |
+
cardEl.classList.add("all-available");
|
| 310 |
+
badgeEl.innerText = "全員皆有空!";
|
| 311 |
+
fullAvailableDates.push(displayStr);
|
| 312 |
+
} else {
|
| 313 |
+
cardEl.classList.remove("all-available");
|
| 314 |
+
badgeEl.innerText = `有空人數:${availableCount}/${members.length}`;
|
| 315 |
+
}
|
| 316 |
+
});
|
| 317 |
+
|
| 318 |
+
// 更新頂部交集結果
|
| 319 |
+
const resultsContainer = document.getElementById("intersection-results");
|
| 320 |
+
if (fullAvailableDates.length > 0) {
|
| 321 |
+
resultsContainer.innerHTML = fullAvailableDates
|
| 322 |
+
.map(d => `<span class="tag">${d}</span>`)
|
| 323 |
+
.join("");
|
| 324 |
+
} else {
|
| 325 |
+
resultsContainer.innerHTML = `<span class="no-match">目前尚無所有人都有空的日期,大家快來勾選!</span>`;
|
| 326 |
+
}
|
| 327 |
+
});
|
| 328 |
+
</script>
|
| 329 |
+
</body>
|
| 330 |
+
</html>
|