by justusthane · 3y ago · 0 comments
I've had this one for a couple years now. I've had more polished-looking sites in the past, but this time I wanted to emphasize having fun with it and not being too precious - this allows me to update it without worrying about everything being perfect.
It's a static site built by Eleventy. I edit/build it locally, and then when I push up to Github it's rebuilt there by a Github action. Details here: https://www.justus.ws/how/
Edit: An interesting tidbit: my avatar in the upper-left corner blinks on a random timer thanks to a very simple bit of JS[0]. However, it exhibits a strange and unexpected behaviour: if you don't interact with the webpage for a while, my avatar "goes to sleep"; e.g. the eyes close until you interact with it again.
I love this, but I don't know why it happens! I get that the browser probably pauses scripts after a time, but why would it always end up with its eyes closed, especially when the eyes are only supposed to close for 150ms at a time?
[0]:
async function blinktimer() {
async function blink() {
var src = $(" .avatar ").attr('src');
console.log("BLINK!");
$(" .avatar ").attr('src','/images/dadi-avatar_blink.png');
await sleep(150);
$(" .avatar ").attr('src',src);
}
while (true) {
var delay = Math.floor((Math.random() * 11000) + 0);
await sleep(delay);
blink();
}
};
- https://www.justus.ws/js/scripts.jsBTW, I made a vanilla JS version for fun, without jQuery or promises (untested)
function blinktimer() {
var avatar = document.querySelector(" .avatar ");
var srcBlink = '/images/dadi-avatar_blink.png';
var blink = function() {
console.log("BLINK!");
var srcOpen = avatar.src;
avatar.src = srcBlink;
setTimeout(function() {
avatar.src = srcOpen;
var delay = (Math.random() * 11000) | 0;
setTimeout(blink, delay);
}, 150);
}
var delay = (Math.random() * 11000) | 0;
setTimeout(blink, delay);
}I should specify a better fallback font though.
As an aside, for some reason all of your comments are showing up as dead (including a comment you made on another post 29 days ago). I vouched for your two comments here to bring them back. I'm not sure why that is, but you might want to reach out to hn@ycombinator.com