- Add Recognition notification type (ID 5) with blue color - Add employeesso field to notifications table - Create carousel display for Recognition on shopfloor dashboard - Show employee names (lookup from wjf_employees) instead of SSO - Auto-set starttime to NOW and endtime to 4AM next day - Auto-enable shopfloor display for Recognition type - Add Achievements tab to employee profile (displayprofile.asp) - Hide Recognition from calendar view - Add lookupemployee.asp AJAX endpoint for name preview - Fix datetime double-formatting bug in save/update files - Fix URL parameter loading on shopfloor dashboard init 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1575 lines
50 KiB
HTML
1575 lines
50 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
|
<meta http-equiv="Pragma" content="no-cache">
|
|
<meta http-equiv="Expires" content="0">
|
|
<title>West Jefferson - Events & Notifications</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
background: #00003d; /* GE Aerospace Deep Navy */
|
|
color: #fff;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
.container {
|
|
max-width: 100%;
|
|
margin: 0 auto;
|
|
padding: 20px 40px;
|
|
padding-bottom: 80px;
|
|
}
|
|
|
|
.header {
|
|
position: relative;
|
|
display: grid;
|
|
grid-template-columns: auto 1fr auto;
|
|
align-items: center;
|
|
gap: 30px;
|
|
margin-bottom: 25px;
|
|
border-bottom: 3px solid #4181ff; /* GE Sky Blue */
|
|
padding-bottom: 15px;
|
|
}
|
|
|
|
.logo-container {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.logo-container img {
|
|
height: 90px;
|
|
width: auto;
|
|
}
|
|
|
|
.fiscal-week {
|
|
font-size: 18px;
|
|
font-weight: 600;
|
|
color: #888;
|
|
letter-spacing: 2px;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.header-center {
|
|
text-align: center;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 5px;
|
|
}
|
|
|
|
.location-title {
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
color: #eaeaea; /* GE Tungsten */
|
|
text-transform: uppercase;
|
|
letter-spacing: 2px;
|
|
}
|
|
|
|
.header-center h1 {
|
|
font-size: 32px;
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
letter-spacing: 2px;
|
|
color: #fff;
|
|
}
|
|
|
|
.clock {
|
|
font-size: 28px;
|
|
font-weight: 600;
|
|
letter-spacing: 1px;
|
|
color: #4181ff; /* GE Sky Blue */
|
|
text-align: right;
|
|
line-height: 1.3;
|
|
white-space: nowrap;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
.filter-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
align-items: flex-end;
|
|
}
|
|
|
|
.filter-label {
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: #eaeaea;
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
.filter-select {
|
|
padding: 10px 16px;
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
background: #1a1a5e;
|
|
color: #fff;
|
|
border: 2px solid #4181ff;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
min-width: 200px;
|
|
font-family: 'Inter', sans-serif;
|
|
}
|
|
|
|
.filter-select:hover {
|
|
background: #2a2a6e;
|
|
border-color: #5a91ff;
|
|
}
|
|
|
|
.filter-select:focus {
|
|
outline: none;
|
|
border-color: #0ad64f;
|
|
box-shadow: 0 0 0 3px rgba(10, 214, 79, 0.2);
|
|
}
|
|
|
|
.connection-status {
|
|
position: absolute;
|
|
top: 100%;
|
|
right: 0;
|
|
margin-top: 10px;
|
|
padding: 8px 16px;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
font-weight: 700;
|
|
z-index: 1000;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
.connection-status.connected {
|
|
background: #0ad64f; /* GE Avionics Green */
|
|
color: #00003d;
|
|
}
|
|
|
|
.connection-status.disconnected {
|
|
background: #dc3545;
|
|
animation: blink 1s infinite;
|
|
}
|
|
|
|
@keyframes blink {
|
|
0%, 50% { opacity: 1; }
|
|
51%, 100% { opacity: 0.5; }
|
|
}
|
|
|
|
.status-dot {
|
|
width: 12px;
|
|
height: 12px;
|
|
border-radius: 50%;
|
|
background: #00003d;
|
|
}
|
|
|
|
.events-section {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.events-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 10px;
|
|
}
|
|
|
|
/* Single event - full width */
|
|
.events-grid.single {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
/* 3 or more events - use 2 columns */
|
|
.events-grid.multi {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
|
|
.section-title {
|
|
font-size: 22px;
|
|
font-weight: 800;
|
|
margin-bottom: 5px;
|
|
padding: 5px 10px;
|
|
border-radius: 8px;
|
|
display: inline-block;
|
|
text-transform: uppercase;
|
|
letter-spacing: 2px;
|
|
}
|
|
|
|
.section-title.current {
|
|
background: #dc3545;
|
|
color: #fff;
|
|
box-shadow: 0 4px 20px rgba(220, 53, 69, 0.4);
|
|
}
|
|
|
|
/* Dynamic severity colors for current events */
|
|
.section-title.current.severity-danger {
|
|
background: #dc3545; /* Red - Incident */
|
|
box-shadow: 0 4px 20px rgba(220, 53, 69, 0.4);
|
|
}
|
|
|
|
.section-title.current.severity-warning {
|
|
background: #ffc107; /* Yellow - Change */
|
|
color: #000;
|
|
box-shadow: 0 4px 20px rgba(255, 193, 7, 0.4);
|
|
}
|
|
|
|
.section-title.current.severity-success {
|
|
background: #0ad64f; /* Green - Awareness/TBD */
|
|
color: #00003d;
|
|
box-shadow: 0 4px 20px rgba(10, 214, 79, 0.4);
|
|
}
|
|
|
|
.section-title.upcoming {
|
|
background: #4181ff; /* GE Sky Blue */
|
|
color: #fff;
|
|
box-shadow: 0 4px 20px rgba(65, 129, 255, 0.4);
|
|
}
|
|
|
|
.event-card {
|
|
background: #fff;
|
|
color: #000;
|
|
padding: 15px 20px;
|
|
margin-bottom: 5px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
|
border-left: 60px solid;
|
|
transition: all 0.3s ease;
|
|
position: relative;
|
|
}
|
|
|
|
.resolved-indicator {
|
|
position: absolute;
|
|
left: -60px;
|
|
top: 0;
|
|
bottom: 0;
|
|
width: 60px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
writing-mode: vertical-rl;
|
|
text-orientation: upright;
|
|
font-size: 18px;
|
|
font-weight: 800;
|
|
letter-spacing: -3px;
|
|
color: #fff;
|
|
text-transform: uppercase;
|
|
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.event-card.current {
|
|
border-left-color: #dc3545;
|
|
animation: pulse 2s infinite;
|
|
}
|
|
|
|
.event-card.current.resolved {
|
|
animation: none;
|
|
}
|
|
|
|
.event-card.upcoming {
|
|
border-left-color: #4181ff; /* GE Sky Blue */
|
|
}
|
|
|
|
@keyframes pulse {
|
|
0%, 100% {
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
|
}
|
|
50% {
|
|
box-shadow: 0 6px 30px rgba(220, 53, 69, 0.5);
|
|
}
|
|
}
|
|
|
|
.event-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 12px;
|
|
gap: 20px;
|
|
min-height: 32px;
|
|
}
|
|
|
|
.event-title {
|
|
font-size: 32px;
|
|
font-weight: 700;
|
|
flex: 1;
|
|
color: #00003d; /* GE Deep Navy for text */
|
|
line-height: 1.2;
|
|
}
|
|
|
|
.event-ticket {
|
|
font-size: 22px;
|
|
font-weight: 700;
|
|
background: #00003d; /* GE Deep Navy */
|
|
color: #fff;
|
|
padding: 5px 12px;
|
|
border-radius: 6px;
|
|
white-space: nowrap;
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.event-ticket:hover {
|
|
background: #4181ff; /* GE Sky Blue */
|
|
transform: scale(1.05);
|
|
box-shadow: 0 4px 15px rgba(65, 129, 255, 0.4);
|
|
}
|
|
|
|
.event-time {
|
|
font-size: 22px;
|
|
color: #666;
|
|
font-weight: 400;
|
|
line-height: 1.4;
|
|
}
|
|
|
|
.event-time strong {
|
|
color: #00003d; /* GE Deep Navy */
|
|
font-weight: 700;
|
|
}
|
|
|
|
.no-events {
|
|
text-align: center;
|
|
font-size: 32px;
|
|
font-weight: 600;
|
|
padding: 40px 30px;
|
|
background: rgba(234, 234, 234, 0.1);
|
|
border-radius: 8px;
|
|
margin-top: 20px;
|
|
color: #eaeaea; /* GE Tungsten */
|
|
}
|
|
|
|
.footer {
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
background: rgba(0, 0, 0, 0.8);
|
|
text-align: center;
|
|
padding: 12px;
|
|
font-size: 18px;
|
|
z-index: 999;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.loading {
|
|
text-align: center;
|
|
font-size: 32px;
|
|
font-weight: 600;
|
|
padding: 40px 30px;
|
|
background: rgba(234, 234, 234, 0.1);
|
|
border-radius: 8px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.error-message {
|
|
background: #dc3545;
|
|
color: #fff;
|
|
padding: 30px;
|
|
border-radius: 8px;
|
|
text-align: center;
|
|
font-size: 28px;
|
|
font-weight: 700;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.more-events {
|
|
text-align: center;
|
|
font-size: 24px;
|
|
font-weight: 600;
|
|
padding: 15px;
|
|
margin-top: 10px;
|
|
background: rgba(255, 255, 255, 0.15);
|
|
border-radius: 6px;
|
|
color: #eaeaea;
|
|
font-style: italic;
|
|
}
|
|
|
|
/* Recognition carousel styles */
|
|
.recognition-section {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.section-title.recognition {
|
|
background: #0d6efd;
|
|
color: #fff;
|
|
box-shadow: 0 4px 20px rgba(13, 110, 253, 0.4);
|
|
}
|
|
|
|
.recognition-carousel-container {
|
|
position: relative;
|
|
overflow: hidden;
|
|
width: 100%;
|
|
}
|
|
|
|
.recognition-carousel-wrapper {
|
|
position: relative;
|
|
width: 100%;
|
|
min-height: 150px;
|
|
}
|
|
|
|
.recognition-card {
|
|
background: linear-gradient(135deg, #1e3a5f 0%, #0d2137 100%);
|
|
border: 3px solid #0d6efd;
|
|
border-radius: 12px;
|
|
padding: 25px 30px;
|
|
box-shadow: 0 4px 20px rgba(13, 110, 253, 0.3);
|
|
transition: transform 0.8s ease-in-out, opacity 0.8s ease-in-out;
|
|
width: 100%;
|
|
}
|
|
|
|
.recognition-card:not(.active) {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
}
|
|
|
|
.recognition-card.active {
|
|
transform: translateY(0);
|
|
opacity: 1;
|
|
position: relative;
|
|
}
|
|
|
|
.recognition-card.exit-up {
|
|
transform: translateY(-100%);
|
|
opacity: 0;
|
|
}
|
|
|
|
.recognition-card.enter-down {
|
|
transform: translateY(100%);
|
|
opacity: 0;
|
|
}
|
|
|
|
.recognition-header {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.recognition-star {
|
|
font-size: 48px;
|
|
color: #ffc107;
|
|
margin-right: 20px;
|
|
text-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
|
|
animation: starPulse 2s ease-in-out infinite;
|
|
}
|
|
|
|
@keyframes starPulse {
|
|
0%, 100% { transform: scale(1); }
|
|
50% { transform: scale(1.1); }
|
|
}
|
|
|
|
.recognition-employee {
|
|
font-size: 32px;
|
|
font-weight: 700;
|
|
color: #fff;
|
|
}
|
|
|
|
.recognition-achievement {
|
|
font-size: 24px;
|
|
color: #ccc;
|
|
line-height: 1.4;
|
|
margin-left: 68px;
|
|
}
|
|
|
|
.recognition-counter {
|
|
position: absolute;
|
|
top: 15px;
|
|
right: 20px;
|
|
background: rgba(0, 0, 0, 0.5);
|
|
padding: 5px 12px;
|
|
border-radius: 15px;
|
|
font-size: 14px;
|
|
color: #fff;
|
|
}
|
|
|
|
.recognition-dots {
|
|
text-align: center;
|
|
margin-top: 15px;
|
|
}
|
|
|
|
.recognition-dots .dot {
|
|
display: inline-block;
|
|
width: 10px;
|
|
height: 10px;
|
|
background: #444;
|
|
border-radius: 50%;
|
|
margin: 0 5px;
|
|
}
|
|
|
|
.recognition-dots .dot.active {
|
|
background: #0d6efd;
|
|
}
|
|
|
|
/* Upcoming events carousel */
|
|
.upcoming-carousel-container {
|
|
position: relative;
|
|
overflow: hidden;
|
|
width: 100%;
|
|
}
|
|
|
|
.upcoming-carousel-wrapper {
|
|
position: relative;
|
|
width: 100%;
|
|
min-height: 200px;
|
|
}
|
|
|
|
.event-card.upcoming.carousel-item {
|
|
width: 100%;
|
|
transition: transform 0.8s ease-in-out, opacity 0.8s ease-in-out;
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.event-card.upcoming.carousel-item:not(.active) {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
}
|
|
|
|
.event-card.upcoming.carousel-item.active {
|
|
transform: translateY(0);
|
|
opacity: 1;
|
|
position: relative;
|
|
}
|
|
|
|
.event-card.upcoming.carousel-item.exit-up {
|
|
transform: translateY(-100%);
|
|
opacity: 0;
|
|
}
|
|
|
|
.event-card.upcoming.carousel-item.enter-down {
|
|
transform: translateY(100%);
|
|
opacity: 0;
|
|
}
|
|
|
|
/* ============================================ */
|
|
/* RESPONSIVE SIZING FOR LOW-RES DISPLAYS (720p) */
|
|
/* ============================================ */
|
|
@media screen and (max-height: 900px) {
|
|
.container {
|
|
padding: 15px 30px;
|
|
padding-bottom: 70px;
|
|
}
|
|
|
|
.header {
|
|
gap: 20px;
|
|
margin-bottom: 15px;
|
|
padding-bottom: 10px;
|
|
}
|
|
|
|
.logo-container img {
|
|
height: 50px;
|
|
}
|
|
|
|
.fiscal-week {
|
|
font-size: 10px;
|
|
}
|
|
|
|
.location-title {
|
|
font-size: 12px;
|
|
}
|
|
|
|
.header-center h1 {
|
|
font-size: 18px;
|
|
}
|
|
|
|
.clock {
|
|
font-size: 14px;
|
|
}
|
|
|
|
.filter-label {
|
|
font-size: 10px;
|
|
}
|
|
|
|
.filter-select {
|
|
padding: 6px 10px;
|
|
font-size: 12px;
|
|
min-width: 140px;
|
|
}
|
|
|
|
.connection-status {
|
|
padding: 4px 10px;
|
|
font-size: 10px;
|
|
gap: 4px;
|
|
}
|
|
|
|
.status-dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
}
|
|
|
|
.section-title {
|
|
font-size: 14px;
|
|
margin-bottom: 5px;
|
|
padding: 4px 8px;
|
|
}
|
|
|
|
.events-grid {
|
|
gap: 8px;
|
|
}
|
|
|
|
.event-card {
|
|
padding: 10px 12px;
|
|
margin-bottom: 5px;
|
|
border-left: 35px solid;
|
|
}
|
|
|
|
.resolved-indicator {
|
|
left: -35px;
|
|
width: 35px;
|
|
font-size: 12px;
|
|
letter-spacing: -2px;
|
|
}
|
|
|
|
.event-header {
|
|
min-height: 20px;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.event-title {
|
|
font-size: 16px;
|
|
}
|
|
|
|
.event-ticket {
|
|
font-size: 12px;
|
|
padding: 3px 8px;
|
|
}
|
|
|
|
.event-time {
|
|
font-size: 13px;
|
|
}
|
|
|
|
.footer {
|
|
padding: 8px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.no-events {
|
|
font-size: 18px;
|
|
padding: 20px 15px;
|
|
}
|
|
|
|
.loading {
|
|
font-size: 18px;
|
|
padding: 20px 15px;
|
|
}
|
|
|
|
.error-message {
|
|
font-size: 16px;
|
|
padding: 20px;
|
|
}
|
|
|
|
.more-events {
|
|
font-size: 14px;
|
|
padding: 10px;
|
|
}
|
|
|
|
.recognition-card {
|
|
padding: 15px 20px;
|
|
}
|
|
|
|
.recognition-star {
|
|
font-size: 28px;
|
|
margin-right: 12px;
|
|
}
|
|
|
|
.recognition-employee {
|
|
font-size: 18px;
|
|
}
|
|
|
|
.recognition-achievement {
|
|
font-size: 14px;
|
|
margin-left: 40px;
|
|
}
|
|
|
|
.recognition-counter {
|
|
font-size: 10px;
|
|
padding: 3px 8px;
|
|
}
|
|
|
|
.recognition-carousel-wrapper {
|
|
min-height: 100px;
|
|
}
|
|
}
|
|
|
|
/* ============================================ */
|
|
/* RESPONSIVE SIZING FOR 4K DISPLAYS */
|
|
/* ============================================ */
|
|
@media screen and (min-width: 2560px) {
|
|
.container {
|
|
padding: 40px 80px;
|
|
padding-bottom: 120px;
|
|
}
|
|
|
|
.header {
|
|
gap: 60px;
|
|
margin-bottom: 50px;
|
|
padding-bottom: 30px;
|
|
}
|
|
|
|
.logo-container img {
|
|
height: 180px;
|
|
}
|
|
|
|
.fiscal-week {
|
|
font-size: 36px;
|
|
}
|
|
|
|
.location-title {
|
|
font-size: 40px;
|
|
}
|
|
|
|
.header-center h1 {
|
|
font-size: 84px;
|
|
}
|
|
|
|
.clock {
|
|
font-size: 56px;
|
|
}
|
|
|
|
.connection-status {
|
|
padding: 20px 35px;
|
|
font-size: 32px;
|
|
gap: 15px;
|
|
}
|
|
|
|
.status-dot {
|
|
width: 20px;
|
|
height: 20px;
|
|
}
|
|
|
|
.section-title {
|
|
font-size: 72px;
|
|
margin-bottom: 30px;
|
|
padding: 24px 50px;
|
|
}
|
|
|
|
.events-grid {
|
|
gap: 30px;
|
|
}
|
|
|
|
.event-card {
|
|
padding: 60px 80px;
|
|
margin-bottom: 0;
|
|
border-left: 100px solid;
|
|
}
|
|
|
|
.resolved-indicator {
|
|
left: -100px;
|
|
width: 100px;
|
|
font-size: 40px;
|
|
letter-spacing: 5px;
|
|
}
|
|
|
|
.event-header {
|
|
min-height: 90px;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.event-title {
|
|
font-size: 80px;
|
|
}
|
|
|
|
.event-ticket {
|
|
font-size: 56px;
|
|
padding: 18px 44px;
|
|
}
|
|
|
|
.event-ticket:hover {
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
.event-time {
|
|
font-size: 54px;
|
|
}
|
|
|
|
.footer {
|
|
padding: 24px;
|
|
font-size: 36px;
|
|
}
|
|
|
|
.no-events {
|
|
font-size: 64px;
|
|
padding: 80px 60px;
|
|
}
|
|
|
|
.loading {
|
|
font-size: 64px;
|
|
padding: 80px 60px;
|
|
}
|
|
|
|
.error-message {
|
|
font-size: 56px;
|
|
padding: 60px;
|
|
}
|
|
|
|
.more-events {
|
|
font-size: 48px;
|
|
padding: 30px;
|
|
}
|
|
|
|
.recognition-card {
|
|
padding: 50px 60px;
|
|
}
|
|
|
|
.recognition-star {
|
|
font-size: 96px;
|
|
margin-right: 40px;
|
|
}
|
|
|
|
.recognition-employee {
|
|
font-size: 64px;
|
|
}
|
|
|
|
.recognition-achievement {
|
|
font-size: 48px;
|
|
margin-left: 136px;
|
|
}
|
|
|
|
.recognition-counter {
|
|
font-size: 28px;
|
|
padding: 10px 24px;
|
|
}
|
|
|
|
.recognition-carousel-wrapper {
|
|
min-height: 300px;
|
|
}
|
|
|
|
.recognition-dots .dot {
|
|
width: 20px;
|
|
height: 20px;
|
|
margin: 0 10px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<div class="logo-container">
|
|
<img src="ge-aerospace-logo.svg" alt="GE Aerospace">
|
|
</div>
|
|
<div class="header-center">
|
|
<div class="fiscal-week" id="fiscalWeek"></div>
|
|
<h1>West Jefferson Events</h1>
|
|
</div>
|
|
<div class="filter-container">
|
|
<div class="clock" id="clock"></div>
|
|
<div>
|
|
<label for="businessUnitFilter" class="filter-label">Business Unit:</label>
|
|
<select id="businessUnitFilter" class="filter-select">
|
|
<option value="">All Units</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="connection-status connected" id="connectionStatus">
|
|
<div class="status-dot"></div>
|
|
<span>LIVE</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="eventsContainer">
|
|
<div class="loading">Loading events...</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer">
|
|
Last updated: <span id="lastUpdate">--:--:--</span> | Refreshing every 10 seconds
|
|
</div>
|
|
|
|
<script>
|
|
let isConnected = true;
|
|
let updateInterval;
|
|
let clockInterval;
|
|
let selectedBusinessUnit = '';
|
|
let businessUnitsLoaded = false;
|
|
let upcomingEvents = [];
|
|
let currentUpcomingIndex = 0;
|
|
let upcomingCarouselInterval = null;
|
|
let isTransitioning = false;
|
|
let pendingDataRender = null;
|
|
|
|
// Recognition carousel state
|
|
let recognitionEvents = [];
|
|
let currentRecognitionIndex = 0;
|
|
let recognitionCarouselInterval = null;
|
|
let isRecognitionTransitioning = false;
|
|
|
|
// Get business unit from URL parameter
|
|
function getBusinessUnitFromURL() {
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
return urlParams.get('businessunit') || '';
|
|
}
|
|
|
|
// Calculate ISO week number
|
|
// ISO week 1 is the week containing the first Thursday of the year (or Jan 4th)
|
|
// Weeks start on Monday
|
|
function getFiscalWeek() {
|
|
const today = new Date();
|
|
|
|
// Find Thursday of current week (ISO weeks are identified by their Thursday)
|
|
const dayOfWeek = (today.getDay() + 6) % 7; // 0=Monday, 6=Sunday
|
|
const thursday = new Date(today);
|
|
thursday.setDate(today.getDate() - dayOfWeek + 3);
|
|
|
|
// The year of the Thursday determines the ISO year
|
|
const isoYear = thursday.getFullYear();
|
|
|
|
// Find January 4th of that year (always in week 1)
|
|
const jan4 = new Date(isoYear, 0, 4);
|
|
|
|
// Find Monday of the week containing Jan 4 (start of week 1)
|
|
const jan4DayOfWeek = (jan4.getDay() + 6) % 7;
|
|
const week1Start = new Date(jan4);
|
|
week1Start.setDate(jan4.getDate() - jan4DayOfWeek);
|
|
|
|
// Calculate week number
|
|
const diffTime = today - week1Start;
|
|
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
|
|
const fiscalWeek = Math.floor(diffDays / 7) + 1;
|
|
|
|
return fiscalWeek;
|
|
}
|
|
|
|
// Update fiscal week display
|
|
function updateFiscalWeek() {
|
|
const fiscalWeek = getFiscalWeek();
|
|
document.getElementById('fiscalWeek').textContent = 'Fiscal Week ' + fiscalWeek;
|
|
}
|
|
|
|
// Update clock and fiscal week
|
|
function updateClock() {
|
|
const now = new Date();
|
|
const timeString = now.toLocaleString('en-US', {
|
|
weekday: 'short',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
year: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
second: '2-digit'
|
|
});
|
|
document.getElementById('clock').textContent = timeString;
|
|
updateFiscalWeek();
|
|
}
|
|
|
|
// Update connection status indicator
|
|
function setConnectionStatus(connected) {
|
|
isConnected = connected;
|
|
const statusEl = document.getElementById('connectionStatus');
|
|
if (connected) {
|
|
statusEl.className = 'connection-status connected';
|
|
statusEl.innerHTML = '<div class="status-dot"></div><span>LIVE</span>';
|
|
} else {
|
|
statusEl.className = 'connection-status disconnected';
|
|
statusEl.innerHTML = '<div class="status-dot"></div><span>RECONNECTING...</span>';
|
|
}
|
|
}
|
|
|
|
// Format date/time for display
|
|
function formatDateTime(datetime) {
|
|
const date = new Date(datetime);
|
|
return date.toLocaleString('en-US', {
|
|
weekday: 'short',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
year: 'numeric',
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
hour12: true
|
|
});
|
|
}
|
|
|
|
// Render events on the page (with smart delay during transitions)
|
|
function renderEvents(data) {
|
|
// If carousel is mid-transition, delay the render
|
|
if (isTransitioning) {
|
|
console.log('Carousel: Transition in progress, delaying render by 800ms');
|
|
pendingDataRender = data;
|
|
return;
|
|
}
|
|
|
|
const container = document.getElementById('eventsContainer');
|
|
let html = '';
|
|
|
|
// Separate Recognition events from other current events
|
|
const recognitions = data.current ? data.current.filter(e => e.typecolor === 'recognition') : [];
|
|
const otherCurrentEvents = data.current ? data.current.filter(e => e.typecolor !== 'recognition') : [];
|
|
|
|
// Current Events - show all in grid layout (excluding Recognition) - FIRST priority
|
|
if (otherCurrentEvents.length > 0) {
|
|
// Split into active and resolved events
|
|
const activeEvents = otherCurrentEvents.filter(e => !e.resolved);
|
|
const resolvedEvents = otherCurrentEvents.filter(e => e.resolved);
|
|
|
|
// Sort function: by type priority (Incident > Change > Awareness > TBD), then by date (earliest first)
|
|
const typePriority = {
|
|
'Incident': 1,
|
|
'Change': 2,
|
|
'Awareness': 3,
|
|
'Recognition': 4,
|
|
'TBD': 5
|
|
};
|
|
|
|
const sortByTypeAndDate = (a, b) => {
|
|
// First, sort by type priority
|
|
const priorityA = typePriority[a.typename] || 999;
|
|
const priorityB = typePriority[b.typename] || 999;
|
|
|
|
if (priorityA !== priorityB) {
|
|
return priorityA - priorityB;
|
|
}
|
|
|
|
// If same type, sort by start time (earliest first)
|
|
const dateA = new Date(a.starttime);
|
|
const dateB = new Date(b.starttime);
|
|
return dateA - dateB;
|
|
};
|
|
|
|
// Sort both active and resolved events
|
|
activeEvents.sort(sortByTypeAndDate);
|
|
resolvedEvents.sort(sortByTypeAndDate);
|
|
|
|
// Combine with active first, resolved last
|
|
const sortedEvents = [...activeEvents, ...resolvedEvents];
|
|
|
|
// Determine badge color based on highest severity
|
|
const severity = getHighestSeverity(data.current);
|
|
|
|
html += '<div class="events-section">';
|
|
html += `<div class="section-title current severity-${severity}">CURRENT EVENTS</div>`;
|
|
|
|
// Determine grid class based on number of events
|
|
const gridClass = sortedEvents.length === 1 ? 'single' : 'multi';
|
|
html += `<div class="events-grid ${gridClass}">`;
|
|
|
|
sortedEvents.forEach(event => {
|
|
const borderColor = getColorFromType(event.typecolor);
|
|
const ticketBadge = event.ticketnumber
|
|
? `<a href="${getServiceNowUrl(event.ticketnumber)}" target="_blank" class="event-ticket">${escapeHtml(event.ticketnumber)}</a>`
|
|
: '';
|
|
const resolvedIndicator = event.resolved ? '<div class="resolved-indicator">RESOLVED</div>' : '';
|
|
|
|
const endTimeText = event.resolved
|
|
? `<br><strong>Resolved:</strong> ${formatDateTime(event.endtime)}`
|
|
: event.endtime ? `<br><strong>Ends:</strong> ${formatDateTime(event.endtime)}` : '<br><strong>Status:</strong> Ongoing (no end time)';
|
|
|
|
// Calculate progressive fade for resolved incidents (fade over 30 minutes)
|
|
let opacity = 1.0;
|
|
let resolvedClass = '';
|
|
if (event.resolved && event.minutes_since_end !== null && event.minutes_since_end !== undefined) {
|
|
// Fade from 1.0 to 0.5 over 30 minutes, then drop off
|
|
opacity = Math.max(0.5, 1.0 - (event.minutes_since_end / 30) * 0.5);
|
|
resolvedClass = ' resolved';
|
|
}
|
|
|
|
html += `
|
|
<div class="event-card current${resolvedClass}" style="border-left-color: ${borderColor}; opacity: ${opacity};">
|
|
${resolvedIndicator}
|
|
<div>${ticketBadge}</div>
|
|
<div class="event-header">
|
|
<div class="event-title">${escapeHtml(event.notification)}</div>
|
|
</div>
|
|
<div class="event-time">
|
|
<strong>Started:</strong> ${formatDateTime(event.starttime)}${endTimeText}
|
|
</div>
|
|
</div>
|
|
`;
|
|
});
|
|
|
|
html += '</div>'; // Close grid
|
|
html += '</div>'; // Close section
|
|
}
|
|
|
|
// Recognition Carousel Section - AFTER current events, BEFORE upcoming
|
|
if (recognitions.length > 0) {
|
|
recognitionEvents = recognitions;
|
|
|
|
// Preserve current index if valid
|
|
if (currentRecognitionIndex >= recognitions.length) {
|
|
currentRecognitionIndex = 0;
|
|
}
|
|
|
|
html += '<div class="recognition-section">';
|
|
html += '<div class="section-title recognition">EMPLOYEE RECOGNITION</div>';
|
|
html += '<div class="recognition-carousel-container">';
|
|
html += '<div class="recognition-carousel-wrapper" id="recognitionCarousel">';
|
|
|
|
recognitions.forEach((event, index) => {
|
|
const activeClass = index === currentRecognitionIndex ? 'active' : 'enter-down';
|
|
const displayName = event.employeename || event.employeesso || 'Employee';
|
|
console.log('Recognition event:', event);
|
|
console.log('employeename:', event.employeename, 'employeesso:', event.employeesso, 'displayName:', displayName);
|
|
html += `
|
|
<div class="recognition-card ${activeClass}" data-index="${index}">
|
|
${recognitions.length > 1 ? `<div class="recognition-counter">${index + 1} of ${recognitions.length}</div>` : ''}
|
|
<div class="recognition-header">
|
|
<span class="recognition-star">★</span>
|
|
<span class="recognition-employee">${escapeHtml(displayName)}</span>
|
|
</div>
|
|
<div class="recognition-achievement">${escapeHtml(event.notification)}</div>
|
|
</div>
|
|
`;
|
|
});
|
|
|
|
html += '</div>'; // Close carousel wrapper
|
|
|
|
// Add dots if multiple recognitions
|
|
if (recognitions.length > 1) {
|
|
html += '<div class="recognition-dots">';
|
|
recognitions.forEach((_, index) => {
|
|
html += `<span class="dot ${index === currentRecognitionIndex ? 'active' : ''}" data-index="${index}"></span>`;
|
|
});
|
|
html += '</div>';
|
|
}
|
|
|
|
html += '</div>'; // Close carousel container
|
|
html += '</div>'; // Close section
|
|
} else {
|
|
recognitionEvents = [];
|
|
}
|
|
|
|
// Upcoming Events - carousel with slide-up transition
|
|
if (data.upcoming && data.upcoming.length > 0) {
|
|
// Sort upcoming events by type priority, then by date
|
|
const typePriority = {
|
|
'Incident': 1,
|
|
'Change': 2,
|
|
'Awareness': 3,
|
|
'Recognition': 4,
|
|
'TBD': 5
|
|
};
|
|
|
|
const sortedUpcoming = [...data.upcoming].sort((a, b) => {
|
|
// First, sort by type priority
|
|
const priorityA = typePriority[a.typename] || 999;
|
|
const priorityB = typePriority[b.typename] || 999;
|
|
|
|
if (priorityA !== priorityB) {
|
|
return priorityA - priorityB;
|
|
}
|
|
|
|
// If same type, sort by start time (earliest first)
|
|
const dateA = new Date(a.starttime);
|
|
const dateB = new Date(b.starttime);
|
|
return dateA - dateB;
|
|
});
|
|
|
|
// Store for carousel
|
|
upcomingEvents = sortedUpcoming;
|
|
|
|
// Preserve current index if it's still valid, otherwise reset
|
|
if (currentUpcomingIndex >= sortedUpcoming.length) {
|
|
console.log(`Carousel: Index ${currentUpcomingIndex} out of range, resetting to 0`);
|
|
currentUpcomingIndex = 0;
|
|
} else {
|
|
console.log(`Carousel: Preserving index ${currentUpcomingIndex} across refresh`);
|
|
}
|
|
|
|
html += '<div class="events-section">';
|
|
html += '<div class="section-title upcoming">UPCOMING (Next 5 Days)</div>';
|
|
html += '<div class="upcoming-carousel-container">';
|
|
html += '<div class="upcoming-carousel-wrapper" id="upcomingCarousel">';
|
|
|
|
// Render all upcoming events (preserve current active index)
|
|
sortedUpcoming.forEach((event, index) => {
|
|
const borderColor = getColorFromType(event.typecolor);
|
|
const ticketBadge = event.ticketnumber
|
|
? `<a href="${getServiceNowUrl(event.ticketnumber)}" target="_blank" class="event-ticket">${escapeHtml(event.ticketnumber)}</a>`
|
|
: '';
|
|
const activeClass = index === currentUpcomingIndex ? 'active' : 'enter-down';
|
|
html += `
|
|
<div class="event-card upcoming carousel-item ${activeClass}" data-index="${index}" style="border-left-color: ${borderColor};">
|
|
<div>${ticketBadge}</div>
|
|
<div class="event-header">
|
|
<div class="event-title">${escapeHtml(event.notification)}</div>
|
|
</div>
|
|
<div class="event-time">
|
|
<strong>Starts:</strong> ${formatDateTime(event.starttime)}
|
|
${event.endtime ? `<br><strong>Ends:</strong> ${formatDateTime(event.endtime)}` : ''}
|
|
</div>
|
|
</div>
|
|
`;
|
|
});
|
|
|
|
html += '</div>'; // Close carousel wrapper
|
|
html += '</div>'; // Close carousel container
|
|
html += '</div>'; // Close section
|
|
}
|
|
|
|
// No events message
|
|
if ((!data.current || data.current.length === 0) && (!data.upcoming || data.upcoming.length === 0)) {
|
|
html += '<div class="no-events">No scheduled events for the next 5 days</div>';
|
|
}
|
|
|
|
container.innerHTML = html;
|
|
|
|
// Start carousels if there are events
|
|
if (upcomingEvents.length > 1) {
|
|
startUpcomingCarousel();
|
|
} else {
|
|
stopUpcomingCarousel();
|
|
}
|
|
|
|
// Start recognition carousel if there are multiple recognitions
|
|
if (recognitionEvents.length > 1) {
|
|
startRecognitionCarousel();
|
|
} else {
|
|
stopRecognitionCarousel();
|
|
}
|
|
}
|
|
|
|
// Start the upcoming events carousel
|
|
function startUpcomingCarousel() {
|
|
console.log(`Carousel: Starting carousel with ${upcomingEvents.length} events`);
|
|
|
|
// Clear any existing interval
|
|
stopUpcomingCarousel();
|
|
|
|
// Start new interval (5 seconds)
|
|
upcomingCarouselInterval = setInterval(rotateUpcomingEvent, 5000);
|
|
console.log('Carousel: Interval set for 5 seconds');
|
|
}
|
|
|
|
// Stop the upcoming events carousel
|
|
function stopUpcomingCarousel() {
|
|
if (upcomingCarouselInterval) {
|
|
clearInterval(upcomingCarouselInterval);
|
|
upcomingCarouselInterval = null;
|
|
}
|
|
}
|
|
|
|
// Rotate to next upcoming event
|
|
function rotateUpcomingEvent() {
|
|
if (upcomingEvents.length <= 1) {
|
|
console.log('Carousel: Not enough events to rotate');
|
|
return;
|
|
}
|
|
|
|
const carousel = document.getElementById('upcomingCarousel');
|
|
if (!carousel) {
|
|
console.log('Carousel: Carousel element not found');
|
|
return;
|
|
}
|
|
|
|
const items = carousel.querySelectorAll('.carousel-item');
|
|
if (items.length === 0) {
|
|
console.log('Carousel: No carousel items found');
|
|
return;
|
|
}
|
|
|
|
console.log(`Carousel: Rotating from index ${currentUpcomingIndex} to ${(currentUpcomingIndex + 1) % upcomingEvents.length} (${items.length} total items)`);
|
|
|
|
// Mark transition as active
|
|
isTransitioning = true;
|
|
|
|
const currentItem = items[currentUpcomingIndex];
|
|
const nextIndex = (currentUpcomingIndex + 1) % upcomingEvents.length;
|
|
const nextItem = items[nextIndex];
|
|
|
|
// Slide current item up and out
|
|
currentItem.classList.remove('active');
|
|
currentItem.classList.add('exit-up');
|
|
|
|
// Slide next item up from bottom
|
|
nextItem.classList.remove('enter-down');
|
|
nextItem.classList.add('active');
|
|
|
|
// After transition, reset the exited item for next rotation
|
|
setTimeout(() => {
|
|
currentItem.classList.remove('exit-up');
|
|
currentItem.classList.add('enter-down');
|
|
|
|
// Mark transition as complete
|
|
isTransitioning = false;
|
|
|
|
// If there's pending data to render, render it now
|
|
if (pendingDataRender) {
|
|
console.log('Carousel: Transition complete, rendering pending data');
|
|
const dataToRender = pendingDataRender;
|
|
pendingDataRender = null;
|
|
renderEvents(dataToRender);
|
|
}
|
|
}, 800); // Match transition duration
|
|
|
|
currentUpcomingIndex = nextIndex;
|
|
}
|
|
|
|
// Start the recognition carousel
|
|
function startRecognitionCarousel() {
|
|
console.log(`Recognition Carousel: Starting with ${recognitionEvents.length} recognitions`);
|
|
|
|
// Clear any existing interval
|
|
stopRecognitionCarousel();
|
|
|
|
// Start new interval (5 seconds)
|
|
recognitionCarouselInterval = setInterval(rotateRecognitionEvent, 5000);
|
|
}
|
|
|
|
// Stop the recognition carousel
|
|
function stopRecognitionCarousel() {
|
|
if (recognitionCarouselInterval) {
|
|
clearInterval(recognitionCarouselInterval);
|
|
recognitionCarouselInterval = null;
|
|
}
|
|
}
|
|
|
|
// Rotate to next recognition
|
|
function rotateRecognitionEvent() {
|
|
if (recognitionEvents.length <= 1) {
|
|
return;
|
|
}
|
|
|
|
const carousel = document.getElementById('recognitionCarousel');
|
|
if (!carousel) {
|
|
return;
|
|
}
|
|
|
|
const items = carousel.querySelectorAll('.recognition-card');
|
|
if (items.length === 0) {
|
|
return;
|
|
}
|
|
|
|
// Mark transition as active
|
|
isRecognitionTransitioning = true;
|
|
|
|
const currentItem = items[currentRecognitionIndex];
|
|
const nextIndex = (currentRecognitionIndex + 1) % recognitionEvents.length;
|
|
const nextItem = items[nextIndex];
|
|
|
|
// Slide current item up and out
|
|
currentItem.classList.remove('active');
|
|
currentItem.classList.add('exit-up');
|
|
|
|
// Slide next item up from bottom
|
|
nextItem.classList.remove('enter-down');
|
|
nextItem.classList.add('active');
|
|
|
|
// Update counter if present
|
|
const counter = nextItem.querySelector('.recognition-counter');
|
|
if (counter) {
|
|
counter.textContent = `${nextIndex + 1} of ${recognitionEvents.length}`;
|
|
}
|
|
|
|
// Update dots
|
|
const dots = document.querySelectorAll('.recognition-dots .dot');
|
|
dots.forEach((dot, i) => {
|
|
dot.classList.toggle('active', i === nextIndex);
|
|
});
|
|
|
|
// After transition, reset the exited item for next rotation
|
|
setTimeout(() => {
|
|
currentItem.classList.remove('exit-up');
|
|
currentItem.classList.add('enter-down');
|
|
isRecognitionTransitioning = false;
|
|
}, 800);
|
|
|
|
currentRecognitionIndex = nextIndex;
|
|
}
|
|
|
|
// Escape HTML to prevent XSS
|
|
function escapeHtml(text) {
|
|
const div = document.createElement('div');
|
|
div.textContent = text;
|
|
return div.innerHTML;
|
|
}
|
|
|
|
// Generate ServiceNow ticket URL
|
|
function getServiceNowUrl(ticketNumber) {
|
|
return 'https://geit.service-now.com/now/nav/ui/search/0f8b85d0c7922010099a308dc7c2606a/params/search-term/' +
|
|
encodeURIComponent(ticketNumber) +
|
|
'/global-search-data-config-id/c861cea2c7022010099a308dc7c26041/back-button-label/IT4IT%20Homepage/search-context/now%2Fnav%2Fui';
|
|
}
|
|
|
|
// Map Bootstrap color classes to hex colors
|
|
function getColorFromType(typecolor) {
|
|
const colorMap = {
|
|
'success': '#0ad64f', // Green (GE Avionics Green) - Awareness, TBD
|
|
'warning': '#ffc107', // Yellow - Change
|
|
'danger': '#dc3545', // Red - Incident
|
|
'recognition': '#0d6efd', // Blue - Recognition
|
|
'secondary': '#6c757d' // Gray - fallback
|
|
};
|
|
return colorMap[typecolor] || colorMap['secondary'];
|
|
}
|
|
|
|
// Determine highest severity level from events (for badge color)
|
|
function getHighestSeverity(events) {
|
|
// Severity hierarchy: danger > warning > success > secondary
|
|
let highestSeverity = 'secondary';
|
|
|
|
events.forEach(event => {
|
|
const severity = event.typecolor;
|
|
|
|
if (severity === 'danger') {
|
|
highestSeverity = 'danger'; // Highest priority
|
|
} else if (severity === 'warning' && highestSeverity !== 'danger') {
|
|
highestSeverity = 'warning';
|
|
} else if (severity === 'success' && highestSeverity !== 'danger' && highestSeverity !== 'warning') {
|
|
highestSeverity = 'success';
|
|
}
|
|
});
|
|
|
|
return highestSeverity;
|
|
}
|
|
|
|
// Load business units into dropdown
|
|
async function loadBusinessUnits() {
|
|
// Only load once
|
|
if (businessUnitsLoaded) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch('../apibusinessunits.asp');
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
const select = document.getElementById('businessUnitFilter');
|
|
|
|
// Clear existing options except the first "All Units" option
|
|
while (select.options.length > 1) {
|
|
select.remove(1);
|
|
}
|
|
|
|
data.businessunits.forEach(unit => {
|
|
const option = document.createElement('option');
|
|
option.value = unit.businessunitid;
|
|
option.textContent = unit.businessunit;
|
|
select.appendChild(option);
|
|
});
|
|
|
|
// Set the value from URL if present
|
|
const urlBusinessUnit = getBusinessUnitFromURL();
|
|
if (urlBusinessUnit) {
|
|
selectedBusinessUnit = urlBusinessUnit;
|
|
select.value = urlBusinessUnit;
|
|
}
|
|
|
|
businessUnitsLoaded = true;
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading business units:', error);
|
|
}
|
|
}
|
|
|
|
// Fetch notifications from API
|
|
async function fetchNotifications() {
|
|
try {
|
|
let url = '../apishopfloor.asp';
|
|
if (selectedBusinessUnit) {
|
|
url += '?businessunit=' + encodeURIComponent(selectedBusinessUnit);
|
|
}
|
|
const response = await fetch(url);
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
renderEvents(data);
|
|
updateLastUpdateTime();
|
|
setConnectionStatus(true);
|
|
} else {
|
|
throw new Error(data.error || 'Unknown error');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Error fetching notifications:', error);
|
|
setConnectionStatus(false);
|
|
|
|
// Show error message if first load
|
|
const container = document.getElementById('eventsContainer');
|
|
if (container.querySelector('.loading')) {
|
|
container.innerHTML = `
|
|
<div class="error-message">
|
|
Unable to load events<br>
|
|
<span style="font-size: 20px; margin-top: 10px; display: block;">Retrying...</span>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Update last update time
|
|
function updateLastUpdateTime() {
|
|
const now = new Date();
|
|
const timeString = now.toLocaleTimeString('en-US');
|
|
document.getElementById('lastUpdate').textContent = timeString;
|
|
}
|
|
|
|
// Initialize dashboard
|
|
async function init() {
|
|
// Display fiscal week
|
|
updateFiscalWeek();
|
|
|
|
// Start clock
|
|
updateClock();
|
|
clockInterval = setInterval(updateClock, 1000);
|
|
|
|
// Set business unit from URL BEFORE first fetch
|
|
selectedBusinessUnit = getBusinessUnitFromURL();
|
|
|
|
// Load business units dropdown (only once)
|
|
await loadBusinessUnits();
|
|
|
|
// Initial data fetch
|
|
fetchNotifications();
|
|
|
|
// Set up automatic refresh every 10 seconds
|
|
updateInterval = setInterval(fetchNotifications, 10000);
|
|
}
|
|
|
|
// Handle page visibility changes (pause updates when hidden)
|
|
document.addEventListener('visibilitychange', function() {
|
|
if (document.hidden) {
|
|
clearInterval(updateInterval);
|
|
clearInterval(clockInterval);
|
|
stopUpcomingCarousel();
|
|
stopRecognitionCarousel();
|
|
} else {
|
|
// Resume updates without reinitializing everything
|
|
updateClock();
|
|
clockInterval = setInterval(updateClock, 1000);
|
|
fetchNotifications();
|
|
updateInterval = setInterval(fetchNotifications, 10000);
|
|
// Carousel will restart in renderEvents when data loads
|
|
}
|
|
});
|
|
|
|
// Set up business unit filter event listener (only once)
|
|
document.getElementById('businessUnitFilter').addEventListener('change', (e) => {
|
|
selectedBusinessUnit = e.target.value;
|
|
|
|
// Update URL with selected business unit (without page reload)
|
|
const url = new URL(window.location);
|
|
if (selectedBusinessUnit) {
|
|
url.searchParams.set('businessunit', selectedBusinessUnit);
|
|
} else {
|
|
url.searchParams.delete('businessunit');
|
|
}
|
|
window.history.pushState({}, '', url);
|
|
|
|
fetchNotifications();
|
|
});
|
|
|
|
// Start the dashboard
|
|
init();
|
|
</script>
|
|
</body>
|
|
</html>
|