ctucx.git: gallery

static-site-generator for image-galleries [used @ photos.ctu.cx]

commit 3a72255b1ceb521fa5e3cbf98188c81a7a0a7797
parent 0f0976cd14d4b3b5944d37584871b6d2a9766db3
Author: ctucx <c@ctu.cx>
Date: Sat, 13 Jun 2020 22:26:02 +0200

show shutterspeed correctly
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/assets/picture.html b/src/assets/picture.html
@@ -169,6 +169,13 @@
 				if (e.keyCode == 32) document.getElementById("toggle").checked = true;
 			}
 
+			function formatShutterSpeed (d) {
+				if (d >= 1) {
+					return Math.round(d*10)/10 + 's';
+				}
+				return '1/' + Math.round(1/d) + 's';
+			}
+
 			function getExif() {
 				let image = document.getElementById("image");
 

@@ -178,7 +185,7 @@
 					document.getElementById("attr_captured").innerHTML         = EXIF.getTag(this, "DateTimeOriginal");
 					document.getElementById("attr_make").innerHTML             = EXIF.getTag(this, "Make");
 					document.getElementById("attr_type/model").innerHTML       = EXIF.getTag(this, "Model");
-					document.getElementById("attr_shutter-speed").innerHTML    = EXIF.getTag(this, "ExposureTime") + ' s';
+					document.getElementById("attr_shutter-speed").innerHTML    = formatShutterSpeed(EXIF.getTag(this, "ExposureTime"));
 					document.getElementById("attr_shutter-program").innerHTML  = EXIF.getTag(this, "ExposureProgram");
 					document.getElementById("attr_aperture").innerHTML         = EXIF.getTag(this, "FNumber");
 					document.getElementById("attr_focal-length").innerHTML     = EXIF.getTag(this, "FocalLength") + 'mm';