sourcehypertextpublicgalleryarrange.js

function loaded(img) {
	if (img.currentTarget) {
		img = img.currentTarget;
	}
	img.width = Math.floor(
		(img.width * Math.max(480, $("main").clientWidth * 0.3)) /
			Math.sqrt(img.width ** 2 + img.height ** 2)
	) + 40;
	img.removeAttribute("height");
}

addEventListener("DOMContentLoaded", () => {
	for (let el of $$(`.gallery > li > img`)) {
		if (el.complete) {
			loaded(el);
		} else {
			el.addEventListener("load", loaded);
		}
	}

	for (let el of $$(`video`)) {
		loaded(el);
	}
});