-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
70 lines (64 loc) · 2.6 KB
/
Copy pathmain.js
File metadata and controls
70 lines (64 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* Minimal site JS: obfuscated email assembly, footer year, work filters. */
(function () {
"use strict";
/* Email is assembled at runtime from fragments so the address never
appears as a scrapable string in the HTML or JS source. */
var u = ["kh", "anam", "mar", "50"].join("");
var d = ["hot", "mail"].join("") + "." + "com";
var addr = u + "@" + d;
document.querySelectorAll("[data-email-link]").forEach(function (a) {
a.setAttribute("href", "mailto:" + addr);
});
document.querySelectorAll("[data-email-text]").forEach(function (el) {
el.textContent = addr;
});
var year = document.querySelector("[data-year]");
if (year) year.textContent = new Date().getFullYear();
/* Credentials: certificate lightbox (vanilla, keyboard-dismissable). */
var showBtns = document.querySelectorAll(".show-cert[data-cert]");
if (showBtns.length) {
var overlay = document.createElement("div");
overlay.className = "lightbox";
overlay.setAttribute("role", "dialog");
overlay.setAttribute("aria-modal", "true");
overlay.hidden = true;
overlay.innerHTML = '<img alt=""><p class="lightbox-hint">Click anywhere or press Esc to close</p>';
document.body.appendChild(overlay);
var overlayImg = overlay.querySelector("img");
var lastFocus = null;
function closeBox() {
overlay.hidden = true;
document.body.style.overflow = "";
if (lastFocus) lastFocus.focus();
}
overlay.addEventListener("click", closeBox);
document.addEventListener("keydown", function (e) {
if (e.key === "Escape" && !overlay.hidden) closeBox();
});
showBtns.forEach(function (btn) {
btn.addEventListener("click", function () {
lastFocus = btn;
overlayImg.src = btn.getAttribute("data-cert");
overlayImg.alt = btn.getAttribute("data-alt") || "Certificate";
overlay.hidden = false;
document.body.style.overflow = "hidden";
});
});
}
/* Work index: capability filter chips. */
var chips = document.querySelectorAll(".chip[data-filter]");
if (chips.length) {
var cards = document.querySelectorAll(".card[data-tags]");
chips.forEach(function (chip) {
chip.addEventListener("click", function () {
chips.forEach(function (c) { c.setAttribute("aria-pressed", "false"); });
chip.setAttribute("aria-pressed", "true");
var f = chip.getAttribute("data-filter");
cards.forEach(function (card) {
var show = f === "all" || card.getAttribute("data-tags").split(" ").indexOf(f) !== -1;
card.classList.toggle("is-hidden", !show);
});
});
});
}
})();