mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-02-03 08:10:43 +03:00
Add message when connection failed when trying to vote.
This commit is contained in:
@@ -87,7 +87,7 @@ function addSponsorTime(time) {
|
|||||||
function submitVote(type, UUID, callback) {
|
function submitVote(type, UUID, callback) {
|
||||||
getUserID(function(userID) {
|
getUserID(function(userID) {
|
||||||
//publish this vote
|
//publish this vote
|
||||||
sendRequestToUser('GET', "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp) {
|
sendRequestToUser('GET', "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) {
|
||||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||||
callback({
|
callback({
|
||||||
successType: 1
|
successType: 1
|
||||||
@@ -97,6 +97,11 @@ function submitVote(type, UUID, callback) {
|
|||||||
callback({
|
callback({
|
||||||
successType: 0
|
successType: 0
|
||||||
});
|
});
|
||||||
|
} else if (error) {
|
||||||
|
//error while connect
|
||||||
|
callback({
|
||||||
|
successType: -1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -180,7 +185,11 @@ function sendRequestToUser(type, address, callback) {
|
|||||||
xmlhttp.open(type, serverAddress + address, true);
|
xmlhttp.open(type, serverAddress + address, true);
|
||||||
|
|
||||||
xmlhttp.onreadystatechange = function () {
|
xmlhttp.onreadystatechange = function () {
|
||||||
callback(xmlhttp);
|
callback(xmlhttp, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
xmlhttp.onerror = function(ev) {
|
||||||
|
callback(xmlhttp, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
//submit this request
|
//submit this request
|
||||||
|
|||||||
@@ -390,6 +390,9 @@ function vote(type, UUID) {
|
|||||||
} else if (response.successType == 0) {
|
} else if (response.successType == 0) {
|
||||||
//failure: duplicate vote
|
//failure: duplicate vote
|
||||||
votingError("It seems you've already voted before", UUID)
|
votingError("It seems you've already voted before", UUID)
|
||||||
|
} else if (response.successType == -1) {
|
||||||
|
//failure: duplicate vote
|
||||||
|
votingError("A connection error has occured.", UUID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
3
popup.js
3
popup.js
@@ -400,6 +400,9 @@ function vote(type, UUID) {
|
|||||||
} else if (response.successType == 0) {
|
} else if (response.successType == 0) {
|
||||||
//failure: duplicate vote
|
//failure: duplicate vote
|
||||||
addVoteMessage("You have already voted this way before.", UUID)
|
addVoteMessage("You have already voted this way before.", UUID)
|
||||||
|
} else if (response.successType == -1) {
|
||||||
|
//failure: duplicate vote
|
||||||
|
addVoteMessage("A connection error has occured.", UUID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user