From 32884372fa46ec6cccb8f19ffad8ca4b8724864d Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 21 Aug 2019 14:27:25 -0400 Subject: [PATCH] Unsubmitted sponsors are now in the preview. --- content.js | 19 ++++++++++++++++++- utils/previewBar.js | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/content.js b/content.js index 0170b9da..add0b940 100644 --- a/content.js +++ b/content.js @@ -282,6 +282,8 @@ function videoIDChange(id) { //see if this data should be saved in the sponsorTimesSubmitting variable if (sponsorTimes != undefined && sponsorTimes.length > 0) { sponsorTimesSubmitting = sponsorTimes; + + updatePreviewBar(); } } }); @@ -377,7 +379,18 @@ function sponsorsLookup(id) { } function updatePreviewBar() { - previewBar.set(sponsorTimes, [], v.duration); + let allSponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting); + + //create an array of the sponsor types + let types = []; + for (let i = 0; i < sponsorTimes.length; i++) { + types.push("sponsor"); + } + for (let i = 0; i < sponsorTimesSubmitting.length; i++) { + types.push("previewSponsor"); + } + + previewBar.set(allSponsorTimes, types, v.duration); //update last video id lastPreviewBarUpdate = getYouTubeVideoID(document.URL); @@ -609,6 +622,8 @@ function updateSponsorTimesSubmitting() { //see if this data should be saved in the sponsorTimesSubmitting variable if (sponsorTimes != undefined) { sponsorTimesSubmitting = sponsorTimes; + + updatePreviewBar(); } } }); @@ -835,6 +850,8 @@ function clearSponsorTimes() { //clear sponsor times submitting sponsorTimesSubmitting = []; + updatePreviewBar(); + //set buttons to be correct changeStartSponsorButton(true, false); } diff --git a/utils/previewBar.js b/utils/previewBar.js index 95454e9d..c746c5d4 100644 --- a/utils/previewBar.js +++ b/utils/previewBar.js @@ -13,6 +13,10 @@ let barTypes = { "sponsor": { color: "#00d400", opacity: "0.5" + }, + "previewSponsor": { + color: "#0000d4", + opacity: "0.5" } };