From 89ae1e265b61069b87443997b3b0d93987eeaebe Mon Sep 17 00:00:00 2001 From: Astound Date: Mon, 22 Jan 2024 07:48:00 +0800 Subject: Refactor captions logic in Plyr video player initialization Simplify the captions logic in the Plyr video player initialization by using a conditional statement. Cleaner and more concise code. --- youtube/static/js/plyr-start.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'youtube') diff --git a/youtube/static/js/plyr-start.js b/youtube/static/js/plyr-start.js index d9fde90..15e096b 100644 --- a/youtube/static/js/plyr-start.js +++ b/youtube/static/js/plyr-start.js @@ -1,17 +1,10 @@ (function main() { 'use strict'; - let captionsActive; - - switch(true) { - case data.settings.subtitles_mode == 2: - captionsActive = true; - break; - case data.settings.subtitles_mode == 1 && data.has_manual_captions: - captionsActive = true; - break; - default: - captionsActive = false; + // Captions + let captionsActive = false; + if (data.settings.subtitles_mode === 2 || (data.settings.subtitles_mode === 1 && data.has_manual_captions)) { + captionsActive = true; } // AutoPlay -- cgit v1.2.3