Difference between revisions of "StarRating"

From Sega Retro

Line 1: Line 1:
<includeonly>{{#vardefine:imagesize|10}}{{#vardefine:full|RatingStar Full.svg}}{{#vardefine:half|RatingStar Half.svg}}{{#vardefine:empty|RatingStar Empty.svg}}{{#vardefine:starrating|{{{1|0}}}}}{{#vardefine:total|{{{2|5}}}}}{{#vardefine:halfCheck|}}{{#ifeq:{{#pos:{{#var:starrating}}|.5}}|||{{#vardefine:halfCheck|true}}}}{{#vardefine:i|0}}{{#while:
+
<includeonly>{{#vardefine:imagesize|10}}{{#vardefine:full|RatingStar Full.svg}}{{#vardefine:half|RatingStar Half.svg}}{{#vardefine:empty|RatingStar Empty.svg}}{{#vardefine:starrating|{{{1|0}}}}}{{#vardefine:total|{{{2|5}}}}}{{#vardefine:halfCheck|}}{{#ifeq:{{#pos:{{#var:starrating}}|.5}}|||{{#vardefine:halfCheck|true}}}}{{#vardefine:i|0}}<span style="white-space:nowrap;">{{#while:
 
| {{#expr:{{#var:i}} < {{#var:total}}}}{{incvar|i}}
 
| {{#expr:{{#var:i}} < {{#var:total}}}}{{incvar|i}}
 
| {{#ifexpr:{{#var:i}} <= {{#var:starrating}}|[[File:{{#var:full}}|{{#var:imagesize}}px|link=|]]|{{#if:{{#var:halfCheck}}|[[File:{{#var:half}}|{{#var:imagesize}}px|link=|]]{{#vardefine:halfCheck|}}|[[File:{{#var:empty}}|{{#var:imagesize}}px|link=|]]}}}}
 
| {{#ifexpr:{{#var:i}} <= {{#var:starrating}}|[[File:{{#var:full}}|{{#var:imagesize}}px|link=|]]|{{#if:{{#var:halfCheck}}|[[File:{{#var:half}}|{{#var:imagesize}}px|link=|]]{{#vardefine:halfCheck|}}|[[File:{{#var:empty}}|{{#var:imagesize}}px|link=|]]}}}}
}}{{#vardefine:scoreoverride|{{#expr:({{#var:starrating}}/{{#var:total}})*100}}}}</includeonly><noinclude>
+
}}</span>{{#vardefine:scoreoverride|{{#expr:({{#var:starrating}}/{{#var:total}})*100}}}}</includeonly><noinclude>
 
A template to display "star" ratings.
 
A template to display "star" ratings.
  

Revision as of 09:09, 26 November 2023

A template to display "star" ratings.

Usage

{{StarRating|3|5}}

Produces: RatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Empty.svgRatingStar Empty.svg

{{StarRating|33|50}}

Produces: RatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svg

{{StarRating|3.5|5}}

Produces: RatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Half.svgRatingStar Empty.svg

{{StarRating|33.5|50}}

Produces: RatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Full.svgRatingStar Half.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svgRatingStar Empty.svg