diff options
author | Ajay Ramachandran <[email protected]> | 2020-02-01 16:41:08 -0500 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2020-02-01 16:41:08 -0500 |
commit | 4a491f1ebf0702125eca60aea42dc21b2832bc0e (patch) | |
tree | 0ce064d03909a17d3ad206a44730898179c7d7f5 /src/background.ts | |
parent | 5ebdfd84669d40a7c48685a3906fb17b7ae53b54 (diff) | |
download | SponsorBlock-4a491f1ebf0702125eca60aea42dc21b2832bc0e.tar.gz SponsorBlock-4a491f1ebf0702125eca60aea42dc21b2832bc0e.zip |
Moved server code to utils
Diffstat (limited to 'src/background.ts')
-rw-r--r-- | src/background.ts | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/src/background.ts b/src/background.ts index cd259b7d..29f63c51 100644 --- a/src/background.ts +++ b/src/background.ts @@ -153,7 +153,7 @@ function submitVote(type, UUID, callback) { } //publish this vote - sendRequestToServer("POST", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) { + Utils.sendRequestToServer("POST", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { callback({ successType: 1 @@ -205,7 +205,7 @@ async function submitTimes(videoID, callback) { let increasedContributionAmount = false; //submit the sponsorTime - sendRequestToServer("GET", "/api/postVideoSponsorTimes?videoID=" + videoID + "&startTime=" + sponsorTimes[i][0] + "&endTime=" + sponsorTimes[i][1] + Utils.sendRequestToServer("GET", "/api/postVideoSponsorTimes?videoID=" + videoID + "&startTime=" + sponsorTimes[i][0] + "&endTime=" + sponsorTimes[i][1] + "&userID=" + userID, function(xmlhttp, error) { if (xmlhttp.readyState == 4 && !error) { callback({ @@ -227,23 +227,4 @@ async function submitTimes(videoID, callback) { }); } } -} - -function sendRequestToServer(type, address, callback) { - let xmlhttp = new XMLHttpRequest(); - - xmlhttp.open(type, serverAddress + address, true); - - if (callback != undefined) { - xmlhttp.onreadystatechange = function () { - callback(xmlhttp, false); - }; - - xmlhttp.onerror = function(ev) { - callback(xmlhttp, true); - }; - } - - //submit this request - xmlhttp.send(); -} +}
\ No newline at end of file |