0) {
$('#ContentPlaceHolder1_ucRatingWidget_hidRatings').val(ratingValue);
msg = "Thanks! You rated this " + ratingValue + " stars.";
}
else {
$('#ContentPlaceHolder1_ucRatingWidget_hidRatings').val(0);
msg = "We will improve ourselves. You rated this " + ratingValue + " stars.";
}
});
var ratings = $('#ContentPlaceHolder1_ucRatingWidget_hdStarRatings').val();
if (ratings >=3) {
$('#rating').show();
}
});
function CreateStar(id, j, mainstar, next, frac) {
if (j <= mainstar) {
$(id).css("color", "#ffa500");
}
else if (j == next && !isNaN(frac)) {
$('body').append("");
$(id).addClass("half");
}
else {
$(id).css("color", "#BAA9A9");
}
}
function SubmitReview() {
var ratings = $('#ContentPlaceHolder1_ucRatingWidget_hidRatings').val();
var ItemID = getQueryString("ItemID");
var title = $('#ContentPlaceHolder1_ucRatingWidget_divItemName').html();
var revTitle = $('#txtReviewTitle').val();
var review = $('#txtReviewComment').val();
var orderid = $('#txtOrderID').val();
var fname = $('#txtFName').val();
var lname = $('#txtLName').val();
var email = $('#txtEmail').val();
var mailformat = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
$('#ContentPlaceHolder1_ucRatingWidget_spnRating').hide();
$('#ContentPlaceHolder1_ucRatingWidget_spnReviewtitle').hide();
$('#ContentPlaceHolder1_ucRatingWidget_spnReviewComment').hide();
$('#ContentPlaceHolder1_ucRatingWidget_spnOrderid').hide();
$('#ContentPlaceHolder1_ucRatingWidget_spnValidOrderID').hide();
$('#ContentPlaceHolder1_ucRatingWidget_spnFName').hide();
$('#ContentPlaceHolder1_ucRatingWidget_spnLname').hide();
$('#ContentPlaceHolder1_ucRatingWidget_spnEmail').hide();
if (ratings === '0')
$('#ContentPlaceHolder1_ucRatingWidget_spnRating').show();
if (revTitle.length === 0 || revTitle === '')
$('#ContentPlaceHolder1_ucRatingWidget_spnReviewtitle').show();
if (review.length === 0 || review === '')
$('#ContentPlaceHolder1_ucRatingWidget_spnReviewComment').show();
if (orderid === '' || orderid.length === 0 || orderid.length < 7)
$('#ContentPlaceHolder1_ucRatingWidget_spnValidOrderID').show();
if (isNaN(orderid))
$('#ContentPlaceHolder1_ucRatingWidget_spnOrderid').show();
if (fname.length === 0 || fname === '')
$('#ContentPlaceHolder1_ucRatingWidget_spnFName').show();
if (lname.length === 0 || lname === '')
$('#ContentPlaceHolder1_ucRatingWidget_spnLname').show();
if (email.length === 0 || email === '' || !mailformat.test(String(email).toLowerCase()))
$('#ContentPlaceHolder1_ucRatingWidget_spnEmail').show();
if (ratings === '0' || revTitle.length === 0 || review.length === 0 || fname.length === 0 || lname.length === 0 || email.length === 0 || isNaN(orderid) || orderid.length === 0 || orderid.length < 7 || !mailformat.test(String(email).toLowerCase()))
return false;
else {
PageMethods.set_path("/ProductDetail.aspx");
PageMethods.InsertProductReview(ItemID, title, revTitle, review, orderid, fname, lname, ratings, email, InsertProductReviewSuccess, InsertProductReviewFailure);
}
return false;
}
function InsertProductReviewSuccess() {
var isqcoui = getQueryString("isqc");
var itemid = getQueryString("ItemID");
PageMethods.GetRatingWidgetUserControl('RatingWidget', isqcoui, itemid, successRatingWidget, ErrorSubmitting);
}
function successRatingWidget(ratings) {
$('#divProductReviews').html(ratings);
$('#review_form').hide();
$('#txtReviewTitle').val('');
$('#txtReviewComment').val('');
$('#txtOrderID').val('');
$('#txtFName').val('');
$('#txtLName').val('');
$('#txtEmail').val('');
$('#stars li').removeClass('star selected').addClass("star");
$('#ContentPlaceHolder1_ucRatingWidget_divRatingblock').show();
$("#rating").show();
$("#divSubmitSuccess").show();
$(".iangletag").removeClass("fa fa-angle-down").addClass("fa fa-angle-up");
return false;
}
function ErrorSubmitting() {
//alert("something went wrong");
}
function InsertProductReviewFailure() {
alert('Something went wrong, please try again.');
return false;
}
//Pagination
var pgPrefix = "pg";
var currPage = 1;
var recCount = 1;
var pgSize = 10;
var pgCount = 1;
function managePageNumbers() {
var obj = document.getElementById("pageNumbers");
obj.innerHTML = "";
for (i = 1; i <= pgCount; i++)
obj.innerHTML += "
" + i + " ";
}
function showPage(pageNum) {
var pgName = pgPrefix + pageNum;
var obj = document.getElementById("dvRecords");
var divs = obj.getElementsByClassName("pageable");
currPage = pageNum;
for (i = 0; i <= divs.length - 1; i++) {
if (divs[i].getAttribute("name") == pgName)
divs[i].style.display = "block";
else
divs[i].style.display = "none";
}
var element = document.getElementsByClassName("current-page");
if (element.length > 0) {
for (i = 0; i <= element.length - 1; i++)
element[i].classList.remove('current-page');
}
document.getElementById('pageNumber' + pageNum).className = 'current-page';
document.getElementById("divratingwidget").scrollIntoView({ behavior: "smooth" });
var getLastDiv = document.getElementsByClassName(pgName);
if (getLastDiv.length > 0)
getLastDiv[getLastDiv.length - 1].children[1].style.display = 'none';
}
function hidePage() {
var pageableLength = document.getElementsByClassName("pageable").length;
if (length > 0)
document.getElementsByClassName("pageable")[pageableLength - 1].children[1].style.display = 'none';
var divpagination = document.getElementsByClassName("pagination");
divpagination[0].style.display = "none";
}
function managePaging() {
var obj = document.getElementById("dvRecords");
var divs = obj.getElementsByClassName("pageable");
if (divs.length > pgSize) {
for (i = 0; i <= divs.length - 1; i++) {
if (recCount > pgSize) {
pgCount++;
recCount = 0;
}
var pgName = pgPrefix + pgCount; // Create div name as per current page
if (divs[i].className != null && divs[i].className == "pageable") {
divs[i].setAttribute("name", pgName);
divs[i].classList.add(pgName);
}
recCount++;
}
var divpagination = document.getElementsByClassName("pagination");
divpagination[0].style.display = "block";
managePageNumbers();
showPage(currPage);
} else
hidePage();
}
function moveNext() {
if ((currPage + 1) > pgCount)
currPage = 1;
else
currPage++;
showPage(currPage);
}
function movePrevious() {
if ((currPage - 1) < 1)
currPage = pgCount;
else
currPage--;
showPage(currPage);
}