summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-03-25 14:09:05 +0100
committerTor Andersson <tor@ccxvii.net>2022-03-25 14:09:33 +0100
commit16c18932b1a8e4373495cb599df6f83241ce4f21 (patch)
treeb48715c1a66b9c76ae89db295709562e807c3ccd /public
parent70d818bee49e9f1eeed13cc3c2a169abde001aa5 (diff)
downloadserver-16c18932b1a8e4373495cb599df6f83241ce4f21.tar.gz
Detect AVIF support.
Workaround for non-Firefox browsers missing CSS Image Module Level 4, but many still supporting AVIF. NOTE: Remove this when image-set with types works in Chrome.
Diffstat (limited to 'public')
-rw-r--r--public/common/play.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/public/common/play.js b/public/common/play.js
index bfd33d2..ae3e622 100644
--- a/public/common/play.js
+++ b/public/common/play.js
@@ -1,5 +1,13 @@
"use strict";
+// TODO: Remove when CSS Images Module Level 4 is widely supported,
+(function () {
+ let avif = new Image();
+ avif.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUEAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABkAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgSAAAAAAABNjb2xybmNseAABAA0ABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACFtZGF0EgAKBzgABhAQ0GkyDBZABhhhhAAAeUzRyg==";
+ avif.onload = () => document.documentElement.className = "avif";
+ avif.onerror = () => document.documentElement.className = "jpeg";
+})();
+
/* URL: /$title_id/(re)play:$game_id:$role */
if (!/\/[\w-]+\/(re)?play:\d+(:[\w-]+)?/.test(window.location.pathname)) {