Removed old edit pane from popup and made it call the new one

This commit is contained in:
Ajay Ramachandran
2020-04-02 13:22:08 -04:00
parent d37abcfa9f
commit 6fa67088bc
3 changed files with 8 additions and 99 deletions

View File

@@ -39,29 +39,15 @@
<div id="submissionSection" class="popupElement" style="display: none"> <div id="submissionSection" class="popupElement" style="display: none">
<h3 class="popupElement">__MSG_lastTimes__</h3> <h3 class="popupElement">__MSG_lastTimes__</h3>
<b>
<div id="sponsorMessageTimes" class="popupElement"> <b>Sponsor Editing has been moved and will appear after you click submit</b>
</div>
</b>
<br/> <br/>
<button id="clearTimes" class="smallButton popupElement">__MSG_clearTimesButton__</button>
<div id="submitTimesContainer" class="popupElement" style="display: none"> <div id="submitTimesContainer" class="popupElement" style="display: none">
<br/>
<br/>
<button id="submitTimes" class="smallButton popupElement">__MSG_submitTimesButton__</button> <button id="submitTimes" class="smallButton popupElement">__MSG_submitTimesButton__</button>
<div id="submitTimesInfoMessageContainer" class="popupElement" style="display: none">
<h3 id="submitTimesInfoMessage" class="popupElement">
</h3>
</div>
</div> </div>
</div> </div>

View File

