1// Copyright 2021-2026 Prosopo (UK) Ltd. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15/** 16 * Manages dismissable banner functionality 17 */ 18class DismissableBanner { 19 constructor(elementId, storageKey) { 20 this.element = document.getElementById(elementId); 21 this.storageKey = storageKey; 22 23 if (!this.element) { 24 throw new Error(`Element with id "${elementId}" not found`); 25 } 26 } 27 28 /** 29 * Initialize the dismissable banner 30 */ 31 initialize() { 32 // Check if banner was previously dismissed 33 if (this.isDismissed()) { 34 this.hide(); 35 return; 36 } 37 38 // Find and setup dismiss button 39 const dismissButton = this.element.querySelector('[data-dismiss="banner"]'); 40 if (dismissButton) { 41 dismissButton.addEventListener("click", () => this.dismiss()); 42 } 43 44 this.show(); 45 } 46 47 /** 48 * Dismiss the banner and store the state 49 */ 50 dismiss() { 51 this.hide(); 52 localStorage.setItem(this.storageKey, "dismissed"); 53 } 54 55 /** 56 * Check if the banner was previously dismissed 57 */ 58 isDismissed() { 59 return localStorage.getItem(this.storageKey) === "dismissed"; 60 } 61 62 /** 63 * Hide the banner element 64 */ 65 hide() { 66 this.element.style.display = "none"; 67 } 68 69 /** 70 * Show the banner element 71 */ 72 show() { 73 this.element.style.display = "block"; 74 } 75} 76 77/** 78 * Initialize pricing alert banner when DOM is loaded 79 */ 80document.addEventListener("DOMContentLoaded", () => { 81 try { 82 const pricingAlert = new DismissableBanner( 83 "pricing-alert", 84 "pricing-alert-dismissed", 85 ); 86 pricingAlert.initialize(); 87 } catch (error) { 88 // Banner element might not exist on all pages, which is fine 89 console.debug("Pricing alert banner not found on this page"); 90 } 91});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.