From: David Polakovic Date: Fri, 6 Jun 2025 18:23:39 +0000 (+0200) Subject: javascript blog and final update X-Git-Url: https://git.dpolakovic.space/?a=commitdiff_plain;h=9cba8169b349f09213abc927e8399366c334ef5c;p=my-website javascript blog and final update --- diff --git a/Pictures/dot2.png b/Pictures/dot2.png new file mode 100644 index 0000000..39d81f6 Binary files /dev/null and b/Pictures/dot2.png differ diff --git a/Pictures/dpo2.png b/Pictures/dpo2.png new file mode 100644 index 0000000..4ec5f6f Binary files /dev/null and b/Pictures/dpo2.png differ diff --git a/Pictures/space2.png b/Pictures/space2.png new file mode 100644 index 0000000..c8c90cb Binary files /dev/null and b/Pictures/space2.png differ diff --git a/blogs/clicky-images-in-blogs.js b/blogs/clicky-images-in-blogs.js new file mode 100644 index 0000000..a3c489d --- /dev/null +++ b/blogs/clicky-images-in-blogs.js @@ -0,0 +1,127 @@ + +/** + * + * @licstart The following is the entire license notice for the + * JavaScript code in this page. + * + * Copyright (C) 2025 David Polakovic + * + * + * The JavaScript code in this page is free software: you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License (GNU GPL) as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. The code is distributed WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. + * + * As additional permission under GNU GPL version 3 section 7, you + * may distribute non-source (e.g., minimized or compacted) forms of + * that code without the copy of the GNU GPL normally required by + * section 4, provided you include this license notice and a URL + * through which recipients can access the Corresponding Source. + * + * @licend The above is the entire license notice + * for the JavaScript code in this page. + * + */ + +const dotImg = document.getElementById("toggleImageDot"); +const spaceImg = document.getElementById("toggleImageSpace"); +const dpoImg = document.getElementById("toggleImagedpo"); + +// Track key state +const keysPressed = {}; + +// Helper function to check for redirect +function checkRedirect(clickedKey) { + const requiredKeys = [".", "d", " "]; + const otherKeys = requiredKeys.filter(k => k !== clickedKey); + + if (keysPressed[otherKeys[0]] && keysPressed[otherKeys[1]]) { + window.location.href = "https://www.dpolakovic.space/ro"; + } +} + +// Mouse behavior for dot +if (dotImg) { + dotImg.addEventListener("mousedown", () => { + dotImg.src = "../Pictures/dot2.png"; + checkRedirect("."); + }); + + dotImg.addEventListener("mouseup", () => { + dotImg.src = "../Pictures/dot.png"; + }); + + dotImg.addEventListener("mouseleave", () => { + dotImg.src = "../Pictures/dot.png"; + }); +} + +// Mouse behavior for space +if (spaceImg) { + spaceImg.addEventListener("mousedown", () => { + spaceImg.src = "../Pictures/space2.png"; + checkRedirect(" "); + }); + + spaceImg.addEventListener("mouseup", () => { + spaceImg.src = "../Pictures/space.png"; + }); + + spaceImg.addEventListener("mouseleave", () => { + spaceImg.src = "../Pictures/space.png"; + }); +} + +// Mouse behavior for dpo +if (dpoImg) { + dpoImg.addEventListener("mousedown", () => { + dpoImg.src = "../Pictures/dpo2.png"; + checkRedirect("d"); + }); + + dpoImg.addEventListener("mouseup", () => { + dpoImg.src = "../Pictures/dpolakovic.png"; + }); + + dpoImg.addEventListener("mouseleave", () => { + dpoImg.src = "../Pictures/dpolakovic.png"; + }); +} + +// Keyboard behavior +document.addEventListener("keydown", (event) => { + keysPressed[event.key] = true; + + if (dotImg && event.key === ".") { + dotImg.src = "../Pictures/dot2.png"; + } + if (spaceImg && event.key === " ") { + spaceImg.src = "../Pictures/space2.png"; + } + if (dpoImg && event.key === "d") { + dpoImg.src = "../Pictures/dpo2.png"; + } + + // Check if all three keys are pressed + if (keysPressed["."] && keysPressed["d"] && keysPressed[" "]) { + window.location.href = "https://www.dpolakovic.space/ro"; + } +}); + +document.addEventListener("keyup", (event) => { + delete keysPressed[event.key]; + + if (dotImg && event.key === ".") { + dotImg.src = "../Pictures/dot.png"; + } + if (spaceImg && event.key === " ") { + spaceImg.src = "../Pictures/space.png"; + } + if (dpoImg && event.key === "d") { + dpoImg.src = "../Pictures/dpolakovic.png"; + } +}); + diff --git a/blogs/javascript.html b/blogs/javascript.html new file mode 100755 index 0000000..dc8a3fc --- /dev/null +++ b/blogs/javascript.html @@ -0,0 +1,119 @@ + + + + + + + "This site uses client-side scripting" + + + + + + + + + + + + + + +
+

