![]() |
VOOZH | about |
This module implements {{iconbar}}. It should generally be invoked directly on template pages, rather than using the iconbar template.
Parent arguments are automatically merged with directly passed arguments (the latter overwriting the former).
localp={} functionp.bar(f) localargs=require('Module:ProcessArgs').merge() locallink=args.linkor'' localfull=args.full localhalf=args.halfor'Half '..full localempty=args.emptyor'Empty '..full localfullAlt=args.fullaltorargs.altor'' localhalfAlt=args.halfaltorargs.altor'' localemptyAlt=args.emptyaltorargs.altor'' localvalue=math.abs(tonumber(args.value)or0)/2 localmin=math.ceil(math.abs(tonumber(args.min)or0)/2) localsize=args.sizeor'' localtitle=args.titleor'' localreverse=args.reverseor'' localoffset=args.offsetor'' iftitle:lower()=='none'then title='' elseiftitle~=''then title=' title="'..title..'"' else title=' title="'..value..'"' end localfullIcon='' localhalfIcon='' localemptyIcon='' iftonumber(size)then size='|'..size..'px' elseifsize~=''then size='|'..size end ifoffset~=''then offset=' style="--icon-offset:'..offset..';"' else offset=' style="--icon-offset:-'..((size:match('%d+',1)or9)/9)..'px;"' end ifvalue==0then emptyIcon='[[File:'..empty..size..'|link='..link..'|alt='..emptyAlt..']]' else fullIcon=string.rep('[[File:'..full..size..'|link='..link..'|alt='..fullAlt..']]',math.floor(value)) ifmath.floor(value)~=valuethen halfIcon='[[File:'..half..size..'|link='..link..'|alt='..halfAlt..']]' end end ifmin-value>=1then emptyIcon=string.rep('[[File:'..empty..size..'|link='..link..'|alt='..emptyAlt..']]',min-math.ceil(value)) end ifreverse~=''then return'<span class="iconbar pixel-image nowrap"'..offset..title..'>'..emptyIcon..halfIcon..fullIcon..'</span>' else return'<span class="iconbar pixel-image nowrap"'..offset..title..'>'..fullIcon..halfIcon..emptyIcon..'</span>' end end returnp