"Improvements" to the Ref system

This commit is contained in:
Official Noob
2019-07-30 20:43:45 +01:00
committed by GitHub
parent a1c8ecabca
commit 69dee25ea8

View File

@@ -1,32 +1,39 @@
// References
var SB = {}; var SB = {};
SB.sponsorStart = document.getElementById("sponsorStart"); ["sponsorStart",
SB.clearTimes = document.getElementById("clearTimes"); "clearTimes",
SB.submitTimes = document.getElementById("submitTimes"); "submitTimes",
SB.showNoticeAgain = document.getElementById("showNoticeAgain"); "showNoticeAgain",
SB.hideVideoPlayerControls = document.getElementById("hideVideoPlayerControls"); "hideVideoPlayerControls",
SB.showVideoPlayerControls = document.getElementById("showVideoPlayerControls"); "showVideoPlayerControls",
SB.hideInfoButtonPlayerControls = document.getElementById("hideInfoButtonPlayerControls"); "hideInfoButtonPlayerControls",
SB.showInfoButtonPlayerControls = document.getElementById("showInfoButtonPlayerControls"); "showInfoButtonPlayerControls",
SB.hideDeleteButtonPlayerControls = document.getElementById("hideDeleteButtonPlayerControls"); "hideDeleteButtonPlayerControls",
SB.showDeleteButtonPlayerControls = document.getElementById("showDeleteButtonPlayerControls"); "showDeleteButtonPlayerControls",
SB.disableSponsorViewTracking = document.getElementById("disableSponsorViewTracking"); "disableSponsorViewTracking",
SB.enableSponsorViewTracking = document.getElementById("enableSponsorViewTracking"); "enableSponsorViewTracking",
SB.optionsButton = document.getElementById("optionsButton"); "optionsButton",
SB.reportAnIssue = document.getElementById("reportAnIssue"); "reportAnIssue",
// sponsorTimesContributions // sponsorTimesContributions
SB.sponsorTimesContributionsContainer = document.getElementById("sponsorTimesContributionsContainer"); "sponsorTimesContributionsContainer",
SB.sponsorTimesContributionsDisplay = document.getElementById("sponsorTimesContributionsDisplay"); "sponsorTimesContributionsDisplay",
SB.sponsorTimesContributionsDisplayEndWord = document.getElementById("sponsorTimesContributionsDisplayEndWord"); "sponsorTimesContributionsDisplayEndWord",
// sponsorTimesViewsDisplay // sponsorTimesViewsDisplay
SB.sponsorTimesViewsContainer = document.getElementById("sponsorTimesViewsDisplayContainer"); "sponsorTimesViewsContainer",
SB.sponsorTimesViewsDisplay = document.getElementById("sponsorTimesViewsDisplayDisplay"); "sponsorTimesViewsDisplay",
SB.sponsorTimesViewsDisplayEndWord = document.getElementById("sponsorTimesViewsDisplayDisplayEndWord"); "sponsorTimesViewsDisplayEndWord",
// discordButtons // discordButtons
SB.discordButtonContainer = document.getElementById("discordButtonContainer"); "discordButtonContainer",
SB.hideDiscordButton = document.getElementById("hideDiscordButton"); "hideDiscordButton",
// More
"submissionSection",
"mainControls",
"loadingIndicator",
"videoFound",
"sponsorMessageTimes",
"downloadedSponsorMessageTimes",
].forEach(id => SB[id] = document.getElementById(id));
//setup click listeners //setup click listeners
SB.sponsorStart.addEventListener("click", sendSponsorStartMessage); SB.sponsorStart.addEventListener("click", sendSponsorStartMessage);
@@ -186,7 +193,7 @@ function loadTabData(tabs) {
displaySponsorTimes(); displaySponsorTimes();
//show submission section //show submission section
document.getElementById("submissionSection").style.display = "unset"; submissionSection.style.display = "unset";
showSubmitTimesIfNecessary(); showSubmitTimesIfNecessary();
} }
@@ -214,15 +221,15 @@ function infoFound(request) {
isYouTubeTab = true; isYouTubeTab = true;
//remove loading text //remove loading text
document.getElementById("mainControls").style.display = "unset" SB.mainControls.style.display = "unset"
document.getElementById("loadingIndicator").innerHTML = ""; SB.loadingIndicator.innerHTML = "";
if (request.found) { if (request.found) {
document.getElementById("videoFound").innerHTML = "This video's sponsors are in the database!" SB.videoFound.innerHTML = "This video's sponsors are in the database!"
displayDownloadedSponsorTimes(request); displayDownloadedSponsorTimes(request);
} else { } else {
document.getElementById("videoFound").innerHTML = "No sponsors found" SB.videoFound.innerHTML = "No sponsors found"
} }
} }
} }
@@ -266,30 +273,28 @@ function startSponsorCallback(response) {
displaySponsorTimes(); displaySponsorTimes();
//show submission section //show submission section
document.getElementById("submissionSection").style.display = "unset"; SB.submissionSection.style.display = "unset";
showSubmitTimesIfNecessary(); showSubmitTimesIfNecessary();
} }
//display the video times from the array //display the video times from the array
function displaySponsorTimes() { function displaySponsorTimes() {
//set it to the message
let sponsorMessageTimes = document.getElementById("sponsorMessageTimes");
//remove all children //remove all children
while (sponsorMessageTimes.firstChild) { while (SB.sponsorMessageTimes.firstChild) {
sponsorMessageTimes.removeChild(sponsorMessageTimes.firstChild); SB.sponsorMessageTimes.removeChild(SB.sponsorMessageTimes.firstChild);
} }
//add sponsor times //add sponsor times
sponsorMessageTimes.appendChild(getSponsorTimesMessageDiv(sponsorTimes)); SB.sponsorMessageTimes.appendChild(getSponsorTimesMessageDiv(sponsorTimes));
} }
//display the video times from the array at the top, in a different section //display the video times from the array at the top, in a different section
function displayDownloadedSponsorTimes(request) { function displayDownloadedSponsorTimes(request) {
if (request.sponsorTimes != undefined) { if (request.sponsorTimes != undefined) {
//set it to the message //set it to the message
document.getElementById("downloadedSponsorMessageTimes").innerHTML = getSponsorTimesMessage(request.sponsorTimes); SB.downloadedSponsorMessageTimes.innerHTML = getSponsorTimesMessage(request.sponsorTimes);
//add them as buttons to the issue reporting container //add them as buttons to the issue reporting container
let container = document.getElementById("issueReporterTimeButtons"); let container = document.getElementById("issueReporterTimeButtons");