Made upvote system submit data to the server.

This commit is contained in:
Ajay Ramachandran
2019-07-15 19:13:09 -04:00
parent 6cd01108f4
commit 987b7b036c
2 changed files with 34 additions and 0 deletions

View File

@@ -41,6 +41,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
//this allows the callback to be called later
return true;
} else if (request.message == "submitVote") {
submitVote(request.type, request.UUID)
}
});
@@ -79,6 +81,19 @@ function addSponsorTime(time) {
});
}
function submitVote(type, UUID) {
let xmlhttp = new XMLHttpRequest();
getUserID(function(userID) {
//publish this vote
console.log(serverAddress + "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type);
xmlhttp.open('GET', serverAddress + "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, true);
//submit this vote
xmlhttp.send();
})
}
function submitTimes(videoID) {
//get the video times from storage
let sponsorTimeKey = 'sponsorTimes' + videoID;
@@ -130,6 +145,7 @@ function videoIDChange(currentVideoID) {
function getUserID(callback) {
if (userID != null) {
callback(userID);
return;
}
//if it is not cached yet, grab it from storage