PageSourceSearch

https://joshbegley.com/main.js

js joshbegley.com collected 2026-09-24 20:59:22 UTC 3,047 bytes, 89 lines download raw bytes

1/* ---- Section Navigation ---- */
2
3document.querySelectorAll(".floating-menu a").forEach(function (link) {
4  link.addEventListener("click", function (e) {
5    e.preventDefault();
6    var section = this.dataset.section;
7    document.querySelectorAll("[data-page]").forEach(function (el) {
8      el.style.display = el.dataset.page === section ? "" : "none";
9    });
10    document.querySelectorAll(".floating-menu a").forEach(function (a) {
11      a.classList.toggle("active", a.dataset.section === section);
12    });
13    window.scrollTo({ top: 0 });
14  });
15});
16
17/* ---- Video Lightbox ---- */
18
19function openLightbox(vimeoId, aspectRatio) {
20  var overlay = document.createElement("div");
21  overlay.className = "lightbox-overlay";
22
23  var vw = window.innerWidth;
24  var vh = window.innerHeight;
25  var mobile = vw <= 720;
26  var padW = mobile ? 0 : 80;
27  var padH = mobile ? 0 : 80;
28  var w = Math.min(vw - padW, 1100);
29  var h = w / aspectRatio;
30  if (h > vh - padH) { h = vh - padH; w = h * aspectRatio; }
31
32  var iframe = document.createElement("iframe");
33  iframe.className = "lightbox-content";
34  iframe.src = "https://player.vimeo.com/video/" + encodeURIComponent(vimeoId) + "?autoplay=1&title=0&byline=0&portrait=0";
35  iframe.allow = "autoplay; fullscreen";
36  iframe.allowFullscreen = true;
37  iframe.style.width = Math.round(w) + "px";
38  iframe.style.height = Math.round(h) + "px";
39  iframe.addEventListener("click", function (e) { e.stopPropagation(); });
40
41  var close = document.createElement("button");
42  close.className = "lightbox-close";
43  close.setAttribute("aria-label", "Close");
44  close.textContent = "\u2715";
45
46  overlay.appendChild(iframe);
47  overlay.appendChild(close);
48  document.body.appendChild(overlay);
49  document.body.style.overflow = "hidden";
50
51  function remove() {
52    overlay.remove();
53    document.body.style.overflow = "";
54    document.removeEventListener("keydown", onKey);
55  }
56  function onKey(e) { if (e.key === "Escape") remove(); }
57
58  overlay.addEventListener("click", remove);
59  close.addEventListener("click", remove);
60  document.addEventListener("keydown", onKey);
61}
62
63document.querySelectorAll("[data-lightbox]").forEach(function (btn) {
64  btn.addEventListener("click", function () {
65    openLightbox(this.dataset.lightbox, parseFloat(this.dataset.aspect) || 16 / 9);
66  });
67});
68
69/* ---- Vimeo Embeds (feed) ---- */
70
71document.querySelectorAll("[data-vimeo-embed]").forEach(function (el) {
72  var id = el.dataset.vimeoEmbed;
73  var aspect = parseFloat(el.dataset.aspect) || 56.25;
74  el.style.paddingTop = aspect + "%";
75  el.innerHTML = '<iframe src="https://player.vimeo.com/video/' +
76    encodeURIComponent(id) + '?dnt=1&title=0&byline=0&portrait=0" ' +
77    'allow="autoplay; fullscreen" allowfullscreen title="' +
78    el.dataset.title + '"></iframe>';
79});
80
81/* ---- Instagram Embed ---- */
82
83var igEl = document.querySelector(".instagram-embed");
84if (igEl) {
85  var script = document.createElement("script");
86  script.src = "https://www.instagram.com/embed.js";
87  script.async = true;
88  document.body.appendChild(script);
89}

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.