Content deleted Content added
fix variable use |
sync with live template |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 237:
local line = data[v]['lines'] and (mw.clone(data[v]['lines'][lineN]) or error(i18n[lang]['error_unknown'](args[v]['line']))) or error(i18n[lang]['error_line'])
local default = data[v]['lines']['_default'] or {}
line['title'] = line['title'] or default['title'] or ''
line['title'] = mw.ustring.gsub(line['title'], '%%1', lineN)
Line 390:
return function (frame)
local args = getArgs(frame, {parentOnly = true})
return p[funcName](args, frame)
local function makeTemplateFunction(funcName)
-- makes a function that can be returned from #invoke, using
-- [[Module:Arguments]]
return function (frame)
local args = getArgs(frame, {frameOnly = true})
return p[funcName](args, frame)
end
Line 453 ⟶ 462:
if not inline then -- [[Template:Legend]]
result = '<div class="legend" style="page-break-inside:avoid;break-inside:avoid-column"><span class="legend-color" style="display:inline-block;min-width:1.25em;height:1.25em;line-height:1.25;margin:1px 0;border:1px solid black;color:inherit;background-color:#' .. color .. '"> </span> ' .. line .. result .. '</div>'
elseif inline == 'yes' then
result = '<span style="color:inherit;background-color:#' .. color .. ';border:1px solid #000"> </span> ' .. line .. result
elseif inline == 'box' then
result = '<span style="color:inherit;background-color:#' .. color .. ';border:1px solid #000"> </span>' .. result
elseif inline == 'link' then
local link = args.link or mw.ustring.match(line, '%[%[([^%[:|%]]+)[|%]]')
if link then
result = '[[' .. link .. '|<span style="color:inherit;background-color:#' .. color .. ';border:1px solid #000"> </span>]]' .. result
else
result = '<span style="color:inherit;background-color:#' .. color .. ';border:1px solid #000"> </span>' .. result
end
elseif inline == 'square' then
Line 484 ⟶ 493:
end
elseif inline == 'small' then
result = '<span style="color:inherit;background-color:#' .. color .. '"> </span>' .. ' ' .. line .. result
else
local yesno = require("Module:Yesno")
Line 517 ⟶ 526:
if inline == 'route' then -- [[Template:RouteBox]]
if link then
result = '<span style="color:inherit;background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';padding:0 .3em">[[' .. link .. '|<span style="color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>]]</span>'
else
result = '<span style="background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';padding:0 .3em;color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>'
Line 523 ⟶ 532:
elseif inline == 'croute' then -- [[Template:Bahnlinie]]
if link then
result = '<span style="color:inherit;background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';border-radius:.5em;padding:0 .3em">[[' .. link .. '|<span style="color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>]]</span>'
else
result = '<span style="color:inherit;background-color:#' .. color .. ';border:.075em solid #' .. border_color .. ';border-radius:.5em;padding:0 .3em;color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>'
end
elseif inline == 'xroute' then -- [[Template:Bahnlinie]]
Line 535 ⟶ 544:
elseif inline == 'broute' then
if link then
result = '<span style="color:inherit;background-color:#' .. color .. ';border:.075em solid #000;padding:0 .3em">[[' .. link .. '|<span style="color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>]]</span>'
else
result = '<span style="background-color:#' .. color .. ';border:.075em solid #000;padding:0 .3em;color:' .. text_color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>'
end
else -- [[Template:Legend]] (fallback; duplication to simplify logic)
result = '<div class="legend" style="page-break-inside:avoid;break-inside:avoid-column"><span class="legend-color" style="display:inline-block;min-width:1.25em;height:1.25em;line-height:1.25;margin:1px 0;border:1px solid black;color:inherit;background-color:#' .. color .. '"> </span> ' .. line .. result .. '</div>'
end
end
Line 666 ⟶ 675:
p.icon = makeInvokeFunction('_icon')
p['rail icon'] = makeTemplateFunction('_icon')
function p._line(args, frame)
Line 794 ⟶ 804:
p.station = makeInvokeFunction('_station')
p['station link'] = makeTemplateFunction('_station')
function p._terminusTable(args, frame)
Line 843 ⟶ 854:
local result = {}
local data = args.data
local default = 'background-color:#efefef
▲ local default = 'background-color:#efefef; color: black;' -- Default background color for {{Infobox station}}
if system or data then
data = data or getData(system, true)
Line 861 ⟶ 869:
end
if style == 'header
if style == 'header' then▼
elseif style == 'subheader' then
▲ nameFormat = data['name format'] and getValue(data['name format'])
▲ if nameFormat then table.insert(result, nameFormat) end
table.insert(result, 'color:#' .. color)▼
▲ background = getValue(data['header background color'])
else
▲ end
▲ table.insert(result, 'background-color:#' .. background)
▲ end
▲ local color = ''
▲ color = getValue(data['header text color'])
▲ elseif background ~= '' then
local greatercontrast = require('Module:Color contrast')._greatercontrast
end
else
local color = data['header text color'] and getValue(data['header text color'])
▲ table.insert(result, 'color:#' .. color)
if color then table.insert(result, 'color:#' .. color) end
end
end
Line 922 ⟶ 919:
result = table.concat(result, ';')
else
▲ result = default
result = default▼
else
result = ''
end
end
else
if style == 'subheader' then
▲ result = default
result = default
else
result = ''
end
end
|