Made the submission process hidden until you record your first time

This commit is contained in:
Ajay Ramachandran
2019-07-09 22:23:35 -04:00
parent 8d7b66d7d4
commit 26ea70da61
3 changed files with 35 additions and 17 deletions

View File

@@ -38,7 +38,7 @@ function submitTimes(videoID) {
chrome.storage.local.get([sponsorTimeKey], function(result) {
let sponsorTimes = result[sponsorTimeKey];
if (sponsorTimes != undefined && sponsorTimes != []) {
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
//submit these times
for (let i = 0; i < sponsorTimes.length; i++) {
let xmlhttp = new XMLHttpRequest();

View File

@@ -23,26 +23,35 @@
</div>
<br/>
<h2>Record the times of a sponsorship</h2>
<p>
Click the button below when the sponsorship starts and ends to record and
submit it to the database.
</p>
<div>
<button id="sponsorStart">Sponsorship Starts</button>
<button id="sponsorStart">Sponsorship Starts Now</button>
</div>
<h3>Latest Sponsor Message Times Chosen</h3>
<b>
<div id="sponsorMessageTimes">
<div id="submissionSection" style="display: none">
<h3>Latest Sponsor Message Times Chosen</h3>
<b>
<div id="sponsorMessageTimes">
</div>
</b>
</div>
</b>
<button id="clearTimes">Clear Times</button>
<br/>
<button id="submitTimes">Submit Times</button>
<button id="clearTimes">Clear Times</button>
<br/>
<button id="submitTimes">Submit Times</button>
</div>
<br/>
<button id="showNoticeAgain" style="display: none">Show Notice Again</button>
</div>
</div>

View File

@@ -46,7 +46,7 @@ function loadTabData(tabs) {
let sponsorTimeKey = "sponsorTimes" + currentVideoID;
chrome.storage.local.get([sponsorTimeKey], function(result) {
let sponsorTimesStorage = result[sponsorTimeKey];
if (sponsorTimesStorage != undefined && sponsorTimesStorage != []) {
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) {
startTimeChosen = true;
}
@@ -54,6 +54,9 @@ function loadTabData(tabs) {
sponsorTimes = sponsorTimesStorage;
displaySponsorTimes();
//show submission section
document.getElementById("submissionSection").style.display = "unset";
}
});
@@ -124,14 +127,17 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
//update startTimeChosen variable
if (!startTimeChosen) {
startTimeChosen = true;
document.getElementById("sponsorStart").innerHTML = "Sponsorship Ends";
document.getElementById("sponsorStart").innerHTML = "Sponsorship Ends Now";
} else {
startTimeChosen = false;
document.getElementById("sponsorStart").innerHTML = "Sponsorship Start";
document.getElementById("sponsorStart").innerHTML = "Sponsorship Starts Now";
}
//display video times on screen
displaySponsorTimes();
//show submission section
document.getElementById("submissionSection").style.display = "unset";
}
});
@@ -178,6 +184,9 @@ function clearTimes() {
chrome.storage.local.set({[sponsorTimeKey]: sponsorTimes});
displaySponsorTimes();
//hide submission section
document.getElementById("submissionSection").style.display = "none";
}
function submitTimes() {