|
| 1 | +(function() { |
| 2 | + var BANNER_TEXT = ' **SYSTEM ALERT:** Scheduled maintenance for all services will occur this Saturday from 1 AM to 4 AM UTC. Expect minor downtime. 🚨'; |
| 3 | + var BANNER_BG_COLOR = '#ffcc00'; // Warning yellow |
| 4 | + var BANNER_TEXT_COLOR = '#333333'; |
| 5 | + |
| 6 | + // Check if the user has already dismissed this version of the banner |
| 7 | + var isDismissed = (g_preference.get(PREF_KEY) === 'true'); |
| 8 | + |
| 9 | + if (isDismissed) { |
| 10 | + return; |
| 11 | + } |
| 12 | + var banner = document.createElement('div'); |
| 13 | + banner.setAttribute('id', 'global_announcement_banner'); |
| 14 | + banner.innerHTML = BANNER_TEXT; |
| 15 | + banner.style.cssText = [ |
| 16 | + 'position: fixed;', |
| 17 | + 'top: 0;', |
| 18 | + 'left: 0;', |
| 19 | + 'width: 100%;', |
| 20 | + 'padding: 10px 40px 10px 15px;', // Added padding on the right for the close button |
| 21 | + 'background-color: ' + BANNER_BG_COLOR + ';', |
| 22 | + 'color: ' + BANNER_TEXT_COLOR + ';', |
| 23 | + 'z-index: 10000;', // High z-index to ensure it sits on top of everything |
| 24 | + 'text-align: center;', |
| 25 | + 'font-weight: bold;', |
| 26 | + 'box-shadow: 0 2px 5px rgba(0,0,0,0.2);' |
| 27 | + ].join(''); |
| 28 | + var closeButton = document.createElement('span'); |
| 29 | + closeButton.innerHTML = '×'; // Times symbol |
| 30 | + closeButton.style.cssText = [ |
| 31 | + 'position: absolute;', |
| 32 | + 'top: 50%;', |
| 33 | + 'right: 15px;', |
| 34 | + 'transform: translateY(-50%);', |
| 35 | + 'font-size: 20px;', |
| 36 | + 'cursor: pointer;', |
| 37 | + 'font-weight: normal;', |
| 38 | + 'line-height: 1;' |
| 39 | + ].join(''); |
| 40 | + |
| 41 | + closeButton.onclick = function() { |
| 42 | + // Remove the banner from the DOM |
| 43 | + banner.remove(); |
| 44 | + |
| 45 | + // Set the User Preference so the banner stays dismissed across sessions |
| 46 | + g_preference.set(PREF_KEY, 'true'); |
| 47 | + }; |
| 48 | + banner.appendChild(closeButton); |
| 49 | + document.body.appendChild(banner); |
| 50 | + |
| 51 | +})(); |
0 commit comments