@@ -210,6 +210,10 @@ function messageListener(request: any, sender: any, sendResponse: (response: any
case "changeStartSponsorButton": case "changeStartSponsorButton":
changeStartSponsorButton(request.showStartSponsor, request.uploadButtonVisible); changeStartSponsorButton(request.showStartSponsor, request.uploadButtonVisible);
break;
case "submitTimes":
submitSponsorTimes();
break; break;
} }
} }
@@ -1327,11 +1331,6 @@ function resetSponsorSubmissionNotice() {
} }
function submitSponsorTimes() { function submitSponsorTimes() {
if (document.getElementById("submitButton").style.display == "none") {
//don't submit, not ready
return;
}
if (submissionNotice !== null) return; if (submissionNotice !== null) return;
//it can't update to this info yet //it can't update to this info yet

View File

@@ -56,7 +56,6 @@ async function runThePopup(messageListener?: MessageListener) {
"showNoticeAgain", "showNoticeAgain",
"optionsButton", "optionsButton",
// More controls // More controls
"clearTimes",
"submitTimes", "submitTimes",
"reportAnIssue", "reportAnIssue",
// sponsorTimesContributions // sponsorTimesContributions
@@ -82,9 +81,6 @@ async function runThePopup(messageListener?: MessageListener) {
// discordButtons // discordButtons
"discordButtonContainer", "discordButtonContainer",
"hideDiscordButton", "hideDiscordButton",
// submitTimesInfoMessage
"submitTimesInfoMessageContainer",
"submitTimesInfoMessage",
// Username // Username
"setUsernameContainer", "setUsernameContainer",
"setUsernameButton", "setUsernameButton",
@@ -108,7 +104,6 @@ async function runThePopup(messageListener?: MessageListener) {
PageElements.unwhitelistChannel.addEventListener("click", unwhitelistChannel); PageElements.unwhitelistChannel.addEventListener("click", unwhitelistChannel);
PageElements.disableSkipping.addEventListener("click", () => toggleSkipping(true)); PageElements.disableSkipping.addEventListener("click", () => toggleSkipping(true));
PageElements.enableSkipping.addEventListener("click", () => toggleSkipping(false)); PageElements.enableSkipping.addEventListener("click", () => toggleSkipping(false));
PageElements.clearTimes.addEventListener("click", clearTimes);
PageElements.submitTimes.addEventListener("click", submitTimes); PageElements.submitTimes.addEventListener("click", submitTimes);
PageElements.showNoticeAgain.addEventListener("click", showNoticeAgain); PageElements.showNoticeAgain.addEventListener("click", showNoticeAgain);
PageElements.setUsernameButton.addEventListener("click", setUsernameButton); PageElements.setUsernameButton.addEventListener("click", setUsernameButton);
@@ -263,8 +258,6 @@ async function runThePopup(messageListener?: MessageListener) {
sponsorTimes = sponsorTimesStorage; sponsorTimes = sponsorTimesStorage;
displaySponsorTimes();
//show submission section //show submission section
PageElements.submissionSection.style.display = "unset"; PageElements.submissionSection.style.display = "unset";
@@ -363,26 +356,12 @@ async function runThePopup(messageListener?: MessageListener) {
updateStartTimeChosen(); updateStartTimeChosen();
//display video times on screen
displaySponsorTimes();
//show submission section //show submission section
PageElements.submissionSection.style.display = "unset"; PageElements.submissionSection.style.display = "unset";
showSubmitTimesIfNecessary(); showSubmitTimesIfNecessary();
} }
//display the video times from the array
function displaySponsorTimes() {
//remove all children
while (PageElements.sponsorMessageTimes.firstChild) {
PageElements.sponsorMessageTimes.removeChild(PageElements.sponsorMessageTimes.firstChild);
}
//add sponsor times
PageElements.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) {
@@ -692,8 +671,6 @@ async function runThePopup(messageListener?: MessageListener) {
}); });
if (closeEditMode) { if (closeEditMode) {
displaySponsorTimes();
showSubmitTimesIfNecessary(); showSubmitTimesIfNecessary();
} }
} }
@@ -721,9 +698,6 @@ async function runThePopup(messageListener?: MessageListener) {
//save this //save this
Config.config.sponsorTimes.set(currentVideoID, sponsorTimes); Config.config.sponsorTimes.set(currentVideoID, sponsorTimes);
//update display
displaySponsorTimes();
//if they are all removed //if they are all removed
if (sponsorTimes.length == 0) { if (sponsorTimes.length == 0) {
//update chrome tab //update chrome tab
@@ -753,67 +727,17 @@ async function runThePopup(messageListener?: MessageListener) {
}); });
} }
function clearTimes() { function submitTimes() {
//send new sponsor time state to tab
if (sponsorTimes.length > 0) { if (sponsorTimes.length > 0) {
messageHandler.query({
active: true,
currentWindow: true
}, function(tabs) {
messageHandler.sendMessage(tabs[0].id, {
message: "changeStartSponsorButton",
showStartSponsor: true,
uploadButtonVisible: false
});
});
}
//reset sponsorTimes
sponsorTimes = [];
Config.config.sponsorTimes.set(currentVideoID, sponsorTimes);
messageHandler.query({ messageHandler.query({
active: true, active: true,
currentWindow: true currentWindow: true
}, tabs => { }, tabs => {
messageHandler.sendMessage( messageHandler.sendMessage(
tabs[0].id, tabs[0].id,
{message: "sponsorDataChanged"} {message: 'submitTimes'},
); );
}); });
displaySponsorTimes();
//hide submission section
document.getElementById("submissionSection").style.display = "none";
resetStartTimeChosen();
}
function submitTimes() {
//make info message say loading
PageElements.submitTimesInfoMessage.innerText = chrome.i18n.getMessage("Loading");
PageElements.submitTimesInfoMessageContainer.style.display = "unset";
if (sponsorTimes.length > 0) {
chrome.runtime.sendMessage({
message: "submitTimes",
videoID: currentVideoID
}, function(response) {
if (response != undefined) {
if (response.statusCode == 200) {
//hide loading message
PageElements.submitTimesInfoMessageContainer.style.display = "none";
clearTimes();
} else {
document.getElementById("submitTimesInfoMessage").innerText = utils.getErrorMessage(response.statusCode);
document.getElementById("submitTimesInfoMessageContainer").style.display = "unset";
PageElements.submitTimesInfoMessageContainer.style.display = "unset";
}
}
});
} }
} }