<div class="bux-buckeye-alert__wrapper" role="region" aria-labelledby="buckeye-alert-title" hidden>
<div id="bux-buckeye-alert" class="bux-buckeye-alert" aria-label="Buckeye Alert" aria-live="polite" role="status" hidden>
</div>
</div>
<div class="bux-buckeye-alert__wrapper" role="region" aria-labelledby="buckeye-alert-title" hidden>
<div
id="bux-buckeye-alert"
class="bux-buckeye-alert"
aria-label="Buckeye Alert"
aria-live="polite"
role="status"
hidden>
</div>
</div>
site_name_prefix: Office of
site_name: Learning Relations Excellence
site_slogan: Additional text or site slogan
address_1: 100 Building Name
address_2: 1 Oval Mall
city: Columbus
state: OH
zip: '43210'
contact_email: email@osu.edu
contact_phone: 614-292-OHIO
contact_tty: 614-688-8605
.bux-buckeye-alert {
background-color: $scarlet;
padding: $sp-16 $sp-12;
h2 {
@include visually-hidden;
}
a {
@include link-base("scarlet", "no");
}
p {
color: $white;
font-family: $sans;
&:last-child {
margin-bottom: 0;
}
}
.bux-buckeye-alert-container {
display: flex;
.bux-buckeye-alert-container__icon {
line-height: 1;
margin-right: $sp-16;
&:after {
content: "\f623";
font-family: $icon;
font-size: $ts-md;
color: $white;
}
}
}
}
{
class BuckeyeAlert {
constructor(settings) {
this.settings = {
url: "https://www.osu.edu/feeds/emergency-alert.rss",
callback: () => {},
...settings,
};
this.element = document.getElementById("bux-buckeye-alert");
this.wrapper = document.getElementsByClassName("bux-buckeye-alert__wrapper")[0];
if (this.element) {
this.element.setAttribute("hidden", "");
}
if (this.wrapper) {
this.wrapper.setAttribute("hidden", "");
}
}
initialize() {
fetch(this.getURL())
.then((response) => response.text())
.then((xmlString) => new window.DOMParser().parseFromString(xmlString, "text/xml"))
.then((data) => {
const alerts = data.querySelectorAll("item");
if (alerts.length > 0) {
this.buildAlerts(alerts);
this.displayAlerts();
this.settings.callback();
}
})
.catch((error) => {
console.error("Error fetching Buckeye Alerts:", error);
});
}
getElement() {
return this.element;
}
getURL() {
return this.settings.url;
}
buildAlerts(alerts) {
const element = this.getElement();
const container = document.createElement("div");
const icon = document.createElement("div");
const heading = document.createElement("h2");
container.classList.add("bux-buckeye-alert-container");
icon.classList.add("bux-buckeye-alert-container__icon");
container.appendChild(icon);
container.appendChild(heading);
heading.id = "buckeye-alert-title";
heading.innerText = "Buckeye Alert Emergency Message";
alerts.forEach((alert) => {
const [, , description] = alert.children;
const { textContent: message } = description;
container.innerHTML += message;
});
element.appendChild(container);
}
displayAlerts() {
const element = this.getElement();
const wrapper = element.parentElement;
element.removeAttribute("hidden");
wrapper.removeAttribute("hidden");
}
}
}