From 00ae96a7e5ea8446d5823b7b90ebd761d7f966e8 Mon Sep 17 00:00:00 2001 From: bonjinnorenka <32708102+bonjinnorenka@users.noreply.github.com> Date: Sat, 23 Sep 2023 18:13:54 +0900 Subject: [PATCH] Code easy to read by suggestion from code review Co-authored-by: Samantaz Fox --- assets/js/embed.js | 15 ++++++++++++++- assets/js/invidious_iframe_api.js | 25 +++++++++++++++++++------ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/assets/js/embed.js b/assets/js/embed.js index 0a08e24b..20f5320b 100644 --- a/assets/js/embed.js +++ b/assets/js/embed.js @@ -83,7 +83,20 @@ function return_message(message, target_window) { } if (message.message_kind === 'event') { if (message.eventname === 'timeupdate' || message.eventname === 'loadedmetadata') { - additional_info['value'] = { getvolume: player.volume(), getduration: player.duration(), getcurrenttime: player.currentTime(), getplaystatus: player.paused(), getplaybackrate: player.playbackRate(), getloopstatus: player.loop(), getmutestatus: player.muted(), getfullscreenstatus: player.isFullscreen(), getavailableplaybackrates: options.playbackRates, gettitle: player_data.title, getplaylistindex: video_data.index, getplaylistid: video_data.plid }; + additional_info['value'] = { + getvolume: player.volume(), + getduration: player.duration(), + getcurrenttime: player.currentTime(), + getplaystatus: player.paused(), + getplaybackrate: player.playbackRate(), + getloopstatus: player.loop(), + getmutestatus: player.muted(), + getfullscreenstatus: player.isFullscreen(), + getavailableplaybackrates: options.playbackRates, + gettitle: player_data.title, + getplaylistindex: video_data.index, + getplaylistid: video_data.plid + }; } } if (message.eventname === 'error') { diff --git a/assets/js/invidious_iframe_api.js b/assets/js/invidious_iframe_api.js index 2a6e9462..57df5ffe 100644 --- a/assets/js/invidious_iframe_api.js +++ b/assets/js/invidious_iframe_api.js @@ -54,11 +54,7 @@ class invidious_embed { const instance_stats = await fetch(instance_origin + '/api/v1/stats'); if (instance_stats.ok) { const instance_stats_json = await instance_stats.json(); - if (instance_stats_json.software.name === 'invidious') { - return_status = true; - } else { - return_status = false; - } + return_status = (instance_stats_json.software.name === 'invidious'); } else { return_status = false; } @@ -139,7 +135,24 @@ class invidious_embed { this.volume = 100; this.loop = false; this.playlistVideoIds = []; - this.eventobject = { ready: [], ended: [], error: [], ratechange: [], volumechange: [], waiting: [], timeupdate: [], loadedmetadata: [], play: [], seeking: [], seeked: [], playerresize: [], pause: [], statechange: [] }; + + this.eventobject = { + ready: [], + ended: [], + error: [], + ratechange: [], + volumechange: [], + waiting: [], + timeupdate: [], + loadedmetadata: [], + play: [], + seeking: [], + seeked: [], + playerresize: [], + pause: [], + statechange: [] + }; + let replace_elemnt; this.isPlaylistVideoList = false; if (element === undefined || element === null) {