Source — /var/www/sites/twin-fin/js/hours.js

/var/www/sites/twin-fin/js/hours.js

/* =============================================================
   ✏️  TWIN FIN — OPENING HOURS
   =============================================================
   Edit ONLY this file to update hours across the whole website.
   Changes here automatically update every page (nav, homepage,
   about page, footer, contact page — everywhere).
   ============================================================= */

const TWIN_FIN_HOURS = [
  { day: "Monday",    open: "11:00am", close: "8:00pm"  },
  { day: "Tuesday",   open: "11:00am", close: "8:00pm"  },
  { day: "Wednesday", open: "11:00am", close: "8:00pm"  },
  { day: "Thursday",  open: "11:00am", close: "8:30pm"  },
  { day: "Friday",    open: "11:00am", close: "9:00pm"  },
  { day: "Saturday",  open: "11:00am", close: "9:00pm"  },
  { day: "Sunday",    open: "11:00am", close: "8:00pm"  },
];

/* =============================================================
   HOW TO EDIT:
   - Change the open/close times above (use "11:00am" format)
   - To mark a day as closed, set: open: "Closed", close: ""
     e.g. { day: "Monday", open: "Closed", close: "" }
   - Save the file — all pages update instantly.
   ============================================================= */

// Compact footer summary (auto-generated from above)
function getFooterHours() {
  const lines = [];
  let i = 0;
  while (i < TWIN_FIN_HOURS.length) {
    const current = TWIN_FIN_HOURS[i];
    let j = i + 1;
    while (
      j < TWIN_FIN_HOURS.length &&
      TWIN_FIN_HOURS[j].open === current.open &&
      TWIN_FIN_HOURS[j].close === current.close
    ) j++;
    if (j - i === 1) {
      lines.push(`${current.day}: ${current.open} – ${current.close}`);
    } else {
      lines.push(`${current.day} – ${TWIN_FIN_HOURS[j-1].day}: ${current.open} – ${current.close}`);
    }
    i = j;
  }
  return lines.join('<br>');
}

// Render hours grid (homepage / about)
function renderHoursGrid(containerId) {
  const el = document.getElementById(containerId);
  if (!el) return;
  el.innerHTML = TWIN_FIN_HOURS.map(h => `
    <div class="hours-item">
      <div class="hours-item__day">${h.day}</div>
      <div class="hours-item__time">${h.open === 'Closed' ? 'Closed' : `${h.open} – ${h.close}`}</div>
    </div>
  `).join('');
}

// Render compact footer hours
function renderFooterHours(containerId) {
  const el = document.getElementById(containerId);
  if (!el) return;
  el.innerHTML = getFooterHours();
}

// Auto-run on page load
document.addEventListener('DOMContentLoaded', () => {
  renderHoursGrid('hours-grid');
  renderFooterHours('footer-hours');
  renderFooterHours('footer-hours-contact');
});