HtmlFormatterV3 = { initialize: function() { }, getHtml: function(item, dim) { if(item == null) { return ""; } //create random number to keep ids unique (in case the same product appears in two similar sliders) var r_num = Math.random(); r_num = Math.ceil(r_num * 100); if ((item.type == 'homepage_category_products') || (item.type == 'simliar_product') || (item.type == 'related_category')) { //homepage return '
' +'

'+ item.title + '

'+ '
'+ '
'+ '
'+ '
'+ '
'+ '
'+ '£'+ item.price + '
'+ '
'+ '
'+ '
'+ '
'; } else if (item.type == 'related_nav_category') { //square "Related Products" on Categories page return '
' +'

'+ item.title + '

'+ '
'+ '
'+ '
'+ '
'+ '
'+ '
'+ '
'+ '£'+ item.price + '
'+ '
'+ '
'+ '
'+ '
'+ '
'; } else if(item.type == 'main_category') { //categories page product slider (NOTE: needs to stay consistant with code in category_select.php) return '
'+ '

'+ item.title+'

'+ '
 '+ '
'+ '
'+ '£'+item.price+ '
' + '
'+helloworld(item.star_total,item.num_star_ratings)+'
'+ '
'; } else if (item.type == 'recently_viewed_items') //was 'recent_deal' { //"Recently Viewed Items" slider if (item.product_slug !== undefined) { //ts (internal link) url = '/products/'+ item.product_slug; } else { //td (external link) url = item.product_url; } return '
' +'
' +'
' +'
' +'
' +' £'+ item.price +'
' +'
' +'
' +'
' +'
'; } else if (item.type == 'tommy_s_deals') { //"Tommy's Deals" main product slider return '
' +'
'+ item.product_name +'
' +'
' +' ' +'
' +'
' +'
' +'
' +'
' +'
'+ item.discount +'% off
' +'
' +'
'+ item.product_rrp +'
' +'
£'+ item.product_price +'
' +'
' +'
'+ item.description +'
' +' ' +'
' +'
'; } return ""; } } function helloworld(star_total,num_star_ratings){ //get average if (num_star_ratings != 0) { //to avoid 'divide by 0' error avg_rating = star_total / num_star_ratings; } else { avg_rating = 0; } avg_rating = Math.round(avg_rating / 0.5) * 0.5; //round to nearest half num_ratings = num_star_ratings; star_avg_rating = ""; lg_sm ='lg'; for(i=0; i < Math.floor(avg_rating); i++) { star_avg_rating += '
'; } if (avg_rating > Math.floor(avg_rating)) { //if there's a half star_avg_rating += '
'; added_stars = Math.floor(avg_rating) + 1; } else { added_stars = Math.floor(avg_rating); } for(i = added_stars; i<5; i++) { star_avg_rating += '
'; } return star_avg_rating; }