summaryrefslogtreecommitdiff
path: root/docs/assets/js/site.js
blob: 8b8e6327c9defde4ca9a1dc0da638390135669a4 (plain)
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
71
72
73
74
75
76
77
78
79
const site = (function () {
  let section;
  let links = toArray(document.querySelectorAll(".menu a"));
  let time = new Date();
  let hour = time.getHours();
  let quotes = [
    "So, are soft-synths as nasty as they say?",
    "Ah, a hardware person, I get it.",
    "You have to make space to leave space.",
    "Those waveforms are more powerful than we realize.",
    "And that sub-oscillator? W-O-W!",
    "Get in there, sweep the filter and give yourself a pat on the back. In that order.",
    "Not a museum. Move along.",
    "I've got to get out of this studio and back out there.",
    "(whispers) You're my favorite. Don't tell anyone.",
  ];
  if (hour < 8 || hour > 16) {
    document.body.parentNode.classList.add("night");
  } else {
    document.body.parentNode.classList.add("day");
  }
  preload("/assets/img/pause-inv.png");
  setTimeout(() => {
    document.body.classList.remove("loading");
    // navigateHash(window.location.hash)
    const email = atob("eGVuYUB4ZW5hdmVjdHJhLmNvbQ==");
    document.querySelector("#email_addr").href = "mailto:" + email;
    document.querySelector("#email_addr").innerHTML = email;
  }, 0);
  toArray(document.querySelectorAll(".menu a")).forEach((a) => {
    a.addEventListener("click", (e) => {
      console.log(e.target);
      const href = e.target.getAttribute("href") || "";
      if (href.indexOf("#") === -1) {
        sounds.play("click");
        return;
      }
      e.preventDefault();
      sounds.play("click");
      if (e.target.nodeName.toLowerCase() !== "a") {
        navigateHash(e.target.parentNode.href);
      } else {
        navigateHash(e.target.href);
      }
    });
  });
  function navigateHash(url) {
    if (is_mobile) {
      player.hidePlaylist();
    }
    let new_section = (url || "").split("#")[1];
    if (section) {
      document.body.classList.remove(section);
      links.forEach((link) => link.classList.remove("active"));
    }
    if (new_section && new_section !== section) {
      if (new_section.match("hardware")) {
        document.querySelector("#quote").innerHTML = choice(quotes);
      }
      document.body.classList.add(new_section);
      links.forEach(
        (link) =>
          link.getAttribute("href").match(new_section) &&
          link.classList.add("active")
      );
      section = new_section;
    } else {
      section = null;
    }
    // window.location.hash = section || ""
  }
  function preload(src) {
    const img = new Image();
    img.src = src;
  }
  return {
    navigateHash: navigateHash,
  };
})();