jQuery(".io_testimonials, #io_testimonials").each(function(){ io_get_reviews(this); }) setTimeout(function(){ jQuery(".io_testimonials .w3-ul li p").each(function(){ const container = jQuery(this).parent() const element = jQuery(this); if (element[0].scrollHeight > container[0].clientHeight) { jQuery(this).parent().parent().append(create_read_more()); } }); }, 500); function create_read_more(){ let html = "

read more

" return html; } function review_readmore_clicked(element){ let review_li = jQuery(element).parent().find("li:eq(3)"); new_height = jQuery(review_li).find("p").height() + 16; jQuery(review_li).height(new_height); jQuery(element).hide(); } function io_get_reviews(element){ let io_un = "ndsuddarth"; let io_loc = "493"; let io_url1 = 'https://rental.software/testimonials_iframe.php?user='; if (location.hostname === "localhost"){ io_url1 = 'http://localhost/io/bugs/testimonials_iframe.php?user='; //io_url1 = 'http://localhost/jbug/trunk/testimonials_iframe.php?user='; } let io_url2 = '&location_id='; let io_url3 = '&width=100%&number_of_reviews=10&show_average_rating=1&show_stars=1&show_date=&show_reviewer_name=1&orderby=time&iframe=0'; let io_url_c = io_url1 + io_un + io_url2 + io_loc + io_url3; fetch(io_url_c, { method: 'get' }).then( function(response){ return response.json(); } ).then(function(data) { //let element = document.getElementById("io_testimonials"); let out = ""; let review_cnt=0; let rating_sum = 0; data.forEach((user) => { const { name, review, rating, time } = user; rating_sum += Number(rating); review_cnt++; let img_star = Math.round(parseFloat(rating)); star = ``; out += `
`; }); let avg = (parseFloat(rating_sum)/parseFloat(review_cnt)).toFixed(1); let avg_img = Math.round(avg); let head = `

Avg Rating: ${avg}

`; element.innerHTML = head + out; return head+out; }).catch(function(err) { console.log(err); }); }