+

This site uses client-side scripting

+ 5 Jun 2025 - Spooky, scary JavaScript update. +
+

+ + Jerry about to be eaten by Tom +

+

+ I have a few thoughts on client-side scripting. It was only recently that + I decided to burden your browsers with up to 2.9 kilobytes of JavaScript + code per page[*]. My previous zealotry of avoiding + it was based on privacy and security concerns that I have with this + technology, which I didn't want my few readers to deal with. So, let me + explain why I decided to burden your browser with a code size of a photo + taken with a Nokia 6600. +

+

+ The sheer concept of running served code locally in your browser is alien + to me. Sandboxed or not, escapes happen on a large scale. Just this week, + the zero-day vulnerability + CVE-2025-5419 + was documented after having existed for almost half a year in the wild. Last + year, four severe vulnerabilities in the JavaScript engine emerged that + I am aware of, one of which enabled ACE with as little as 40 lines of code + (including the payload!). +

+

+ Running code client-side means placing a lot of trust in your source (the + website) but even more in the tool (the browser). My decision to include + JavaScript in the non-critical functionality of the site was made for the + comfort of average surfers. To be specific, now visitors can see my + mars clock + update in real time. I wanted to demonstrate the difference between a Mars + second and an Earth second in the simplest possible example. +

+

+ The core functionality is, and always will be, executed server-side. All + scripting is purely cosmetic and in no way interferes with your experience + on my domain. +

+

+ But don't take my word for it. I encourage every visitor to read my source + code. Up-to-date "backups" are stored on my Git server and linked in every + footer. Compare them with the dev console and call me out if you find any + discrepancies. If you don't feel comfortable diving into the code, fire up + JShelter + to protect yourself. Even better, I encourage you to disable all JavaScript + and fetch only my + RSS feed. +

+

+ Remember, a web publication should be obtained from the server in its complete and + unaltered form. If someone hides information behind potential security risks, + it might not be worth your time. +

+ + + + +
+
+
+ +

+ * If we include the license statements, which don't affect the logic of mentioned code, + it adds up to 5 kilobytes per page. +

+
+
+
+ + + +

