Modulo:StileAttacco: differenze tra le versioni
Aspetto
Production version - remove debug |
Intestazioni esplicite |
||
| Riga 48: | Riga 48: | ||
local headerRow = html:tag('tr') | local headerRow = html:tag('tr') | ||
headerRow:tag('th'):css('width', ' | headerRow:tag('th'):css('width', '25%'):wikitext('Possesso') | ||
headerRow:tag('th'):css('width', '20%'):wikitext('vs Atout') | headerRow:tag('th'):css('width', '20%'):wikitext('Attacco vs Atout') | ||
headerRow:tag('th'):css('width', '20%'):wikitext('vs SA') | headerRow:tag('th'):css('width', '20%'):wikitext('Attacco vs SA') | ||
headerRow:tag('th'):css('width', ' | headerRow:tag('th'):css('width', '35%'):wikitext('Su attacco del compagno') | ||
for _, row in ipairs(rows) do | for _, row in ipairs(rows) do | ||
Versione attuale delle 06:39, 12 mar 2026
La documentazione per questo modulo può essere creata in Modulo:StileAttacco/man
local p = {}
function p.tabella(frame)
local parentFrame = frame:getParent()
local args = nil
if parentFrame then
local val = parentFrame.args['lead_holding_1']
if val and val ~= '' then
args = parentFrame.args
end
end
if not args then
local val = frame.args['lead_holding_1']
if val and val ~= '' then
args = frame.args
end
end
if not args then
return ''
end
local rows = {}
for i = 1, 99 do
local val = args['lead_holding_' .. i]
if not val or val == '' then
break
end
local parts = {}
for part in (val .. ';'):gmatch('([^;]*);') do
table.insert(parts, mw.text.trim(part))
end
while #parts < 4 do
table.insert(parts, '')
end
table.insert(rows, parts)
end
if #rows == 0 then
return ''
end
local html = mw.html.create('table')
:addClass('wikitable')
:css('width', '100%')
:css('margin-top', '8px')
local headerRow = html:tag('tr')
headerRow:tag('th'):css('width', '25%'):wikitext('Possesso')
headerRow:tag('th'):css('width', '20%'):wikitext('Attacco vs Atout')
headerRow:tag('th'):css('width', '20%'):wikitext('Attacco vs SA')
headerRow:tag('th'):css('width', '35%'):wikitext('Su attacco del compagno')
for _, row in ipairs(rows) do
local tr = html:tag('tr')
tr:tag('td'):css('font-weight', 'bold'):wikitext(row[1])
tr:tag('td'):css('text-align', 'center'):wikitext(row[2])
tr:tag('td'):css('text-align', 'center'):wikitext(row[3])
tr:tag('td'):css('text-align', 'center'):wikitext(row[4])
end
return tostring(html)
end
return p