clean = mw.text.decode(clean):gsub('<!%-.-%->', *):gsub(params.pattern or '[^%w-;%.]', *) .. params.append
clean = clean ~= params.append and clean or params.ifNil
end
args[key] = params.keepOld and args[key] or clean
return clean
end
p.cols = tonumber(args:clean('columns', {pattern = '%D'}))
p.tCols = (tonumber(args:clean('final_RDs_excluded', {pattern = '%D'})) or 0) + p.cols
local matchPer = {
pattern = '%d*per%d+[%-x]%d+',
vals = '(%d*)per(%d+)([%-x])(%d+)'
}
local skipMatch, unBold = {}, {}--(skip|manualbold)match# to boolean
for k, _ in pairs(args) do
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'
else
for pattern in args:clean(k, {ifNil = ''}):gfind(matchPer.pattern) do
local d1, period, op, d2 = pattern:match(matchPer.vals)
d1 = tonumber(d1) or 1
d2 = op == '-' and d2 or (d1 + period * (d2 - 1))
for y = d1, d2, period do
mType[y] = true
end
end
for _, x in ipairs(mw.text.split(args[k]:gsub(matchPer.pattern, ''):gsub('[;%-%a][;%-%a]+', ';'):match('^;*(.-)[;%-]*$'), ';')) do
x = mw.text.split(x, '-')
for y = tonumber(x[1]) or 1, tonumber(x[2] or x[1]) or 0 do
mType[y] = true
end
end
end
end
end
for _, v in ipairs({--more args to boolean
'widescore',
'template',
'article_include',
'color',
'3rdplace',
'omit_blanks',
'scroll_head_unlock',
'previewnumbers',
'flex_tree',
'no_column_head',
'short_brackets',
'branch_upwards'
}) do
if args[v] and (p[v] == nil or type(p[v]) == 'boolean') then
p[v] = args:clean(v) == 'yes' or args[v] == 'true'
end
end
p.scoreWasher:init(args['score-clean'])
p.scoreWasher.demo = args.demoWash and tonumber(args:clean('demoWash', {pattern = '%D'}), 10)
p.scoreSumBox = args['score-boxes'] and args['score-boxes']:match('%d ?%+ ?sum')
p.bold = ({low = 1, high = 2})[args:clean('bold_winner')] or p.scoreSumBox and 2
local sumBox = p.scoreSumBox and 1 or 0
p.scoreBoxes = (tonumber(args:clean('score-boxes', {pattern = '%D'})) or 1) + sumBox
p.scoreSumBox = p.scoreBoxes > 0 and p.scoreSumBox or nil
local boxStyle = p.scoreBoxes > 1 and
(p.scoreSumBox and
setmetatable(
,
{__call = function(t, i) if t[i] then return nil end return 0 end}
or setmetatable(
{},
{__call = function return 0 end}
or setmetatable({}, {__call = function return nil end})
p.colspan = p.scoreBoxes > 0 and (p.scoreBoxes + 1) or nil
local nodeArgs = {
score = p.scoreBoxes - sumBox,
team = {offset = 1 + p.scoreBoxes - sumBox}
}
nodeArgs.all = 1 + nodeArgs.team.offset * 2
nodeArgs.tableSum = {
__add = function(v, t)
if #t == 3 then
return v + nodeArgs.all
end
local s = v
for i, n in ipairs(t) do
s = s + n
end
return s-- + (p.scoreSumBox and #t == 3 and -2 or 0) --merging disabled with score boxes, uncomment if enable
end
}
nodeArgs.team[1] = 1--constant to be replaced later by new param
nodeArgs.team[2] = nodeArgs.team[1] + nodeArgs.team.offset
nodeArgs.blank = setmetatable({}, nodeArgs.tableSum)
p.unflex_div = mw.html.create'div'
:css{overflow = 'hidden',}
:wikitext'&nbsp;'
p.flex_tree = setmetatable({},{__index = {
merge = p.flex_tree and p.scoreBoxes == 0,
wt = p.flex_tree and '' or '&nbsp;',
cell = mw.html.create'td'
:node(not p.flex_tree and p.unflex_div or nil)
}})
if args:clean'scroll_height' then
local fontSize, fontUnit = args.style and args.style:match('font%-size *: *(%d+)([^ ]+)')
if fontSize then
local units = {
em = 1,
ex = 2,
['%'] = 0.01
}
fontSize, fontUnit = {fontSize * fontUnit}
end
end
tab
:cssText(table.concat{args.scroll_height and 'padding' or 'margin', ':', fontSize and (math.ceil(fontSize * 10) / 10) or '.9', 'em 2em 1em 1em;:0;', fontSize and '' or 'font-size:90%;', args.style})
:attr{cellpadding = 0, cellspacing = 0}
if not p.no_column_head then--headings row
newRow
head.row = tab.r
:css{['white-space'] = args.scroll_height and 'nowrap'}
newRow
else
tab.r = tab:tag'tr'
tab.r:tag'td'
end
local sp = {--set column widths
args['team-width'] or 170,
p.widescore and 40 or 30,
p.short_brackets and 6 or 15,
p.short_brackets and 4 or 20
}
local scoreWidth = args:clean('score-width', {pattern = '[^%d;]'}) and mw.text.split(args['score-width'], ';') or {}
scoreWidth[1] = tonumber(scoreWidth[1], 10)
if p.scoreSumBox and #scoreWidth ~= 1 then
local _scoreWidth = {}
for k = 1, p.scoreBoxes - 1 do
_scoreWidth[k] = tonumber(scoreWidth[k], 10) or math.ceil(sp[2] * 0.75)
end
setmetatable(scoreWidth, _scoreWidth)
end
if p.template or p.article_include then
p.template = mw.title.new(args.name)
p.templateFixedName = (p.template.namespace == 0 and not p.article_include and 'Template:' or '') .. p.template.fullText
end
p.template = p.template and mw.title.new(args:clean('name', {pattern = ''}))
local head_br = {
count = 0,
compare = function (self, text)
if text and args.scroll_height then
local _, count = text:gsub('<br[ >/]', '%1')
self.count = math.max(self.count, count)
end
return text
end
}
p.branch_upwards = p.branch_upwards and 0
for k = 1, p.cols do
if k > 1 then
spacer(sp[3])
spacer(sp[4])
if not p.no_column_head then
head.row:tag'td':attr{colspan = 2}
end
end
spacer(sp[1])
for s = 1, p.scoreBoxes do
spacer(#scoreWidth == 1 and scoreWidth[1] or scoreWidth[s] or sp[2])
end
if not p.no_column_head then
head.wt = head_br:compare(args:clean('RD' .. k, {pattern = ''}))
or p.RD[#p.RD + k - p.tCols - 1]
or (math.pow(2, p.tCols - k + 1).. ' அணிகளின் சுற்று')
drawHead(
k == 1 and p.template and mw.getCurrentFrame:expandTemplate{
title = 'tnavbar-header',
args = {head.wt, p.templateFixedName}
} or head.wt
end
end
sp.row = tab.r
col.tot = math.pow(2, p.tCols - 1)
local step, bump, bumpBase, rows = 1, 0, mw.html.create'td':attr{colspan = p.colspan}, col.tot * 6--Begin body row output
args.line_px = table.concat{args:clean('line_px') or 3, args.line_px ~= '0' and 'px' or nil}
tab.line = {--reduces concats and 'or' statements
{
[true] = args.line_px,
[false] = 0
},
args.line_px:rep(2):gsub('(%a)(%d)', '%1 %2', 1)
}
p['3rdplace'] = p.tCols == p.cols and (p['3rdplace'] or p.cols > 3 and nil == p['3rdplace'] and not p.no_column_head)
if p['3rdplace'] then
p.textThird = args.Consol or args['RD' .. (p.cols + 1)] or p.RD[4]
local no3rdText = p.no_column_head or p.textThird and p.textThird:match('omit_label')
rowNum.third = math.max(math.pow(2, p.branch_upwards and -3 or p.cols - 2) * 9 + (no3rdText and 4 or 9), no3rdText and 12 or 17, rows)
end
for r = 1, rowNum.third or rows do
newRow(r)
end
p:saveStr('solid', tab.line[1][true], ' solid')
p.cornerDiv = mw.html.create'div':css{height = tab.line[1][true], ['-'] = p.reuseStr.solid}
for c = 1, p.cols do
col.c = c
local bumps = bump
if c > 1 then
col.tot = col.tot + math.pow(2, p.tCols - c)
if p.branch_upwards then
bumps = 0
rowNum[1]:tag'td':attr{rowspan = 4}
else
rowNum[1]:node(c < p.cols and
mw.clone(bumpBase):attr{rowspan = bump}
or p.no_column_head and p.template and
mw.html.create'td':wikitext(mw.getCurrentFrame:expandTemplate{
title = 'tnavbar-header',
args = {'', p.templateFixedName}
})
end
end
col.top = m.num
p.span = p.tCols > c and bump * 2 or p.branch_upwards or math.max((bump - 1) / 2, 2)
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
for r = 1, col.show3rd or rows, 2 do
m.r = r + bumps
if col.show3rd or rowNum[m.r] and m.num <= col.tot then
if m.phase == 0 then
m.showBox = setmetatable({1, nodeArgs.team.offset, nodeArgs.team.offset}, nodeArgs.tableSum)
if nodeFunc:scanPattern(args, step) then
nodeFunc.called = {}
m.available = true
else
m.available = nil
end
end
if skipMatch[m.num] then
if m.phase == 0 then
if nodeFunc.pattern then
for x, y in ipairs(nodeFunc.pattern) do
if nodeFunc.skipAllowed[y] then
nodeFunc.called[y] = nodeFunc[y].main(x)
end
end
end
local canvas = nodeFunc.pattern and nodeFunc.called.canvas and 6