+ + + diff --git a/clicky-images.js b/clicky-images.js index c79d02d..16a3f0d 100644 --- a/clicky-images.js +++ b/clicky-images.js @@ -25,15 +25,28 @@ * for the JavaScript code in this page. * */ - const dotImg = document.getElementById("toggleImageDot"); const spaceImg = document.getElementById("toggleImageSpace"); const dpoImg = document.getElementById("toggleImagedpo"); +// Track key state +const keysPressed = {}; + +// Helper function to check for redirect +function checkRedirect(clickedKey) { + const requiredKeys = [".", "d", " "]; + const otherKeys = requiredKeys.filter(k => k !== clickedKey); + + if (keysPressed[otherKeys[0]] && keysPressed[otherKeys[1]]) { + window.location.href = "https://www.dpolakovic.space/ro"; + } +} + // Mouse behavior for dot if (dotImg) { dotImg.addEventListener("mousedown", () => { dotImg.src = "./Pictures/dot2.png"; + checkRedirect("."); }); dotImg.addEventListener("mouseup", () => { @@ -48,7 +61,8 @@ if (dotImg) { // Mouse behavior for space if (spaceImg) { spaceImg.addEventListener("mousedown", () => { - spaceImg.src = "./Pictures/space2.png"; + spaceImg.src = "../Pictures/space2.png"; + checkRedirect(" "); }); spaceImg.addEventListener("mouseup", () => { @@ -64,6 +78,7 @@ if (spaceImg) { if (dpoImg) { dpoImg.addEventListener("mousedown", () => { dpoImg.src = "./Pictures/dpo2.png"; + checkRedirect("d"); }); dpoImg.addEventListener("mouseup", () => { @@ -77,25 +92,34 @@ if (dpoImg) { // Keyboard behavior document.addEventListener("keydown", (event) => { - if (event.key === "." && dotImg) { + keysPressed[event.key] = true; + + if (dotImg && event.key === ".") { dotImg.src = "./Pictures/dot2.png"; } - if (event.key === " " && spaceImg) { + if (spaceImg && event.key === " ") { spaceImg.src = "./Pictures/space2.png"; } - if (event.key === "d" && dpoImg) { + if (dpoImg && event.key === "d") { dpoImg.src = "./Pictures/dpo2.png"; } + + // Check if all three keys are pressed + if (keysPressed["."] && keysPressed["d"] && keysPressed[" "]) { + window.location.href = "https://www.dpolakovic.space/ro"; + } }); document.addEventListener("keyup", (event) => { - if (event.key === "." && dotImg) { + delete keysPressed[event.key]; + + if (dotImg && event.key === ".") { dotImg.src = "./Pictures/dot.png"; } - if (event.key === " " && spaceImg) { + if (spaceImg && event.key === " ") { spaceImg.src = "./Pictures/space.png"; } - if (event.key === "d" && dpoImg) { + if (dpoImg && event.key === "d") { dpoImg.src = "./Pictures/dpolakovic.png"; } }); \ No newline at end of file diff --git a/mars-clock.php b/mars-clock.php index f79f60a..765009f 100755 --- a/mars-clock.php +++ b/mars-clock.php @@ -1,133 +1,187 @@ - - - - dpolakovic.space - - - - - - - - - - - - + + + +dpolakovic.space + + + + + + + + + + + - - - + + + + +
+

+

Mars clock

+ Ack Ack Ack Ack Ack! +
+
It was my friend Peter who got me into timekeeping "nerding". He is a devoted fan of Mars colonization and author of few articles about timekeeping on other celestial bodies. He inspired me to make a simple app to help me (and you!) to see what time it is on other places in our Solar system. -

-

-

+

+

+

------------------------------------------------------- -Earth | Time | Date | ------------------------------------------------------- -Silicon Valley | | | +--------------------------------------------------------- +Earth | Time | Date | +--------------------------------------------------------- +Silicon Valley | | | Boston | | | London* | | | Tokyo | | | + ------------------------------------------------------- -Mars | Time | Date | ------------------------------------------------------- -Jezero Crater | | | +--------------------------------------------------------- +Mars | Time | Date | +--------------------------------------------------------- +Jezero Crater | | | Gale Crater | | | Olympus Mons* | | | Tharsis Tholus | | | Conv. Prime Meridian | | | - - - ------------------------------------------------------- +

+--------------------------------------------------------- * 0 offset time zone -
- -

-

+

+

+

The idea was to create the most humanly readable modification of the - Darian calendar +Darian calendar On contrary to the original, the epoch starts on UTC 00:00 11th April, 1609 (invention / first use of telescope) with year 1, not year 0. Aditionaly, the time zone with zero offset was chosen not conventionally (the first landing spot / prime meridian) but rather by matching the converted time with actual daylight on the Red Planet. -

-

+

+

Note, that original Darian calendar designates the first day of each month as the start of a new week, which results in a one-day weekend occurring three or four times a year. I am uncertain how this would be received by future Martian colonists, so I didn't implemented this feature as well as winter/summer time shifts or any holidays whatsoever. -

-

- Also, the clocks are not updating automatically like clocks usually do, - because I didn't want to DDOS myself nor invade your client with - any scripting. It is also not very useful extraterrestrially, +

+

+ Also, this site is not very useful extraterrestrially, so I made a portable version which you can fit on your Raspberry Pi or any device running Java. It runs in GUI mode and terminal as well. -

-

-

- Download +

+

+

+Download (12.7kb) / - Source code -
-

-
-
-
-

- +Source code +

+

+
+

+ What about other celestial bodies in the Solar System? All relatively good + colonization candidates have a problem adopting a customized timekeeping + format due to their vastly different synodic rotation periods compared to + that of Earth. Homo sapiens are biologically programmed to function on a + 24–26-hour day. Therefore, it is much easier to implement the classic + Gregorian calendar with a 24-hour day and disregard the actual daylight + period (especially since the thin atmospheres and natural luminous intensity + would require artificial lighting anyway). +

