Back to the lesson

Original working file

public/app.js

Code and working example pages keep their original identifiers and sample text. The lesson and file guidance explain them in your language.

import { BOOKING_URL } from "./config.js";
const a = document.querySelector("#booking"),
  status = document.querySelector("[role=status]");
try {
  const u = new URL(BOOKING_URL);
  if (
    u.protocol !== "https:" ||
    u.hostname !== "calendly.com" ||
    u.pathname.includes("YOUR-")
  )
    throw Error();
  a.href = u.href;
  a.hidden = false;
  status.textContent =
    "Booking opens on Calendly. Check the time zone before confirming.";
} catch {
  status.textContent = "Set your own public event link in config.js first.";
}