107週年校慶典禮參加典禮-中獎名單(另開新視窗)
嘉心嘉力・共創新局|國立嘉義大學 107 週年校慶典禮抽獎活動
/* =====================================================================
典禮深紅金主題變數與基礎設定(搭配 Bootstrap 5.3.3)
===================================================================== */
:root {
--ceremony-red: #7a0e1b;
--ceremony-dark: #4a060f;
--ceremony-deep: #2b0308;
--ceremony-gold: #f5c542;
--ceremony-gold-light: #fff3c4;
--ceremony-gold-deep: #c99214;
--bs-body-font-family: "Noto Sans TC", system-ui, -apple-system, sans-serif;
}
body {
background: radial-gradient(circle at 50% 0%, #7a0e1b 0%, #4a060f 58%, #290308 100%);
min-height: 100vh;
color: var(--ceremony-gold-light);
overflow-x: hidden;
}
.font-serif-tc {
font-family: "Noto Serif TC", serif;
}
.font-mono-num {
font-family: "JetBrains Mono", monospace;
}
/* 深紅金慶典旋轉光芒背景 */
.ceremony-rays {
position: fixed;
inset: -50%;
width: 200%;
height: 200%;
background: repeating-conic-gradient(
from 0deg,
rgba(245, 197, 66, 0.055) 0deg 8deg,
transparent 8deg 22deg
);
animation: slowSpin 110s linear infinite;
pointer-events: none;
z-index: 0;
}
@keyframes slowSpin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
/* 深紅底專用:典禮金標題與分隔線樣式 */
.header-divider {
border-bottom: 1px solid rgba(245, 197, 66, 0.28);
}
.header-pill-badge {
background-color: rgba(245, 197, 66, 0.14);
color: var(--ceremony-gold);
border: 1px solid rgba(245, 197, 66, 0.55);
font-weight: 700;
letter-spacing: 0.05em;
}
.header-subtitle {
color: rgba(255, 243, 196, 0.85);
font-weight: 500;
}
.ceremony-footer {
color: rgba(255, 243, 196, 0.6);
}
/* 璀璨金屬漸層字體 */
.text-gold-gradient {
background: linear-gradient(135deg, #fff3c4 0%, #f5c542 42%, #e0a11b 75%, #fff3c4 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
filter: drop-shadow(0 2px 10px rgba(245, 197, 66, 0.28));
}
.text-gold {
color: var(--ceremony-gold) !important;
}
.text-gold-light {
color: var(--ceremony-gold-light) !important;
}
/* 107 週年校慶徽章(深金邊框高對比) */
.anniversary-badge {
width: 62px;
height: 62px;
background: linear-gradient(135deg, var(--ceremony-gold-light), var(--ceremony-gold), var(--ceremony-gold-deep));
padding: 2.5px;
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 0 18px rgba(245, 197, 66, 0.25);
}
.anniversary-badge-inner {
background: #2b0409;
width: 100%;
height: 100%;
}
/* 客製化 Bootstrap Card 深紅金慶典舞台容器 */
.stage-card {
background: linear-gradient(165deg, rgba(122, 14, 27, 0.86) 0%, rgba(74, 6, 15, 0.94) 55%, rgba(43, 3, 8, 0.96) 100%);
border: 1.5px solid rgba(245, 197, 66, 0.45);
box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42), inset 0 0 36px rgba(245, 197, 66, 0.06);
color: #ffffff;
}
.stage-main-area {
min-height: 350px;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
/* 四角典禮金框裝飾 */
.corner-ornament {
position: absolute;
width: 24px;
height: 24px;
border-color: rgba(245, 197, 66, 0.78);
border-style: solid;
pointer-events: none;
}
.corner-tl { top: 10px; left: 10px; border-width: 2.5px 0 0 2.5px; border-top-left-radius: 8px; }
.corner-tr { top: 10px; right: 10px; border-width: 2.5px 2.5px 0 0; border-top-right-radius: 8px; }
.corner-bl { bottom: 10px; left: 10px; border-width: 0 0 2.5px 2.5px; border-bottom-left-radius: 8px; }
.corner-br { bottom: 10px; right: 10px; border-width: 0 2.5px 2.5px 0; border-bottom-right-radius: 8px; }
/* 滾動抽獎時外框金光脈衝 */
.stage-rolling {
border-color: rgba(245, 197, 66, 0.95) !important;
box-shadow: 0 0 38px rgba(245, 197, 66, 0.35), inset 0 0 42px rgba(245, 197, 66, 0.14) !important;
}
/* 金屬光澤主按鈕與深酒紅輔助按鈕 */
.btn-gold {
background: linear-gradient(180deg, #ffe58f 0%, #f5c542 50%, #d49815 100%);
border: 1.5px solid #fff3c4;
color: #2b0409;
font-weight: 700;
box-shadow: 0 4px 14px rgba(245, 197, 66, 0.3);
}
.btn-gold:hover, .btn-gold:focus {
background: linear-gradient(180deg, #fff1b8 0%, #ffd25a 50%, #e0a61c 100%);
color: #1f0306;
border-color: #ffffff;
}
.btn-wine {
background: rgba(58, 5, 12, 0.88);
border: 1px solid rgba(245, 197, 66, 0.42);
color: var(--ceremony-gold-light);
font-weight: 600;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
.btn-wine:hover, .btn-wine:focus {
background: rgba(122, 14, 27, 0.95);
border-color: var(--ceremony-gold);
color: #ffffff;
}
.btn-wine.active {
background: linear-gradient(180deg, #ffe58f 0%, #f5c542 50%, #d49815 100%);
border-color: #fff3c4;
color: #2b0409;
font-weight: 700;
}
/* 深紅底專用:金框次要按鈕(「直接列出全部 150 人」) */
.btn-outline-wine {
background-color: rgba(245, 197, 66, 0.1);
border: 1.5px solid rgba(245, 197, 66, 0.78);
color: var(--ceremony-gold-light);
font-weight: 700;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
transition: all 0.2s ease;
}
.btn-outline-wine:hover, .btn-outline-wine:focus {
background-color: var(--ceremony-gold);
border-color: #fff3c4;
color: #2b0409;
}
/* Bootstrap Nav Pills 典禮金配色 */
.ceremony-pills .nav-link {
color: rgba(255, 243, 196, 0.82);
background: rgba(36, 3, 7, 0.65);
border: 1px solid rgba(245, 197, 66, 0.3);
font-weight: 600;
border-radius: 0.75rem;
padding: 0.42rem 0.95rem;
transition: all 0.2s ease;
}
.ceremony-pills .nav-link:hover {
border-color: var(--ceremony-gold);
color: #ffffff;
}
.ceremony-pills .nav-link.active {
background: linear-gradient(180deg, #f5c542 0%, #d49815 100%);
color: #2b0409;
border-color: #fff3c4;
font-weight: 700;
box-shadow: 0 4px 12px rgba(245, 197, 66, 0.3);
}
/* 搜尋輸入框深紅金樣式 */
.ceremony-input-group .input-group-text {
background: rgba(36, 3, 7, 0.9);
border-color: rgba(245, 197, 66, 0.4);
color: var(--ceremony-gold);
}
.ceremony-input-group .form-control {
background: rgba(36, 3, 7, 0.85);
border-color: rgba(245, 197, 66, 0.4);
color: var(--ceremony-gold-light);
}
.ceremony-input-group .form-control::placeholder {
color: rgba(255, 243, 196, 0.45);
}
.ceremony-input-group .form-control:focus {
background: rgba(36, 3, 7, 0.95);
border-color: var(--ceremony-gold);
color: #ffffff;
box-shadow: 0 0 0 0.2rem rgba(245, 197, 66, 0.25);
}
/* 進度條金光樣式 */
.ceremony-progress {
height: 12px;
background-color: rgba(36, 3, 7, 0.9);
border: 1px solid rgba(245, 197, 66, 0.35);
}
.ceremony-progress .progress-bar {
background: linear-gradient(90deg, #d49815 0%, #f5c542 55%, #fff3c4 100%);
}
/* 校區過場氣勢動畫 */
@keyframes campusBannerIn {
0% { opacity: 0; transform: scale(0.84); filter: blur(6px); }
55% { opacity: 1; transform: scale(1.03); filter: blur(0); }
100% { opacity: 1; transform: scale(1); filter: blur(0); }
}
.campus-intro-anim {
animation: campusBannerIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
/* 舞台抽獎卡片:滾動中與揭曉定格 */
.rolling-card {
background: rgba(36, 3, 7, 0.82);
border: 1px solid rgba(245, 197, 66, 0.4);
color: var(--ceremony-gold-light);
}
@keyframes cardPopIn {
0% { opacity: 0; transform: scale(0.76) translateY(14px); filter: brightness(1.65); }
65% { opacity: 1; transform: scale(1.04) translateY(-2px); filter: brightness(1.15); }
100% { opacity: 1; transform: scale(1) translateY(0); filter: brightness(1); }
}
.reveal-card {
opacity: 0;
animation: cardPopIn 0.48s cubic-bezier(0.22, 1, 0.36, 1) forwards;
background: linear-gradient(150deg, rgba(122, 14, 27, 0.96) 0%, rgba(58, 5, 12, 0.98) 100%);
border: 1.5px solid rgba(245, 197, 66, 0.9);
box-shadow: 0 8px 22px rgba(0, 0, 0, 0.48), 0 0 18px rgba(245, 197, 66, 0.28);
position: relative;
overflow: hidden;
}
/* 揭曉卡片流光掃描 */
.reveal-card::after {
content: "";
position: absolute;
top: -50%;
left: -135%;
width: 55%;
height: 200%;
background: linear-gradient(to right, transparent 0%, rgba(255, 243, 196, 0.34) 50%, transparent 100%);
transform: rotate(24deg);
animation: cardShimmer 1.25s ease-out 0.15s 1 forwards;
pointer-events: none;
}
@keyframes cardShimmer {
to { left: 165%; }
}
/* 下方總覽卡片與新收錄微光高亮動畫 */
.winner-item-card {
background: rgba(36, 3, 7, 0.72);
border: 1px solid rgba(245, 197, 66, 0.24);
transition: border-color 0.2s ease, transform 0.2s ease;
}
.winner-item-card:hover {
border-color: rgba(245, 197, 66, 0.75);
transform: translateY(-1px);
}
@keyframes newlyAddedGlow {
0% {
border-color: #fff3c4;
box-shadow: 0 0 18px rgba(245, 197, 66, 0.65);
background: rgba(201, 146, 20, 0.38);
}
100% {
border-color: rgba(245, 197, 66, 0.24);
box-shadow: none;
background: rgba(36, 3, 7, 0.72);
}
}
.newly-added-item {
animation: newlyAddedGlow 2.4s ease-out forwards;
}
/* 校區專屬徽章配色 */
.badge-lantan { background: rgba(16, 185, 129, 0.2); color: #a7f3d0; border: 1px solid rgba(52, 211, 153, 0.5); }
.badge-minxiong { background: rgba(14, 165, 233, 0.2); color: #bae6fd; border: 1px solid rgba(56, 189, 248, 0.5); }
.badge-xinmin { background: rgba(168, 85, 247, 0.22); color: #e9d5ff; border: 1px solid rgba(192, 132, 252, 0.5); }
.campus-group-box {
background: rgba(74, 6, 15, 0.45);
border: 1px solid rgba(245, 197, 66, 0.25);
}
/* 狀態脈衝點 */
@keyframes pulseDot {
0%, 100% { opacity: 1; transform: scale(1); }
50% { opacity: 0.4; transform: scale(0.8); }
}
.pulse-dot {
width: 10px;
height: 10px;
border-radius: 50%;
display: inline-block;
background-color: var(--ceremony-gold);
animation: pulseDot 1.2s ease-in-out infinite;
}
.pulse-dot.paused {
animation: none;
opacity: 0.5;
}
/* 全螢幕特效 Canvas */
#fxCanvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 1050;
}
/* 右下角柔和音效解鎖提示 */
#audioUnlockBanner {
position: fixed;
bottom: 1.1rem;
right: 1.1rem;
z-index: 1040;
transition: opacity 0.3s ease;
}
/* Bootstrap Toast 客製化典禮樣式 */
.ceremony-toast {
background: rgba(58, 5, 12, 0.96);
border: 1px solid rgba(245, 197, 66, 0.65);
color: var(--ceremony-gold-light);
}
點擊任意處啟用慶典音效
107
TH
嘉心嘉力・共創新局
國立嘉義大學 107 週年校慶典禮
抽獎活動-中獎名單自動揭曉
暫停
重新播放
直接列出全部 150 人
慢速
標準
快速
音效開
全螢幕
校區跳轉:
全部連播 (150)
蘭潭校區 (82)
民雄校區 (39)
新民校區 (29)
準備自動揭曉中...
已揭曉 0 / 150 人
自動抽獎揭曉啟動中...
第 0 / 26 批
完整中獎名單總覽
已揭曉 0 / 150 人
國立嘉義大學 107 週年校慶典禮・心嘉力・共創新局(蘭潭 82 名/民雄 39 名/新民 29 名,共計 150 名)
/**
* ============================================================================
* 1. 完整內建 150 筆精確中獎名單(蘭潭 82 人、民雄 39 人、新民 29 人)
* ============================================================================
*/
const RAW_WINNERS_BY_CAMPUS = {
"蘭潭校區": [
[1,"土木系","1152818"],[2,"土木系","1152787"],[3,"木設系","1142213"],[4,"木設系","1142227"],
[5,"木設系","1142241"],[6,"水生系","1153283"],[7,"生化系","1143366"],[8,"生化系","1143333"],
[9,"生化系","1143353"],[10,"生化系","1143343"],[11,"生化系","1143355"],[12,"生機系","1152841"],
[13,"生機系","1152890"],[14,"食科系","1153126"],[15,"食科系","1153172"],[16,"食科系","1153167"],
[17,"食科系","1153124"],[18,"食科系","1153121"],[19,"動科系","1152325"],[20,"動科系","1152282"],
[21,"動科系","1152306"],[22,"動科系","1152312"],[23,"動科系","1152296"],[24,"景觀系","1152445"],
[25,"景觀系","1152424"],[26,"森林系","1152142"],[27,"森林系","1152145"],[28,"森林系","1152171"],
[29,"森林系","1152154"],[30,"植醫系","1152502"],[31,"植醫系","1152494"],[32,"植醫系","1152504"],
[33,"園藝系","1152084"],[34,"園藝系","1152100"],[35,"園藝系","1152111"],[36,"園藝系","1152104"],
[37,"園藝系","1152110"],[38,"微藥系","1153438"],[39,"微藥系","1153431"],[40,"微藥系","1153442"],
[41,"微藥系","1153428"],[42,"微藥系","1153447"],[43,"資工系","1152925"],[44,"資工系","1152930"],
[45,"資工系","1152932"],[46,"農生系","1152396"],[47,"農生系","1152363"],[48,"農生系","1152386"],
[49,"農生系","1152370"],[50,"農生系","1152356"],[51,"農生系","1152373"],[52,"農管進學程","1158166"],
[53,"農管進學程","1158120"],[54,"農管進學程","1158130"],[55,"農管進學程","1158158"],[56,"農藝系","1152039"],
[57,"農藝系","1142013"],[58,"農藝系","1152009"],[59,"農藝系","1152042"],[60,"農藝系","1152011"],
[61,"電物系","1152657"],[62,"電物系","1152631"],[63,"電機系","1152984"],[64,"電機系","1152992"],
[65,"電機系","1152990"],[66,"電機系","1152986"],[67,"電機系","1152997"],[68,"機械系","1153079"],
[69,"機械系","1153059"],[70,"機械系","1153099"],[71,"機械系","1153051"],[72,"機械系","1153068"],
[73,"機械系","1153083"],[74,"應化系","1152706"],[75,"應化系","1152729"],[76,"應化系","1152712"],
[77,"應化系","1152747"],[78,"應化系","1152716"],[79,"應數系","1152561"],[80,"應數系","1152571"],
[81,"應數系","1152588"],[82,"應數系","1152610"]
],
"民雄校區": [
[1,"中文系","1154245"],[2,"中文系","1154266"],[3,"中文系","1154274"],[4,"中文系","1154267"],
[5,"中文系","1154272"],[6,"中文系","1154247"],[7,"外語系","1153979"],[8,"外語系","1154000"],
[9,"外語系","1153894"],[10,"外語系","1154009"],[11,"幼教系","1153646"],[12,"幼教系","1153615"],
[13,"幼教系","1153612"],[14,"幼教系","1153636"],[15,"特教系","1153554"],[16,"特教系","1143548"],
[17,"特教系","1133580"],[18,"特教系","1153566"],[19,"特教系","1133545"],[20,"教育系","1153508"],
[21,"教育系","1153474"],[22,"教育系","1153479"],[23,"教育系","1153504"],[24,"教育系","1153478"],
[25,"教育系","1153513"],[26,"輔諮系","1153713"],[27,"輔諮系","1153711"],[28,"輔諮系","1153724"],
[29,"輔諮系","1153732"],[30,"輔諮系","1153712"],[31,"數位系","1153851"],[32,"數位系","1153853"],
[33,"應用歷史系","1154070"],[34,"應用歷史系","1154041"],[35,"應用歷史系","1154035"],[36,"應用歷史系","1154033"],
[37,"視覺藝術系","1154121"],[38,"視覺藝術系","1154115"],[39,"視覺藝術系","1154101"]
],
"新民校區": [
[1,"企管系","1154474"],[2,"企管系","1154478"],[3,"企管系","1154469"],[4,"企管系","1154467"],
[5,"行銷觀光系","1154693"],[6,"行銷觀光系","1154685"],[7,"行銷觀光系","1154677"],[8,"科管系","1154319"],
[9,"科管系","1154314"],[10,"科管系","1154324"],[11,"科管系","1154330"],[12,"科管系","1154328"],
[13,"科管系","1154320"],[14,"財金系","1154638"],[15,"財金系","1154605"],[16,"財金系","1154628"],
[17,"財金系","1154604"],[18,"財金系","1154637"],[19,"財金系","1154633"],[20,"資管系","1154525"],
[21,"資管系","1154524"],[22,"資管系","1154532"],[23,"資管系","1154577"],[24,"資管系","1154564"],
[25,"應經系","1154419"],[26,"應經系","1154435"],[27,"應經系","1154399"],[28,"獸醫系","1154734"],
[29,"獸醫系","1154752"]
]
};
const CAMPUS_ORDER = ["蘭潭校區", "民雄校區", "新民校區"];
const CAMPUS_META = {
"蘭潭校區": { badgeClass: "badge-lantan", subtitle: "Lantan Campus・共 82 名中獎人" },
"民雄校區": { badgeClass: "badge-minxiong", subtitle: "Minxiong Campus・共 39 名中獎人" },
"新民校區": { badgeClass: "badge-xinmin", subtitle: "Xinmin Campus・共 29 名中獎人" }
};
// 建立展平資料與各校區索引
const ALL_WINNERS = [];
const WINNERS_BY_CAMPUS = {};
CAMPUS_ORDER.forEach(campus => {
WINNERS_BY_CAMPUS[campus] = RAW_WINNERS_BY_CAMPUS[campus].map(([seq, dept, studentId]) => {
const record = { uid: `${campus}-${seq}-${studentId}`, campus, seq, dept, studentId };
ALL_WINNERS.push(record);
return record;
});
});
/**
* 將各校區均勻切分為每批 5~6 人(無零碎落單):
* 蘭潭 82 人 -> 14 批(6人×12 + 5人×2)
* 民雄 39 人 -> 7 批(6人×4 + 5人×3)
* 新民 29 人 -> 5 批(6人×4 + 5人×1)
*/
function buildPlaylist(scope = "ALL") {
const targetCampuses = scope === "ALL" ? CAMPUS_ORDER : [scope];
const steps = [];
let globalBatchIndex = 0;
targetCampuses.forEach(campus => {
const list = WINNERS_BY_CAMPUS[campus];
const numBatches = Math.ceil(list.length / 6);
const baseSize = Math.floor(list.length / numBatches);
const remainder = list.length % numBatches;
const batches = [];
let cursor = 0;
for (let b = 0; b {
globalBatchIndex++;
steps.push({
type: "batch",
campus,
campusBatchNum: idx + 1,
campusBatchTotal: batches.length,
globalBatchNum: globalBatchIndex,
items
});
});
});
steps.forEach(step => {
if (step.type === "batch") step.globalBatchTotal = globalBatchIndex;
});
return steps;
}
/**
* ============================================================================
* 2. Web Audio API 典禮合成音效引擎(滾動節奏+校區定音鼓+揭曉歡呼和弦)
* ============================================================================
*/
class CeremonyAudio {
constructor() {
this.ctx = null;
this.unlocked = false;
}
unlock() {
try {
if (!this.ctx) {
const AudioCtx = window.AudioContext || window.webkitAudioContext;
if (AudioCtx) this.ctx = new AudioCtx();
}
if (this.ctx && this.ctx.state === "suspended") {
this.ctx.resume();
}
if (this.ctx && this.ctx.state === "running") {
this.unlocked = true;
hideAudioBanner();
}
} catch (e) {}
}
isReady() {
return state.soundEnabled && this.ctx && this.ctx.state === "running";
}
// 校區切換鼓聲
playCampusIntro() {
if (!this.isReady()) return;
try {
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = "sine";
osc.frequency.setValueAtTime(165, now);
osc.frequency.exponentialRampToValueAtTime(68, now + 0.55);
gain.gain.setValueAtTime(0.25, now);
gain.gain.exponentialRampToValueAtTime(0.001, now + 0.65);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.68);
} catch (e) {}
}
// 高速滾動清脆音效
playTick(progress = 0) {
if (!this.isReady()) return;
try {
const now = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
const freq = 600 + (1 - progress) * 280 + (Math.random() * 44 - 22);
osc.type = "triangle";
osc.frequency.setValueAtTime(freq, now);
osc.frequency.exponentialRampToValueAtTime(240, now + 0.04);
gain.gain.setValueAtTime(0.11, now);
gain.gain.exponentialRampToValueAtTime(0.001, now + 0.045);
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(now);
osc.stop(now + 0.05);
} catch (e) {}
}
// 揭曉歡呼和弦
playRevealFanfare(grand = false) {
if (!this.isReady()) return;
try {
const now = this.ctx.currentTime;
const notes = grand
? [523.25, 659.25, 783.99, 1046.50, 1318.51, 1567.98]
: [523.25, 659.25, 783.99, 1046.50];
notes.forEach((freq, idx) => {
const start = now + idx * 0.065;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = "triangle";
osc.frequency.setValueAtTime(freq, start);
gain.gain.setValueAtTime(0.001, start);
gain.gain.linearRampToValueAtTime(grand ? 0.16 : 0.12, start + 0.025);
gain.gain.exponentialRampToValueAtTime(0.001, start + (grand ? 1.35 : 0.85));
osc.connect(gain);
gain.connect(this.ctx.destination);
osc.start(start);
osc.stop(start + (grand ? 1.4 : 0.9));
});
} catch (e) {}
}
}
const audioEngine = new CeremonyAudio();
function hideAudioBanner() {
const banner = document.getElementById("audioUnlockBanner");
if (banner) {
banner.style.opacity = "0";
banner.style.pointerEvents = "none";
setTimeout(() => banner.classList.add("d-none"), 300);
}
}
/**
* ============================================================================
* 3. 全螢幕 Canvas 金色彩帶與煙火慶賀特效
* ============================================================================
*/
class CelebrationFX {
constructor(canvasId) {
this.canvas = document.getElementById(canvasId);
this.ctx = this.canvas.getContext("2d");
this.particles = [];
this.running = false;
this.palette = ["#f5c542", "#fff3c4", "#fbbf24", "#f87171", "#ef4444", "#ffffff", "#34d399", "#38bdf8"];
this.resize();
window.addEventListener("resize", () => this.resize());
}
resize() {
this.canvas.width = window.innerWidth;
this.canvas.height = window.innerHeight;
}
burstBatch() {
const w = this.canvas.width;
const h = this.canvas.height;
for (let i = 0; i {
setTimeout(() => {
this.createFirework(pt.x, pt.y, 44);
this.startLoop();
}, pt.delay);
});
}
createFirework(cx, cy, count = 36) {
const primary = this.palette[Math.floor(Math.random() * 3)];
for (let i = 0; i = 0; i--) {
const p = this.particles[i];
p.vx *= p.drag;
p.vy = p.vy * p.drag + p.gravity;
p.x += p.vx;
p.y += p.vy;
p.alpha -= p.decay;
if (p.alpha this.canvas.height + 40) {
this.particles.splice(i, 1);
continue;
}
this.ctx.save();
this.ctx.globalAlpha = Math.max(0, p.alpha);
if (p.type === "confetti") {
p.angle += p.spin;
this.ctx.translate(p.x, p.y);
this.ctx.rotate(p.angle);
this.ctx.fillStyle = p.color;
this.ctx.fillRect(-p.w / 2, -p.h / 2, p.w, p.h);
} else {
this.ctx.beginPath();
this.ctx.arc(p.x, p.y, p.radius, 0, Math.PI * 2);
this.ctx.fillStyle = p.color;
this.ctx.shadowBlur = 10;
this.ctx.shadowColor = p.color;
this.ctx.fill();
}
this.ctx.restore();
}
if (this.particles.length > 0) {
requestAnimationFrame(() => this.loop());
} else {
this.running = false;
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
}
}
}
const fxEngine = new CelebrationFX("fxCanvas");
/**
* ============================================================================
* 4. 狀態管理與 Bootstrap Toast 提示
* ============================================================================
*/
const SPEED_PRESETS = {
slow: { introMs: 1500, rollMs: 2200, holdMs: 2800, label: "慢速" },
normal: { introMs: 1150, rollMs: 1600, holdMs: 2000, label: "標準" },
fast: { introMs: 700, rollMs: 950, holdMs: 1150, label: "快速" }
};
const state = {
scope: "ALL",
speed: "normal",
soundEnabled: true,
isPaused: false,
isCompleted: false,
playlist: [],
revealedUids: new Set(),
latestBatchUids: new Set(),
listFilterCampus: "ALL",
searchKeyword: "",
runToken: 0,
activeTimers: []
};
function clearAllTimers() {
state.activeTimers.forEach(id => clearTimeout(id));
state.activeTimers = [];
}
// 使用 Bootstrap 5 Toast 顯示操作提示(絕不使用 alert)
function showToast(message) {
const container = document.getElementById("toastContainer");
const toastEl = document.createElement("div");
toastEl.className = "toast ceremony-toast align-items-center rounded-3 shadow-lg";
toastEl.setAttribute("role", "status");
toastEl.setAttribute("aria-live", "polite");
toastEl.innerHTML = `
${escapeHtml(message)}
`;
container.appendChild(toastEl);
if (window.bootstrap && bootstrap.Toast) {
const bsToast = new bootstrap.Toast(toastEl, { delay: 2400 });
bsToast.show();
toastEl.addEventListener("hidden.bs.toast", () => toastEl.remove());
} else {
toastEl.classList.add("show");
setTimeout(() => toastEl.remove(), 2400);
}
}
function escapeHtml(str) {
return String(str).replace(/[&"']/g, m => ({ "&": "&", "": ">", '"': """, "'": "'" }[m]));
}
// 支援暫停與安全中斷的延遲函式
function sleepWithPause(ms, token) {
return new Promise(resolve => {
let elapsed = 0;
let lastTick = performance.now();
function check() {
if (token !== state.runToken) return resolve(false);
const now = performance.now();
if (!state.isPaused) {
elapsed += (now - lastTick);
}
lastTick = now;
if (elapsed >= ms) return resolve(true);
const id = setTimeout(check, 50);
state.activeTimers.push(id);
}
check();
});
}
/**
* ============================================================================
* 5. 自動抽獎揭曉主流程(蘭潭 → 民雄 → 新民,每批 5~6 人)
* ============================================================================
*/
async function startAutoShow(scope = "ALL", resetRevealed = true) {
state.runToken++;
const token = state.runToken;
clearAllTimers();
state.scope = scope;
state.isPaused = false;
state.isCompleted = false;
state.playlist = buildPlaylist(scope);
state.latestBatchUids.clear();
if (resetRevealed) {
state.revealedUids.clear();
}
state.listFilterCampus = scope === "ALL" ? "ALL" : scope;
updateControlsUI();
renderWinnersList();
updateProgressUI("準備開始自動揭曉...");
for (let i = 0; i
${meta.subtitle}
${step.campus}
國立嘉義大學 107 週年校慶典禮・中獎名單即將揭曉
`;
audioEngine.playCampusIntro();
return await sleepWithPause(preset.introMs, token);
}
// 單批高速滾動 -> 定格揭曉+彩帶煙火 -> 收錄至下方總覽
async function runBatchStep(step, token) {
const mainStage = document.getElementById("mainStage");
const stageContent = document.getElementById("stageContent");
const count = step.items.length;
const campusPool = WINNERS_BY_CAMPUS[step.campus];
mainStage.classList.add("stage-rolling");
document.getElementById("stageStatusTitle").textContent = `${step.campus}・第 ${step.campusBatchNum} / ${step.campusBatchTotal} 批滾動抽獎中...`;
document.getElementById("stageBatchHint").textContent = `總進度 第 ${step.globalBatchNum} / ${step.globalBatchTotal} 批(本批 ${count} 名)`;
updateProgressUI(`正在揭曉 ${step.campus} 第 ${step.campusBatchNum}/${step.campusBatchTotal} 批...`);
// 依本批人數(5 或 6 人)自動選擇最對稱的 Bootstrap 響應式格線
const colClass = count `;
const stageGrid = document.getElementById("stageGrid");
const okRoll = await runRollingAnimation(stageGrid, campusPool, count, token);
if (!okRoll) return false;
// 定格揭曉
mainStage.classList.remove("stage-rolling");
document.getElementById("stageStatusTitle").textContent = `🎉 恭喜 ${step.campus} 第 ${step.campusBatchNum} 批得獎同學!`;
stageGrid.innerHTML = step.items
.map((item, idx) => createStageCardHtml(item, true, idx))
.join("");
fxEngine.burstBatch();
audioEngine.playRevealFanfare(false);
// 即時同步收錄至下方總覽
state.latestBatchUids = new Set(step.items.map(x => x.uid));
step.items.forEach(x => state.revealedUids.add(x.uid));
updateProgressUI(`已揭曉 ${step.campus} 第 ${step.campusBatchNum}/${step.campusBatchTotal} 批`);
renderWinnersList();
const holdMs = SPEED_PRESETS[state.speed].holdMs;
return await sleepWithPause(holdMs, token);
}
// 高速滾動動畫循環(支援暫停、即時變速、尾段漸進減速)
function runRollingAnimation(gridEl, pool, count, token) {
return new Promise(resolve => {
let elapsed = 0;
let lastTime = performance.now();
function tick() {
if (token !== state.runToken) return resolve(false);
const totalRollMs = SPEED_PRESETS[state.speed].rollMs;
const now = performance.now();
if (!state.isPaused) {
elapsed += (now - lastTime);
const progress = Math.min(1, elapsed / totalRollMs);
const batchPreview = [];
for (let i = 0; i createStageCardHtml(item, false, 0))
.join("");
audioEngine.playTick(progress);
if (elapsed >= totalRollMs) {
return resolve(true);
}
const nextDelay = progress > 0.65
? 48 + Math.pow((progress - 0.65) / 0.35, 2) * 155
: 48;
lastTime = now;
const id = setTimeout(tick, nextDelay);
state.activeTimers.push(id);
} else {
lastTime = now;
const id = setTimeout(tick, 80);
state.activeTimers.push(id);
}
}
tick();
});
}
// 全部揭曉完成畫面
function finishAutoShow(isFullAll) {
state.isCompleted = true;
state.isPaused = false;
state.latestBatchUids.clear();
const mainStage = document.getElementById("mainStage");
const stageContent = document.getElementById("stageContent");
mainStage.classList.remove("stage-rolling");
const headline = isFullAll
? "三校區全體 150 位中獎人已全數揭曉!"
: `${state.scope}全體 ${WINNERS_BY_CAMPUS[state.scope].length} 位中獎人已全數揭曉!`;
document.getElementById("stageStatusTitle").textContent = "🎉 揭曉完畢・恭喜所有幸運得主!";
document.getElementById("stageBatchHint").textContent = `已揭曉 ${state.revealedUids.size} / 150 人`;
updateProgressUI("全部中獎名單揭曉完成!");
stageContent.innerHTML = `
嘉心嘉力・共創新局
${headline}
下方已完整依「蘭潭、民雄、新民」三校區呈現序號、學系與學號,歡迎使用校區頁籤或搜尋框快速查詢。
重新播放完整揭曉動畫
檢視完整中獎名單
`;
fxEngine.burstGrandFinale();
audioEngine.playRevealFanfare(true);
updateControlsUI();
renderWinnersList();
}
// 一鍵直接列出全部 150 人名單
function revealAllImmediately() {
state.runToken++;
clearAllTimers();
ALL_WINNERS.forEach(w => state.revealedUids.add(w.uid));
state.scope = "ALL";
state.listFilterCampus = "ALL";
finishAutoShow(true);
showToast("已直接列出全部 150 位中獎人名單!");
}
/**
* ============================================================================
* 6. Bootstrap 5 元件介面渲染函式
* ============================================================================
*/
function createStageCardHtml(person, isRevealed, idx) {
const meta = CAMPUS_META[person.campus];
const cardTypeClass = isRevealed ? "reveal-card" : "rolling-card";
const delayStyle = isRevealed ? `style="animation-delay: ${idx * 55}ms;"` : "";
return `
#${String(person.seq).padStart(2, "0")}
${person.campus.replace("校區", "")}
${person.dept}
${person.studentId}
`;
}
function updateProgressUI(labelText) {
const count = state.revealedUids.size;
const total = ALL_WINNERS.length;
const pct = Math.round((count / total) * 100);
document.getElementById("progressLabel").textContent = labelText;
document.getElementById("progressCounter").textContent = `已揭曉 ${count} / ${total} 人`;
document.getElementById("listRevealedBadge").textContent = `已揭曉 ${count} / ${total} 人`;
const bar = document.getElementById("progressBarFill");
bar.style.width = `${pct}%`;
bar.parentElement.setAttribute("aria-valuenow", String(count));
}
function updateControlsUI() {
const ppIcon = document.getElementById("playPauseIcon");
const ppText = document.getElementById("playPauseText");
const pulseDot = document.getElementById("stagePulseDot");
if (state.isCompleted) {
ppIcon.className = "bi bi-arrow-counterclockwise";
ppText.textContent = "重播";
pulseDot.classList.add("paused");
} else if (state.isPaused) {
ppIcon.className = "bi bi-play-fill";
ppText.textContent = "繼續";
pulseDot.classList.add("paused");
} else {
ppIcon.className = "bi bi-pause-fill";
ppText.textContent = "暫停";
pulseDot.classList.remove("paused");
}
// 速度按鈕群組 active 狀態
document.querySelectorAll(".speed-btn").forEach(btn => {
btn.classList.toggle("active", btn.dataset.speed === state.speed);
});
// 校區跳轉按鈕群組 active 狀態
document.querySelectorAll(".jump-campus-btn").forEach(btn => {
btn.classList.toggle("active", btn.dataset.jump === state.scope);
});
}
// 渲染下方「完整中獎名單總覽」(nav-pills + 響應式 Bootstrap 格線)
function renderWinnersList() {
// 1. 渲染 Bootstrap nav-pills 篩選頁籤
const tabsEl = document.getElementById("listFilterTabs");
const tabOptions = [
{ key: "ALL", label: "全部校區", total: ALL_WINNERS.length, revealed: state.revealedUids.size },
...CAMPUS_ORDER.map(c => ({
key: c,
label: c,
total: WINNERS_BY_CAMPUS[c].length,
revealed: WINNERS_BY_CAMPUS[c].filter(w => state.revealedUids.has(w.uid)).length
}))
];
tabsEl.innerHTML = tabOptions.map(t => `
${t.label} (${t.revealed}/${t.total})
`).join("");
tabsEl.querySelectorAll("button[data-filter-campus]").forEach(btn => {
btn.addEventListener("click", () => {
state.listFilterCampus = btn.dataset.filterCampus;
renderWinnersList();
});
});
// 2. 分校區渲染已揭曉名單
const container = document.getElementById("winnersGroupsContainer");
const keyword = state.searchKeyword.trim().toLowerCase();
const campusesToShow = state.listFilterCampus === "ALL" ? CAMPUS_ORDER : [state.listFilterCampus];
let totalMatched = 0;
const sectionsHtml = campusesToShow.map(campus => {
const meta = CAMPUS_META[campus];
const allInCampus = WINNERS_BY_CAMPUS[campus];
const revealedInCampus = allInCampus.filter(w => state.revealedUids.has(w.uid));
const filtered = revealedInCampus.filter(w => {
if (!keyword) return true;
return (
w.studentId.toLowerCase().includes(keyword) ||
w.dept.toLowerCase().includes(keyword) ||
String(w.seq) === keyword
);
});
totalMatched += filtered.length;
if (revealedInCampus.length === 0) {
return `
${campus}
0 / ${allInCampus.length} 名
等待自動揭曉中...
`;
}
if (filtered.length === 0 && keyword) {
return "";
}
const itemsHtml = filtered.map(w => {
const isNew = state.latestBatchUids.has(w.uid);
return `
${String(w.seq).padStart(2, "0")}
${w.dept}
${w.studentId}
`;
}).join("");
return `
${campus}
${revealedInCampus.length} / ${allInCampus.length} 名
${keyword ? `符合搜尋:${filtered.length} 筆` : ""}
${itemsHtml}
`;
}).join("");
if (keyword && totalMatched === 0) {
container.innerHTML = `
在目前已揭曉的名單中,查無符合「${escapeHtml(state.searchKeyword)}」的學號或學系。
`;
} else {
container.innerHTML = sectionsHtml;
}
}
/**
* ============================================================================
* 7. 事件綁定與開頁自動執行
* ============================================================================
*/
function bindEvents() {
// 點擊頁面任意處自動解鎖 Web Audio API 音效
const unlockOnce = () => {
audioEngine.unlock();
if (audioEngine.unlocked) {
window.removeEventListener("pointerdown", unlockOnce);
window.removeEventListener("keydown", unlockOnce);
}
};
window.addEventListener("pointerdown", unlockOnce);
window.addEventListener("keydown", unlockOnce);
document.getElementById("btnUnlockAudio").addEventListener("click", () => {
state.soundEnabled = true;
audioEngine.unlock();
showToast("慶典音效已啟用!");
});
// 暫停/繼續/重播
document.getElementById("btnPlayPause").addEventListener("click", () => {
if (state.isCompleted) {
startAutoShow(state.scope, true);
return;
}
state.isPaused = !state.isPaused;
updateControlsUI();
showToast(state.isPaused ? "已暫停自動揭曉" : "繼續自動揭曉");
});
// 重新播放全部 150 人
document.getElementById("btnReplay").addEventListener("click", () => {
startAutoShow("ALL", true);
showToast("已重新開始三校區完整自動揭曉!");
});
// 一鍵直接列出全部 150 人
document.getElementById("btnRevealAllNow").addEventListener("click", revealAllImmediately);
// 速度切換
document.querySelectorAll(".speed-btn").forEach(btn => {
btn.addEventListener("click", () => {
state.speed = btn.dataset.speed;
updateControlsUI();
showToast(`揭曉速度已切換為「${SPEED_PRESETS[state.speed].label}」`);
});
});
// 校區跳轉播放
document.querySelectorAll(".jump-campus-btn").forEach(btn => {
btn.addEventListener("click", () => {
const target = btn.dataset.jump;
if (target === "ALL") {
startAutoShow("ALL", true);
showToast("開始完整三校區自動連播揭曉");
} else {
WINNERS_BY_CAMPUS[target].forEach(w => state.revealedUids.delete(w.uid));
startAutoShow(target, false);
showToast(`已跳轉至「${target}」自動揭曉`);
}
});
});
// 音效開關
document.getElementById("btnToggleSound").addEventListener("click", () => {
audioEngine.unlock();
state.soundEnabled = !state.soundEnabled;
document.getElementById("soundStatusIcon").className = state.soundEnabled
? "bi bi-volume-up-fill text-gold"
: "bi bi-volume-mute-fill text-secondary";
document.getElementById("soundStatusText").textContent = state.soundEnabled ? "音效開" : "已靜音";
showToast(state.soundEnabled ? "慶典音效已開啟" : "已切換為靜音模式");
});
// 全螢幕切換
document.getElementById("btnFullscreen").addEventListener("click", () => {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen?.().catch(() => {
showToast("瀏覽器目前未允許全螢幕切換");
});
} else {
document.exitFullscreen?.();
}
});
document.addEventListener("fullscreenchange", () => {
const isFs = Boolean(document.fullscreenElement);
document.getElementById("fullscreenIcon").className = isFs
? "bi bi-fullscreen-exit text-gold"
: "bi bi-arrows-fullscreen text-gold";
document.getElementById("fullscreenText").textContent = isFs ? "離開全螢幕" : "全螢幕";
});
// 搜尋與清除
const searchInput = document.getElementById("searchInput");
const btnClearSearch = document.getElementById("btnClearSearch");
searchInput.addEventListener("input", (e) => {
state.searchKeyword = e.target.value;
btnClearSearch.classList.toggle("d-none", !state.searchKeyword);
renderWinnersList();
});
btnClearSearch.addEventListener("click", () => {
state.searchKeyword = "";
searchInput.value = "";
btnClearSearch.classList.add("d-none");
renderWinnersList();
});
// 空白鍵快速暫停/繼續(不在輸入框中時生效)
document.addEventListener("keydown", (e) => {
if (e.code !== "Space") return;
if (document.activeElement?.tagName === "INPUT") return;
e.preventDefault();
document.getElementById("btnPlayPause").click();
});
}
// 開頁自動啟動完整揭曉流程
window.addEventListener("DOMContentLoaded", () => {
bindEvents();
startAutoShow("ALL", true);
});