Content deleted Content added
SocietyBox (talk | contribs) m add border-collapse:separate to fix mobile view |
per edit request on talk page - fix the node_function{orphan} bug |
||
(18 intermediate revisions by 7 users not shown) | |||
Line 6:
'Third place'
},
-- The text and background colors are paired and when you set one, you should set the other (accessibility)
textColor = {head = '#202122', '#202122', '#202122', '#202122', '#202122'},
bgColor = {head = '#f2f2f2', 'gold', 'silver', '#C96', '#f9f9f9'},
reuseStr = {},
Line 154 ⟶ 156:
end
local function newRow(bodyRow)
local first = p.flex_tree.merge and mw.clone(p.flex_tree.cell) or p.flex_tree.cell
tab.r = tab:tag'tr'
Line 167 ⟶ 169:
end
local function drawHead(text, row3rd)
local td = (row3rd and rowNum[row3rd]:tag'td':attr{rowspan = 2}
or head.row:tag'td')
Line 175 ⟶ 177:
['text-align'] = 'center',
border = '1px solid #aaa',
['background-color'] = p.bgColor.head,
color = p.textColor.head
}
end
end
local function spacer(width)
tab.r:tag'td'
:attr{width = width}
Line 186 ⟶ 189:
end
local function dpBox(v, r)
p.dpBoxBase = p.dpBoxBase or mw.html.create'td':attr{rowspan = 2, colspan = p.colspan}
if not v then
p.dpBoxEmpty = p.previewnumbers and mw.clone(p.dpBoxBase) or p.dpBoxEmpty or mw.clone(p.dpBoxBase):wikitext(p.flex_tree.wt)
rowNum[r]:node(p.dpBoxEmpty)
else
Line 215 ⟶ 218:
end,
spin = function(self, v)
table.insert(self, v)
return self
end,
Line 249 ⟶ 252:
}
local function boldWin(s1, s2)
return setmetatable(
p.bold and s1 ~= s2 and (math[({'min', 'max'})[p.bold]](s1, s2) == s1 and {true} or {[2] = true}) or callableEmpty,
Line 256 ⟶ 259:
end
local function maxSpan(span, start, rows)
return math.min(span, math.max(0, rows - start + 1))
end
Line 262 ⟶ 265:
--in case of templates like RDseed need padding value
p.teamBoxPadding = function()
return '.6ex'
end
p.teamBoxPadTab = {padding = '0 ' .. p.teamBoxPadding()}
p.teamBoxNormal = {border = '1px solid #aaa', ['background-color'] = p.bgColor[4], color = p.textColor[4]}
local function teamBox(v, r, f)
if p.flex_tree.merge and not v and f.phase == 2 then
for i = -2, 0 do
Line 278 ⟶ 281:
if not p.bold then
--backwards compatability (wikitemplates bold each arg individually)
local hasBold, b = tostring(v):gsub("([^']*)'''([^']*)", '%1
if b == 1 then
v = hasBold
end
end
Line 291 ⟶ 294:
else
cell = p.teamBoxPadTab
local text = v or f[1] and '' or ' '
if f.bold then
text = mw.ustring.gsub(text, '(%(%[%[[^%[%]]*%]%]%))', '<span style="font-weight:normal">%1</span>')
end
tab.r = rowNum[r]:tag'td'
Line 296 ⟶ 303:
:css(cell)
:attr{rowspan = 2}
:node(mw.html.create(f.bold and 'b'):wikitext(
end
end
Line 322 ⟶ 329:
local mType, mNum = string.match(k, '^(%l+)match(%d*)$')
mType, mNum = ({skip = skipMatch, manualbold = unBold})[mType], tonumber(mNum)
if mType then
if mNum then
mType[mNum] = args:clean(k) == 'yes' or args[k] == 'true'
Line 345 ⟶ 352:
for _, v in ipairs({--more args to boolean
'widescore',
'color',
'color_repechage',
'3rdplace',
'omit_blanks',
Line 361 ⟶ 367:
end
end
p.previewnumbers = p.namespace ~= 0 and p.previewnumbers
p.scoreWasher:init(args['score-clean'])
p.scoreWasher.demo = args.demoWash and tonumber(args:clean('demoWash', {pattern = '%D'}), 10)
Line 378 ⟶ 386:
{__call = function() return 0 end}
)
)
or setmetatable({}, {__call = function() return nil end})
p.colspan = p.scoreBoxes > 0 and (p.scoreBoxes + 1) or nil
Line 429 ⟶ 437:
:css{['white-space'] = args.scroll_height and 'nowrap'}
newRow()
else
tab.r = tab:tag'tr'
tab.r:tag'td'
Line 448 ⟶ 456:
setmetatable(scoreWidth, _scoreWidth)
end
▲ end
local head_br = {
count = 0,
Line 480 ⟶ 484:
or p.RD[#p.RD + k - p.tCols - 1]
or ('Round of ' .. math.pow(2, p.tCols - k + 1))
drawHead(head.wt)
end
end
Line 521 ⟶ 520:
rowNum[1]:node(c < p.cols and
mw.clone(bumpBase):attr{rowspan = bump}
})▼
)
end
Line 531 ⟶ 525:
col.top = m.num
p.span = p.tCols > c and bump * 2 or p.branch_upwards or math.max((bump - 1) / 2, 2)
col.color_repechage = p['color_repechage'] and ((c == p.tCols) or ((c == p.tCols-1) and skipMatch[math.pow(2, p.tCols) - 1]))
col.show3rd = p['3rdplace'] and c == p.tCols and rowNum.third
local colorFinal, bumpMid = p.color and c == p.tCols, p.span > 0 and mw.clone(bumpBase):attr{rowspan = p.span} or nil
Line 586 ⟶ 581:
rowNum[rows + 1]:tag'td':attr{
rowspan = m.r + 9 - rows - (text and 0 or 2),
colspan = (p.cols - 1) *
}
end
Line 603 ⟶ 598:
end
end
dpBox(nodeFunc.pattern and nodeFunc.nonFunc or args[step], m.r
if p.previewnumbers then
rowNum[m.r].nodes[#rowNum[m.r].nodes]
▲ p.namespace = p.namespace or mw.title.getCurrentTitle().namespace
:css{
float = 'left',
Line 616 ⟶ 610:
:wikitext(m.num)
:attr{title = 'Number only visible outside article space (e.g. template) when |numberpreview=yes'}
end▼
end
end
Line 651 ⟶ 644:
else
if m.showBox[m.phase] then
if col.color_repechage then
p.teamBoxCSS = colorFinal and ▼
col.color_repechage = 2
{border = p.teamBoxNormal.border, background = p.bgColor[m.phase + (col.show3rd or 0)]}▼
if p.bold then
if m.bold.win(m.phase) and (colorFinal or col.color_repechage) then
color_index = 1 + (col.show3rd or 0) + (col.color_repechage or 0)
elseif m.bold.box[#m.nonEmpty] then
color_index = 2 + (col.show3rd or 0) + (col.color_repechage or 0)
else▼
color_index = 4
▲ end
▲ {border = p.teamBoxNormal.border, ['background-color'] = p.bgColor[
or p.teamBoxNormal
else
p.teamBoxCSS = (colorFinal or col.color_repechage) and
{border = p.teamBoxNormal.border, ['background-color'] = p.bgColor[m.phase + (col.show3rd or 0) + (col.color_repechage or 0)], color = p.textColor[m.phase + (col.show3rd or 0) + (col.color_repechage or 0)]}
or p.teamBoxNormal
local f = {phase = m.phase, bold = m.bold.win(m.phase)}
teamBox(args[step + nodeArgs.team[m.phase]], m.r, f)
Line 680 ⟶ 689:
if m.phase == 2 then
col.show3rd = col.show3rd ~= 2 and col.show3rd or nil
if p.scoreWasher.demo and p.scoreWasher.demo == m.num and
table.insert(m.bold.clean, 1, {args[step + nodeArgs.team[1]], args[step + nodeArgs.team[2]]})
return table.concat{
Line 722 ⟶ 731:
end
col.n = 0
col.t2 = nil
for r = bumps + 1, rows, p.unit * 2 do
tab.r = rowNum[r]:tag'td'
Line 730 ⟶ 740:
col.n = col.n + 2
col.t2 = skipMatch[col.tot + col.n / 2 + 1] and 3 or ((skipMatch[col.top + col.n] and 1 or 0) + (skipMatch[col.top + col.n + 1] and 2 or 0))
if col.t == 0 then --draws the ']' when a PAIR of matches needs lines
tab.r
:attr{rowspan = maxSpan(p.unit * 2, r, rows)}
Line 737 ⟶ 747:
['border-left'] = 0
})
else --draws the lines when only top OR bottom match need lines
▲ else
tab.r
:attr{rowspan = maxSpan(p.unit, r, rows)}
:cssText(col.t == 2 and
p:saveStr('topRight', 'border-width:', tab.line[2], ' 0 0;border-style:solid')
or col.t == 1 and (nodeFunc.bridge.lay[c](col.n - 2) and
Line 823 ⟶ 833:
function p.seed(frame)
local parent = frame:getParent() or frame
local function arg(k, alt)
return parent.args[k] or frame.args[k] or alt
end
Line 831 ⟶ 841:
return mw.html.create'div'
:css{
margin = ('-1px %s -1px -
float = 'left',
['background-color'] = p.bgColor.head,
border = '1px solid #aaa',
color = p.textColor.head,
['text-align'] = 'center',
width = width
|