‘;
document.getElementById(“poll-options”).innerHTML += ‘
‘;
}
} else {
document.getElementById(“poll-options”).innerHTML = ‘
‘‘ +
‘‘ +
‘
‘ + pollData.option1 + ‘
‘ +
‘
‘ +
‘
‘ +
‘
‘;
document.getElementById(“poll-options”).innerHTML += ‘
‘‘ +
‘‘ +
‘
‘ + pollData.option2 + ‘
‘ +
‘
‘ +
‘
‘ +
‘
‘;
}
if(totalVotes > 10) {
var countElem = document.getElementById(“poll-count”);
countElem.classList.remove(“hidden”);
}
}
function getPollData() {
}
getPollData();
function onPollResponseSuccess(optionElem) {
var expiryTime = new Date();
expiryTime.setMonth(expiryTime.getMonth() + 6); // Expiry after 6 months
setCookie(“article_poll_911225”, optionElem.id, expiryTime);
var options = optionElem.parentNode.getElementsByClassName(“poll-option”);
for(var option of options) {
option.classList.add(“poll-option-answered”);
if (option.id == optionElem.id) {
option.classList.add(“poll-option-selected”);
option.getElementsByClassName(“poll-option-selected-percent”)[0].classList.remove(“hidden”);
option.getElementsByClassName(“poll-option-selected-color”)[0].classList.remove(“hidden”);
} else {
option.getElementsByClassName(“poll-option-response-percent”)[0].classList.remove(“hidden”);
option.getElementsByClassName(“poll-option-response-color”)[0].classList.remove(“hidden”);
}
option.onclick = null;
updatePollCountOnAnswer(optionElem.id);
}
}
function updatePollCountOnAnswer(selectedOption) {
var pollData = null;
if(selectedOption == “option1”) pollData.option1_count += 1;
if(selectedOption == “option2”) pollData.option2_count += 1;
var totalVotes = pollData.option1_count + pollData.option2_count;
var option1Percent = pollData.option1_count/totalVotes * 100 | 0;
option1Percent = parseInt(option1Percent, 10);
var option1SelectedPercent = (pollData.option1_count)/totalVotes * 100 | 0;
option1SelectedPercent = parseInt(option1SelectedPercent, 10);
var option2Percent = pollData.option2_count/totalVotes * 100 | 0;
option2Percent = parseInt(option2Percent, 10);
var option2SelectedPercent = (pollData.option2_count)/totalVotes * 100 | 0;
option2SelectedPercent = parseInt(option2SelectedPercent, 10);
document.getElementById(“poll-options”).innerHTML = ‘
‘‘ +
‘
‘ + pollData.option1 + ‘
‘ +
‘
‘ + (selectedOption === “option1” ? option1SelectedPercent : option1Percent) + ‘%
‘ +
‘
‘;
document.getElementById(“poll-options”).innerHTML += ‘
‘‘ +
‘
‘ + pollData.option2 + ‘
‘ +
‘
‘ + (selectedOption === “option2” ? option2SelectedPercent : option2Percent) + ‘%
‘ +
‘
‘;
document.getElementById(“poll-count”).innerHTML = totalVotes + ‘ votes so far’;
return;
}
function answerPoll(optionElem) {
gtag(‘event’, ‘click’, {
‘event_category’: ‘Article Poll_20Aug2021’,
‘event_label’: optionElem.id.replace(“option”, “Option “)
});
var url = ‘https://gotham.sportskeeda.com/polls//response’;
var data = {
“poll_type”: “article”,
“option”: optionElem.id
}
pureJSAjaxPost(url, data, onPollResponseSuccess.bind(this, optionElem), null, null, false);
}
“;
modalText += “
“;
modalText += “
“;
modalText += “
“;
modalText += “
“;
modalText += “
“;
modalText += “
“;
modalText += “”
modalText += “
”
modalText += “
”
modalPopup.closeOnEsc = false;
modalPopup.setHeader(“Why did you not like this content?”);
modalPopup.setContentText(modalText);
modalPopup.addCancelOkButton(“Submit”, resetRatingAndFeedbackForm, sendRating);
modalPopup.removeCloseModalIcon();
modalPopup.disableDismissPopup();
var userRatedPostIds = getCookie(‘user_rated_post_ids’);
if (!userRatedPostIds) userRatedPostIds = [];
else {
try {
userRatedPostIds = JSON.parse(userRatedPostIds);
} catch (err) {
console.error(err);
userRatedPostIds = [];
}
}
if (userRatedPostIds.indexOf(911225) >= 0) {
$(“#post-rating-layout”).classList.add(“hidden”);
}
function ratePost(index) {
ratingValue = index;
var theStarClasses = Array.from($(“#star-” + index).classList);
if (theStarClasses.indexOf(“active”) index; i–) {
$(“#star-” + i).classList.remove(“active”);
}
}
if (index 3) {
requestPayload.rating_feedback_type = null;
requestPayload.rating_feedback = null;
} else {
if (!$(‘input[name=”drone”]:checked’) || !$(‘input[name=”drone”]:checked’).value) {
showErrorMessage(‘option’);
return;
}
if (!$(“.post-rating-feedback-note textarea”) || !$(“.post-rating-feedback-note textarea”).value) {
showErrorMessage(‘note’);
return;
}
var selectedOption = $(‘input[name=”drone”]:checked’).value;
var feedbackNote = $(“.post-rating-feedback-note textarea”).value;
requestPayload.rating_feedback_type = selectedOption;
requestPayload.rating_feedback = feedbackNote;
}
pureJSAjaxPost(addratingAPI, requestPayload, onsaveRatingSuccess, onsaveRatingFail, function() {}, true);
}
function resetRatingAndFeedbackForm() {
var activeStars = Array.from($all(‘.rating span.rating-star.active’));
for (var i=0; i = 0) {
return true;
} else {
return false;
}
}
function getRatingCountByPostId(postId) {
return new Promise(function(resolve, reject) {
pureJSAjaxGet(
getRatingCountBaseURL + postId + ‘/rating/count’,
function(data) {
try {
data = JSON.parse(data);
if (data.meta_value) {
resolve(data.meta_value);
}
reject(“Failed to fetch rating count for the post:” + postId);
} catch (err) {
reject(“Failed to fetch rating count for the post:” + postId);
}
},
function(err) {
reject(“Failed to fetch rating count for the post:” + postId);
}, true);
});
}
function showErrorMessage(messageType) {
var messageContainerId = ‘#’ + messageType + ‘-error’;
$(messageContainerId).classList.remove(‘hidden’);
window.setInterval(function () {
$(messageContainerId).classList.add(“hidden”);
}, 5000);
}
if (!isPostRatedByUser()) {
getRatingCountByPostId(911225)
.then(function(ratingCount) {
if (ratingCount