Lashtw commited on
Commit
3825049
·
verified ·
1 Parent(s): acf954f

Upload index.html

Browse files
Files changed (1) hide show
  1. index.html +96 -14
index.html CHANGED
@@ -568,27 +568,45 @@
568
  const firstSheet = workbook.Sheets[workbook.SheetNames[0]];
569
  const rows = XLSX.utils.sheet_to_json(firstSheet);
570
 
571
- let newImports = [];
 
 
572
  for(let row of rows) {
573
  if (row['姓名'] && row['圓周率中的位置']) {
574
- newImports.push({
575
- name: String(row['姓名']).trim(),
576
- paddedNumber: String(row['所選號碼'] || ''),
577
- number: String(row['所選號碼'] || ''),
578
- resultVal: Number(row['圓周率中的位置']),
579
- year: Number(row['參加年度'] || new Date().getFullYear()),
580
- isNew: false // 預設歷史匯入為 false,刷新後才會有 NEW (若打破紀錄)
581
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
582
  }
583
  }
584
 
585
- if(newImports.length > 0) {
586
- // 合併或是取代? 這裡選擇完全導入但不清除既有,交給 rank 排名
587
- hallOfFame = hallOfFame.concat(newImports);
588
  renderHallOfFame();
589
- alert(`成功匯入 ${newImports.length} 筆名人堂資料`);
590
  } else {
591
- alert("檔案格式可能有誤未能成功讀取任何名人資料。");
592
  }
593
  }
594
  reader.readAsArrayBuffer(file);
@@ -1289,5 +1307,69 @@
1289
  });
1290
  }
1291
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1292
  </body>
1293
  </html>
 
568
  const firstSheet = workbook.Sheets[workbook.SheetNames[0]];
569
  const rows = XLSX.utils.sheet_to_json(firstSheet);
570
 
571
+ let newCount = 0;
572
+ let updateCount = 0;
573
+
574
  for(let row of rows) {
575
  if (row['姓名'] && row['圓周率中的位置']) {
576
+ const cleanName = String(row['姓名']).trim();
577
+ const numStr = String(row['所選號碼'] || '');
578
+ const resultV = Number(row['圓周率中的位置']);
579
+ const yearV = Number(row['參加年度'] || new Date().getFullYear());
580
+
581
+ const existIdx = hallOfFame.findIndex(h => h.name === cleanName && h.year === yearV);
582
+
583
+ if (existIdx > -1) {
584
+ // 若已存在,且有更高的分數則更新
585
+ if (resultV > hallOfFame[existIdx].resultVal) {
586
+ hallOfFame[existIdx].resultVal = resultV;
587
+ hallOfFame[existIdx].paddedNumber = numStr;
588
+ hallOfFame[existIdx].number = numStr;
589
+ updateCount++;
590
+ }
591
+ } else {
592
+ hallOfFame.push({
593
+ name: cleanName,
594
+ paddedNumber: numStr,
595
+ number: numStr,
596
+ resultVal: resultV,
597
+ year: yearV,
598
+ isNew: false
599
+ });
600
+ newCount++;
601
+ }
602
  }
603
  }
604
 
605
+ if (newCount > 0 || updateCount > 0) {
 
 
606
  renderHallOfFame();
607
+ alert(`成功匯入榜單!(新增 ${newCount} 筆,更新 ${updateCount} 筆資料)`);
608
  } else {
609
+ alert("檔案皆為重複資料,或格式可能有誤未能讀取。");
610
  }
611
  }
612
  reader.readAsArrayBuffer(file);
 
1307
  });
1308
  }
1309
  </script>
1310
+
1311
+ <!-- 頁尾宣告資訊區 -->
1312
+ <style>
1313
+ .footer-credit {
1314
+ position: fixed;
1315
+ bottom: 20px;
1316
+ right: 20px;
1317
+ text-align: right;
1318
+ color: rgba(253, 246, 227, 0.8);
1319
+ font-size: 0.9rem;
1320
+ z-index: 1000;
1321
+ background: rgba(10, 10, 10, 0.5);
1322
+ backdrop-filter: blur(8px);
1323
+ padding: 1rem 1.25rem;
1324
+ border-radius: 1rem;
1325
+ border: 1px solid rgba(255, 255, 255, 0.1);
1326
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
1327
+ transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
1328
+ }
1329
+ .footer-credit:hover {
1330
+ background: rgba(30, 25, 15, 0.75);
1331
+ border-color: rgba(252, 211, 77, 0.3);
1332
+ transform: translateY(-3px);
1333
+ box-shadow: 0 15px 25px -5px rgba(0, 0, 0, 0.6);
1334
+ }
1335
+ .footer-link {
1336
+ color: #fcd34d;
1337
+ text-decoration: none;
1338
+ font-weight: bold;
1339
+ transition: color 0.2s, text-shadow 0.2s;
1340
+ position: relative;
1341
+ }
1342
+ .footer-link::after {
1343
+ content: '';
1344
+ position: absolute;
1345
+ width: 100%;
1346
+ transform: scaleX(0);
1347
+ height: 1px;
1348
+ bottom: -2px;
1349
+ left: 0;
1350
+ background-color: #fcd34d;
1351
+ transform-origin: bottom right;
1352
+ transition: transform 0.25s ease-out;
1353
+ }
1354
+ .footer-link:hover {
1355
+ color: #fde047;
1356
+ text-shadow: 0 0 8px rgba(253, 224, 71, 0.6);
1357
+ }
1358
+ .footer-link:hover::after {
1359
+ transform: scaleX(1);
1360
+ transform-origin: bottom left;
1361
+ }
1362
+ </style>
1363
+ <div class="footer-credit">
1364
+ <div style="margin-bottom: 6px;">
1365
+ 程式設計:新竹縣精華國中 <strong style="color: #fff;">藍星宇</strong>
1366
+ </div>
1367
+ <div style="margin-bottom: 6px;">
1368
+ 教育社群:<a href="https://www.facebook.com/groups/1554372228718393" target="_blank" class="footer-link">萬物皆數</a>
1369
+ </div>
1370
+ <div>
1371
+ Pi-search 使用網站:<a href="https://www.angio.net/pi/" target="_blank" class="footer-link">angio.net/pi/</a>
1372
+ </div>
1373
+ </div>
1374
  </body>
1375
  </html>