diff options
Diffstat (limited to 'web/source/frontend')
| -rw-r--r-- | web/source/frontend/index.js | 34 | 
1 files changed, 16 insertions, 18 deletions
diff --git a/web/source/frontend/index.js b/web/source/frontend/index.js index 2fa035adb..6fb1d5be7 100644 --- a/web/source/frontend/index.js +++ b/web/source/frontend/index.js @@ -104,31 +104,29 @@ function dynamicSpoiler(className, updateFunc) {  }  dynamicSpoiler("text-spoiler", (spoiler) => { -	const button = spoiler.querySelector("button"); +	const button = spoiler.querySelector(".button"); -	if (button != undefined) { -		return () => { -			button.textContent = spoiler.open -				? "Show less" -				: "Show more"; -		}; -	} +	return () => { +		button.textContent = spoiler.open +			? "Show less" +			: "Show more"; +	};  }); -dynamicSpoiler("video-spoiler", (spoiler) => { -	const video = spoiler.querySelector(".plyr-video"); +dynamicSpoiler("media-spoiler", (spoiler) => {  	const eye = spoiler.querySelector(".eye.button"); +	const video = spoiler.querySelector(".plyr-video"); -	if (video != undefined) { -		return () => { -			if (spoiler.open) { -				eye.setAttribute("aria-label", "Hide media"); -			} else { -				eye.setAttribute("aria-label", "Show media"); +	return () => { +		if (spoiler.open) { +			eye.setAttribute("aria-label", "Hide media"); +		} else { +			eye.setAttribute("aria-label", "Show media"); +			if (video) {  				video.pause();  			} -		}; -	} +		} +	};  });  Array.from(document.getElementsByClassName("plyr-video")).forEach((video) => {  | 
