Module:Adjacent stations/sandbox: Difference between revisions

Content deleted Content added
simplify code
Tag: Reverted
restore
Line 204:
if args[v]['system'] then -- Header row
local stop_noun = data[v]['header stop noun'] or i18n[lang]['stop_noun']
mw.logObject(data[v])
table.insert(wikitable, table.concat({'\n|-',
'\n!', style['header cell'], i18n[lang]['preceding'](stop_noun),
'\n!', style['header midcell'], (data[v]['system style'] and data[v]['system style'] or table.concat({(data[v]['system icon'] and data[v]['system icon'] .. ' ' or ''), (data[v]['system title'] or ('[['.. args[v]['system'] ..']]'))})),
'\n!', style['header cell'], i18n[lang]['following'](stop_noun)
}))
Line 500 ⟶ 501:
local greatercontrast = require('Module:Color contrast')._greatercontrast
text_color = text_color and '#' .. text_color or greatercontrast{color}
local bold = (yesno(args.bold) == false) or ';font-weight: bold;'
if inline == 'route' orthen inline-- == 'croute' then[[Template:RouteBox]]
 
local if styleslink = {then
route result = '<span style="background-color: #%s;' .. color .. ';border: .075em solid #%s;' .. border_color .. ';padding: 0 .3em;%scolor">[[' .. link .. '|<span style="color:' %s;.. %stext_color .. bold .. ';font-size: inherit; white-space: nowrap;">%s' .. lineN .. '</span>%s', -- [[Template:RouteBox]]</span>'
else
croute = '<span style="background-color: #%s; border: .075em solid #%s; border-radius: .5em; padding: 0 .3em;%scolor: %s; %s font-size: inherit; white-space: nowrap;">%s</span>%s', -- [[Template:Bahnlinie]]
xroute result = '<span style="borderbackground-color:#' .. color .. ';border:.075em solid #%s;' border-radius:.. border_color .5em;. ';padding: 0 .3em;%scolorcolor:' #%s;.. %stext_color .. bold .. ';font-size: inherit; white-space: nowrap;">%s' .. lineN .. '</span>%s', -- [[Template:Bahnlinie]]
end
fallback = '<div class="legend" style="-webkit-column-break-inside: avoid; page-break-inside: avoid; break-inside: avoid-column;"><span class="legend-color" style="display: inline-block; width: 1.5em; height: 1.5em; margin: 1px 0; border: 1px solid black; background-color: #%s;"> </span> %s %s</div>', -- [[Template:Legend]] (fallback; duplication to simplify logic)
elseif inline == 'xroutecroute' then -- [[Template:Bahnlinie]]
}
if link then
 
result = '<span style="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>'
local link_start = '">[[%s|<span style="'
else
local link_end = ']]</span>'
croute result = '<span style="background-color: #%s;' .. color .. ';border: .075em solid #%s;' .. border_color .. ';border-radius: .5em; padding: 0 .3em;%scolorcolor:' %s;.. %stext_color .. bold .. ';font-size: inherit; white-space: nowrap;">%s' .. lineN .. '</span>%s', -- [[Template:Bahnlinie]]
 
} end
if link then
elseif inline == 'xroute' then -- [[Template:Bahnlinie]]
link_start = string.format(link_start, link)
if link then
else
result = '<span style="border:.075em solid #' .. border_color .. ';border-radius:.5em;padding:0 .3em">[[' .. link .. '|<span style="color:#' .. color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>]]</span>'
link_start = " "
link_end = ""else
result = '<span style="border:.075em solid #' .. border_color .. ';border-radius:.5em;padding:0 .3em;color:#' .. color .. bold .. ';font-size:inherit;white-space:nowrap">' .. lineN .. '</span>'
end
end
 
else -- [[Template:Legend]] (fallback; duplication to simplify logic)
if inline == 'route' or inline == 'croute' then
fallbackresult = '<div class="legend" style="-webkit-column-break-inside: avoid; page-break-inside: avoid; break-inside: avoid-column;"><span class="legend-color" style="display: inline-block; width: 1.5em; height: 1.5em; margin: 1px 0; border: 1px solid black; background-color:#' #%s;.. color .. '"> </span> %s %s</div>', .. --line [[Template:Legend]].. (fallback;result duplication.. to simplify logic)'</div>'
result = string.format(styles[inline], color, border_color, link_start, text_color, bold, lineN, link_end)
elseif inline == 'xroute' then
result = string.format(styles[inline], border_color, link_start, color, bold, lineN, link_end)
else
result = string.format(styles.fallback, color, line, result)
end
end