$("#subject_picker").val(0);var current_page=1;var loading=false;var pages=parseInt($("meta[name=no-of-pages]").attr('content'));$(document).ready(function(){$(document).on('click','.move-page-link',function(e){e.preventDefault();var page=$(this).data('href');if('prev'==page&&1==current_page){return}if('next'==page&&pages==current_page){return}if(page==0||page==current_page){return}else{if('prev'==page){page=current_page-1}if('next'==page){page=current_page+1}var subject=parseInt($("#subject_picker").val());navigate(subject,page)}});$(document).on('change','#subject_picker',function(){var subject=parseInt($("#subject_picker").val());navigate(subject,1)});function navigate(subject,page){if(loading==true){return}current_page=page;var send_data={subject:subject,page:page,_token:$("meta[name=csrf-token]").attr("content")};loading=true;$(".preloader").show();$.ajax({type:"GET",data:send_data,url:window.location.origin+'/pages/reviews',dataType:"JSON",success:function(response){$("#section-reviews-container").html('
No reviews matching your search
');if(typeof response.reviews!=='undefined'&&response.reviews.length){var items='';response.reviews.forEach(function(item){var rate=item.stars;items+='
';items+='
';items+='
';items+='
';[1,2,3,4,5].forEach(function(star){if(Math.floor(rate)>=star||(Math.floor(rate)+1==star&&rate-Math.floor(rate)>=0.5)){items+=' '}else if(Math.floor(rate)+1==star&&rate-Math.floor(rate)<0.5&&rate-Math.floor(rate)>0){items+=' '}else{items+=' '}});items+='
';if($.trim(item.subject)){items+='
'+item.subject+'
'}if(item.deadline>0){items+='
Deadline: '+item.deadline+' days
'}items+='
';if($.trim(item.title)){items+='
'+item.title+'
'}if($.trim(item.feedback)){items+='
'+item.feedback+'
'}items+='
';if(item.details.length){item.details.forEach(function(scope){var stars=scope.stars;items+='
';items+='
'+scope.name+'
';items+='
';[1,2,3,4,5].forEach(function(star){if(Math.floor(stars)>=star||(Math.floor(stars)+1==star&&stars-Math.floor(stars)>=0.5)){items+=' '}else if(Math.floor(stars)+1==star&&stars-Math.floor(stars)<0.5&&stars-Math.floor(stars)>0){items+=' '}else{items+=' '}});items+='
';items+='
'})}items+='
';items+='';items+='
';items+='
'});var no_of_pages=response.no_of_pages;if(no_of_pages>1){var pages='';$('#paginationController').html(pages)}else{$('#paginationController').html("")}$("#section-reviews-container").html(items)}if(!response.status){swal.fire({icon:'warning',title:response.title,html:response.message})}loading=false;$(".preloader").hide()},error:function(jqXHR,textStatus,errorThrown){loading=false;$(".preloader").hide()}})}});