Diferencia entre revisiones de «Módulo:Iconbar»
Página creada con «local p = {} function p.bar( f ) local args = require( 'Module:ProcessArgs' ).merge() local full = args.full local half = args.half or 'Half ' .. full local empty = arg...» |
importado>ImportMC Actualización: Añade parámetros link y alt y clase pixel-image |
||
| (No se muestra una edición intermedia de otro usuario) | |||
| Línea 1: | Línea 1: | ||
local p = {} | local p = {} | ||
function p.bar( f ) | function p.bar( f ) | ||
local args = require( ' | local args = require( 'Módulo:ProcessArgs' ).merge() | ||
local alt = args.alt or '' | |||
local link = args.link or '' | |||
local full = args.full | local full = args.full | ||
local half = args.half or 'Half ' .. full | local half = args.half or 'Half ' .. full | ||
| Línea 18: | Línea 20: | ||
title = ' title="' .. value .. '"' | title = ' title="' .. value .. '"' | ||
end | end | ||
local fullIcon = '' | local fullIcon = '' | ||
local halfIcon = '' | local halfIcon = '' | ||
| Línea 30: | Línea 32: | ||
if value == 0 then | if value == 0 then | ||
emptyIcon = '[[File:' .. empty .. size .. ']]' | emptyIcon = '[[File:' .. empty .. size .. '|link=' .. link .. '|alt=' .. alt .. ']]' | ||
else | else | ||
fullIcon = string.rep( '[[File:' .. full .. size .. ']]', math.floor( value ) ) | fullIcon = string.rep( '[[File:' .. full .. size .. '|link=' .. link .. '|alt=' .. alt .. ']]', math.floor( value ) ) | ||
if math.floor( value ) ~= value then | if math.floor( value ) ~= value then | ||
halfIcon = '[[File:' .. half .. size .. ']]' | halfIcon = '[[File:' .. half .. size .. '|link=' .. link .. '|alt=' .. alt .. ']]' | ||
end | end | ||
end | end | ||
if min - value >= 1 then | if min - value >= 1 then | ||
emptyIcon = string.rep( '[[File:' .. empty .. size .. ']]', min - math.ceil( value ) ) | emptyIcon = string.rep( '[[File:' .. empty .. size .. '|link=' .. link .. '|alt=' .. alt .. ']]', min - math.ceil( value ) ) | ||
end | end | ||
if reverse ~= '' then | if reverse ~= '' then | ||
return '<span class="nowrap"' .. title .. '>' .. emptyIcon .. halfIcon .. fullIcon .. '</span>' | return '<span class="pixel-image nowrap"' .. title .. '>' .. emptyIcon .. halfIcon .. fullIcon .. '</span>' | ||
else | else | ||
return '<span class="nowrap"' .. title .. '>' .. fullIcon .. halfIcon .. emptyIcon .. '</span>' | return '<span class="pixel-image nowrap"' .. title .. '>' .. fullIcon .. halfIcon .. emptyIcon .. '</span>' | ||
end | end | ||
end | end | ||
return p | return p | ||