my website banner

[CHORE] API key is my running joke now
[my-website] / clicky-images.js
1   
2 /**
3  *
4  * @licstart  The following is the entire license notice for the 
5  *  JavaScript code in this page.
6  *
7  * Copyright (C) 2025  David Polakovic
8  *
9  *
10  * The JavaScript code in this page is free software: you can
11  * redistribute it and/or modify it under the terms of the GNU
12  * General Public License (GNU GPL) as published by the Free Software
13  * Foundation, either version 3 of the License, or (at your option)
14  * any later version.  The code is distributed WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
17  *
18  * As additional permission under GNU GPL version 3 section 7, you
19  * may distribute non-source (e.g., minimized or compacted) forms of
20  * that code without the copy of the GNU GPL normally required by
21  * section 4, provided you include this license notice and a URL
22  * through which recipients can access the Corresponding Source.
23  *
24  * @licend  The above is the entire license notice
25  * for the JavaScript code in this page.
26  *
27  */
28 const dotImg = document.getElementById("toggleImageDot");
29 const spaceImg = document.getElementById("toggleImageSpace");
30 const dpoImg = document.getElementById("toggleImagedpo");
31
32 // Track key state
33 const keysPressed = {};
34
35 // Helper function to check for redirect
36 function checkRedirect(clickedKey) {
37   const requiredKeys = [".", "d", " "];
38   const otherKeys = requiredKeys.filter(k => k !== clickedKey);
39   
40   if (keysPressed[otherKeys[0]] && keysPressed[otherKeys[1]]) {
41     window.location.href = "https://www.dpolakovic.space/ro";
42   }
43 }
44
45 // Mouse behavior for dot
46 if (dotImg) {
47   dotImg.addEventListener("mousedown", () => {
48     dotImg.src = "./Pictures/dot2.png";
49     checkRedirect(".");
50   });
51
52   dotImg.addEventListener("mouseup", () => {
53     dotImg.src = "./Pictures/dot.png";
54   });
55
56   dotImg.addEventListener("mouseleave", () => {
57     dotImg.src = "./Pictures/dot.png";
58   });
59 }
60
61 // Mouse behavior for space
62 if (spaceImg) {
63   spaceImg.addEventListener("mousedown", () => {
64     spaceImg.src = "../Pictures/space2.png";
65     checkRedirect(" ");
66   });
67
68   spaceImg.addEventListener("mouseup", () => {
69     spaceImg.src = "./Pictures/space.png";
70   });
71
72   spaceImg.addEventListener("mouseleave", () => {
73     spaceImg.src = "./Pictures/space.png";
74   });
75 }
76
77 // Mouse behavior for dpo
78 if (dpoImg) {
79   dpoImg.addEventListener("mousedown", () => {
80     dpoImg.src = "./Pictures/dpo2.png";
81     checkRedirect("d");
82   });
83
84   dpoImg.addEventListener("mouseup", () => {
85     dpoImg.src = "./Pictures/dpolakovic.png";
86   });
87
88   dpoImg.addEventListener("mouseleave", () => {
89     dpoImg.src = "./Pictures/dpolakovic.png";
90   });
91 }
92
93 // Keyboard behavior
94 document.addEventListener("keydown", (event) => {
95   keysPressed[event.key] = true;
96
97   if (dotImg && event.key === ".") {
98     dotImg.src = "./Pictures/dot2.png";
99   }
100   if (spaceImg && event.key === " ") {
101     spaceImg.src = "./Pictures/space2.png";
102   }
103   if (dpoImg && event.key === "d") {
104     dpoImg.src = "./Pictures/dpo2.png";
105   }
106
107   // Check if all three keys are pressed
108   if (keysPressed["."] && keysPressed["d"] && keysPressed[" "]) {
109     window.location.href = "https://www.dpolakovic.space/ro";
110   }
111 });
112
113 document.addEventListener("keyup", (event) => {
114   delete keysPressed[event.key];
115
116   if (dotImg && event.key === ".") {
117     dotImg.src = "./Pictures/dot.png";
118   }
119   if (spaceImg && event.key === " ") {
120     spaceImg.src = "./Pictures/space.png";
121   }
122   if (dpoImg && event.key === "d") {
123     dpoImg.src = "./Pictures/dpolakovic.png";
124   }
125 });