|
14 | 14 | statusApiUrl: 'https://status.opennetworked.org/api/status', // Placeholder API |
15 | 15 | animationDuration: 15000, // 15 seconds for marquee |
16 | 16 | checkInterval: 300000, // 5 minutes status check |
17 | | - position: 'bottom' // 'top' or 'bottom' |
| 17 | + position: 'top', // 'top' or 'bottom' |
| 18 | + insertMode: 'static' // 'static' (top of page) or 'fixed' (floating) |
18 | 19 | }; |
19 | 20 |
|
20 | 21 | // Global state |
|
159 | 160 | const createBannerStyles = () => { |
160 | 161 | const style = document.createElement('style'); |
161 | 162 | style.id = 'opennetwork-banner-styles'; |
| 163 | + |
| 164 | + const isStatic = CONFIG.insertMode === 'static'; |
| 165 | + |
162 | 166 | style.textContent = ` |
163 | 167 | .opennetwork-banner { |
164 | | - position: fixed; |
165 | | - ${CONFIG.position}: 0; |
166 | | - left: 0; |
167 | | - right: 0; |
| 168 | + ${isStatic ? 'position: relative; width: 100%;' : `position: fixed; ${CONFIG.position}: 0; left: 0; right: 0;`} |
168 | 169 | background: linear-gradient(135deg, #000000ff 0%, #000000ff 100%); |
169 | 170 | color: white; |
170 | 171 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; |
171 | 172 | font-size: 13px; |
172 | 173 | line-height: 1.4; |
173 | | - z-index: 999999; |
174 | | - box-shadow: ${CONFIG.position === 'bottom' ? '0 -2px 12px rgba(0,0,0,0.15)' : '0 2px 12px rgba(0,0,0,0.15)'}; |
175 | | - border-${CONFIG.position === 'bottom' ? 'top' : 'bottom'}: 1px solid rgba(255,255,255,0.1); |
| 174 | + ${isStatic ? '' : 'z-index: 999999;'} |
| 175 | + box-shadow: ${isStatic ? '0 2px 8px rgba(0,0,0,0.1)' : CONFIG.position === 'bottom' ? '0 -2px 12px rgba(0,0,0,0.15)' : '0 2px 12px rgba(0,0,0,0.15)'}; |
| 176 | + ${isStatic ? '' : `border-${CONFIG.position === 'bottom' ? 'top' : 'bottom'}: 1px solid rgba(255,255,255,0.1);`} |
176 | 177 | backdrop-filter: blur(10px); |
177 | 178 | -webkit-backdrop-filter: blur(10px); |
178 | 179 | transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); |
179 | | - padding: 8px 16px; |
180 | | - min-height: 40px; |
| 180 | + padding: 10px 16px; |
| 181 | + min-height: 44px; |
181 | 182 | display: flex; |
182 | 183 | align-items: center; |
| 184 | + ${isStatic ? 'margin: 0; border-bottom: 1px solid rgba(255,255,255,0.1);' : ''} |
183 | 185 | } |
184 | 186 | |
185 | 187 | .opennetwork-banner:hover { |
186 | | - background: linear-gradient(135deg, #000000ff 0%, #000000ff 100%); |
187 | | - transform: translateY(${CONFIG.position === 'bottom' ? '-1px' : '1px'}); |
| 188 | + background: linear-gradient(135deg, #1a1a1aff 0%, #1a1a1aff 100%); |
| 189 | + ${isStatic ? 'box-shadow: 0 4px 12px rgba(0,0,0,0.15);' : `transform: translateY(${CONFIG.position === 'bottom' ? '-1px' : '1px'});`} |
| 190 | + } |
| 191 | + |
| 192 | + ${isStatic ? ` |
| 193 | + body.opennetwork-banner-active { |
| 194 | + margin-top: 0 !important; |
| 195 | + padding-top: 0 !important; |
188 | 196 | } |
| 197 | + ` : ''} |
189 | 198 | |
190 | 199 | .on-banner-content { |
191 | 200 | display: flex; |
|
206 | 215 | } |
207 | 216 | |
208 | 217 | .on-flag-logo { |
209 | | - width: 20px; |
210 | | - height: 20px; |
| 218 | + width: 22px; |
| 219 | + height: 22px; |
211 | 220 | margin-right: 12px; |
212 | 221 | border-radius: 3px; |
213 | 222 | box-shadow: 0 2px 4px rgba(0,0,0,0.2); |
|
250 | 259 | display: flex; |
251 | 260 | align-items: center; |
252 | 261 | background: rgba(255,255,255,0.1); |
253 | | - padding: 4px 8px; |
| 262 | + padding: 6px 10px; |
254 | 263 | border-radius: 20px; |
255 | 264 | font-size: 12px; |
256 | 265 | font-weight: 500; |
|
289 | 298 | 50% { opacity: 0.7; } |
290 | 299 | } |
291 | 300 | |
292 | | - @keyframes slideIn { |
| 301 | + @keyframes slideInTop { |
| 302 | + from { |
| 303 | + opacity: 0; |
| 304 | + transform: translateY(-100%); |
| 305 | + } |
| 306 | + to { |
| 307 | + opacity: 1; |
| 308 | + transform: translateY(0); |
| 309 | + } |
| 310 | + } |
| 311 | + |
| 312 | + @keyframes slideInBottom { |
293 | 313 | from { |
294 | 314 | opacity: 0; |
295 | | - transform: translateY(${CONFIG.position === 'bottom' ? '100%' : '-100%'}); |
| 315 | + transform: translateY(100%); |
296 | 316 | } |
297 | 317 | to { |
298 | 318 | opacity: 1; |
|
301 | 321 | } |
302 | 322 | |
303 | 323 | .opennetwork-banner.on-animate-in { |
304 | | - animation: slideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards; |
| 324 | + animation: ${isStatic ? 'slideInTop' : CONFIG.position === 'bottom' ? 'slideInBottom' : 'slideInTop'} 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards; |
305 | 325 | } |
306 | 326 | |
307 | 327 | /* Responsive design */ |
308 | 328 | @media (max-width: 768px) { |
309 | 329 | .opennetwork-banner { |
310 | 330 | font-size: 12px; |
311 | | - padding: 6px 12px; |
312 | | - min-height: 36px; |
| 331 | + padding: 8px 12px; |
| 332 | + min-height: 40px; |
313 | 333 | } |
314 | 334 | |
315 | 335 | .on-flag-logo { |
316 | | - width: 16px; |
317 | | - height: 16px; |
| 336 | + width: 18px; |
| 337 | + height: 18px; |
318 | 338 | margin-right: 8px; |
319 | 339 | } |
320 | 340 | |
321 | 341 | .on-status { |
322 | 342 | font-size: 11px; |
323 | | - padding: 3px 6px; |
| 343 | + padding: 4px 8px; |
324 | 344 | } |
325 | 345 | |
326 | 346 | .on-left-section { |
|
331 | 351 | @media (max-width: 480px) { |
332 | 352 | .opennetwork-banner { |
333 | 353 | font-size: 11px; |
334 | | - padding: 5px 8px; |
| 354 | + padding: 6px 8px; |
| 355 | + min-height: 36px; |
335 | 356 | } |
336 | 357 | |
337 | 358 | .on-status-text { |
338 | 359 | display: none; |
339 | 360 | } |
340 | 361 | |
341 | 362 | .on-status { |
342 | | - width: 20px; |
343 | | - height: 20px; |
| 363 | + width: 24px; |
| 364 | + height: 24px; |
344 | 365 | justify-content: center; |
345 | 366 | padding: 0; |
346 | 367 | border-radius: 50%; |
|
371 | 392 | const styles = createBannerStyles(); |
372 | 393 | document.head.appendChild(styles); |
373 | 394 |
|
374 | | - // Add banner to body |
375 | | - document.body.appendChild(banner); |
| 395 | + // Insert banner based on mode |
| 396 | + if (CONFIG.insertMode === 'static') { |
| 397 | + // Insert at the very top of the page |
| 398 | + if (document.body.firstChild) { |
| 399 | + document.body.insertBefore(banner, document.body.firstChild); |
| 400 | + } else { |
| 401 | + document.body.appendChild(banner); |
| 402 | + } |
| 403 | + // Add body class for any additional styling needs |
| 404 | + document.body.classList.add('opennetwork-banner-active'); |
| 405 | + } else { |
| 406 | + // Add as floating banner (original behavior) |
| 407 | + document.body.appendChild(banner); |
| 408 | + } |
376 | 409 |
|
377 | 410 | // Setup event listeners |
378 | 411 | window.addEventListener('resize', checkTextOverflow); |
|
389 | 422 | updateStatusIndicator(newStatus.status, newStatus.message); |
390 | 423 | }, CONFIG.checkInterval); |
391 | 424 |
|
392 | | - console.log('OpenNetwork Banner initialized for:', domain); |
| 425 | + console.log('OpenNetwork Banner initialized for:', domain, `(${CONFIG.insertMode} mode)`); |
393 | 426 | }; |
394 | 427 |
|
395 | 428 | const destroyBanner = () => { |
|
398 | 431 | banner = null; |
399 | 432 | } |
400 | 433 |
|
| 434 | + // Remove body class if it was added |
| 435 | + document.body.classList.remove('opennetwork-banner-active'); |
| 436 | + |
401 | 437 | if (statusCheck) { |
402 | 438 | clearInterval(statusCheck); |
403 | 439 | statusCheck = null; |
|
0 commit comments