+

+ However, it is important to keep track of local daylight duration for technical purposes, + such as photovoltaic system management, energy conservation during spacewalks, + or monitoring surface temperature. Nasa is actually working on their custom timekeeping format + for future Moon missions. You can read more about it +here. +

+

+
+

+ Mars clock is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE like aerospace engineering, tax payments and/or time travel. - -

-
-
+ +

+
+ - - +

+ + \ No newline at end of file diff --git a/ro.php b/ro.php new file mode 100755 index 0000000..3217937 --- /dev/null +++ b/ro.php @@ -0,0 +1,100 @@ + + + + + + dpolakovic.biza + + + + + + + + + + + + + + + +
+

+

Giyo tagab

+ Sit ac is erken in! +
+
+ Abe rokab ela + David + ud al ela Ro ro robit + iv abe rabali web biza. Ab neli vev ag uyid gizit, ub + avit ab vev, ag gizit hek camib cid iv abe ladup ta. + Ac eluk relidek ay iv abe ugz, abe uyil lajog git ramibaf + ur ac aluk eca alid ud dotac al cednob.

+
+ cool dancing alien +
+

+

+ Ab neli vev sicu jivabz, alif uf ac hib col ir ab, + ac elul vev E-pipac. Ab rur abe pipac-pejab lacik gizit + alif ab fafac kimerem in zab taf. + Rek ladup eb vev abaque GPG patab rubigeb ace pipalz. +

+

+

+ email@dpolakovic.space +   + Kalibev abe GPG patab +   + (Avif vev GPG petab?) +
+

+

+

+
+

+ + the glider + +

+ + +
+ + GIF button: html and php only + +
+

+
+ + + + + diff --git a/rss.xml b/rss.xml index 553d1e2..da432d1 100755 --- a/rss.xml +++ b/rss.xml @@ -6,48 +6,66 @@ Some obscure thoughts caught on the Web. en-us + + This site uses client-side scripting + https://www.dpolakovic.space/blogs/javascript.html + Spooky, scary JavaScript update. + Thu, 5 Jun 2025 22:00:00 GMT + https://www.dpolakovic.space/blogs/pics/jst.jpg + 100% 1 + + + + Stormtrooper's guide to Galaxies + https://www.dpolakovic.space/blogs/star-wars-galaxies + "You seen that new VT-16?" + Wed, 26 Mar 2025 15:00:00 GMT + https://www.dpolakovic.space/blogs/pics/sw5.jpg + 100% 1 + + The Phantom Menace is good - https://dpolakovic.space/blogs/phantom-menace + https://www.dpolakovic.space/blogs/phantom-menace An inevitable STAR WARS rant. Sun, 18 Aug 2024 17:00:00 GMT - https://dpolakovic.space/blogs/pics/starwars26.jpg + https://www.dpolakovic.space/blogs/pics/starwars26.jpg 100% 1 Y292B bug - https://dpolakovic.space/blogs/y292b + https://www.dpolakovic.space/blogs/y292b We're doomed! Again... Wed, 26 Jun 2024 17:00:00 GMT - https://dpolakovic.space/blogs/pics/bug.jpg + https://www.dpolakovic.space/blogs/pics/bug.jpg 100% 0 Reproducing the printer hack of Windows 95 - https://dpolakovic.space/blogs/windows-95-printer-hack + https://www.dpolakovic.space/blogs/windows-95-printer-hack Start me up! Fri, 12 Apr 2024 16:00:00 GMT - https://dpolakovic.space/blogs/pics/deskjet710c.jpg + https://www.dpolakovic.space/blogs/pics/deskjet710c.jpg 100% 5 Let's play Zork - https://dpolakovic.space/blogs/zork + https://www.dpolakovic.space/blogs/zork A hollow voice says "Fool". Fri, 24 Nov 2023 20:00:00 GMT - https://dpolakovic.space/blogs/pics/zork.png + https://www.dpolakovic.space/blogs/pics/zork.png 100% 1 On the nature of Free software - https://dpolakovic.space/blogs/free-software + https://www.dpolakovic.space/blogs/free-software Does your synthetic colleague pose a threat to you? Tue, 25 Jul 2023 20:00:00 GMT - https://dpolakovic.space/blogs/pics/free2.jpg + https://www.dpolakovic.space/blogs/pics/free2.jpg 100% 0