var Review=new ReviewsModel;function extractReviews(){var e=document.getElementById("product-schema").textContent,o=JSON.parse(e).review;return o.forEach((e=>{e.rivyoo&&(e.rivyoo=new RivYooModel(e))})),o}defer((function(){try{ko.applyBindings(Review,document.getElementById("view-reviews"))}catch(e){console.log(e)}}));var title=document.title;function shareReview(e,o){navigator.share?navigator.share({title:title,text:"Checkout "+o+"`s review!",url:"https://www.rivyoo.co.uk/review/"+e}):alert("Error, upgrade browser!")}function ratingHelpful(e,o){rivyoo_w=window.open("https://www.rivyoo.co.uk/api/likeReview_ui?UID="+o,"Popup_Window","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=560,height=550,left = 312,top = 234"),rivyoo_w.focus()}function RivYooModel(e){var o=e.rivyoo,t=this;t.name=e.author.name,t.id=o.rid,t.invoice=o.invoice,t.likes=o.likes,t.products=o.products,t.responses=o.responses,t.verified=o.verified,t.click_buy_products=function(){getProducts(t.invoice),modalOpen(document.getElementById("buy-reviewed-products"))},t.click_useful=function(){ratingHelpful("Y",t.id)},t.click_share=function(){shareReview(t.id,t.name)}}function ReviewsModel(){var e=this;e.review=ko.observableArray(extractReviews()),e.page=ko.observable(1),e.pages=ko.computed((function(){return Math.ceil(e.review().length/5)})),e.updateReviews=function(o){for(var t=0;t=2&&t<=e.pages()-1&&o.push(t);return o.push(e.pages()),o},e.setPage=function(o){e.page(o);var t=document.querySelector("#revCont");t&&(setTimeout((function(){t.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})}),0),setTimeout((function(){t.focus()}),100))},e.filterPage=function(){var o=5*(e.page()-1),t=o+5;return e.review().slice(o,t)}}