Module:Adjacent stations/sandbox: Difference between revisions

Content deleted Content added
sync with live
simplify code
Tag: Reverted
Line 500:
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' then -- [[Template:RouteBox]]
iflocal linkstyles then= {
resultroute = '<span style="background-color: #'%s; .. color .. ';border: .075em solid #'%s; .. border_color .. ';padding: 0 .3em">[[' .. link .. '|<span style="color;%scolor:' ..%s; text_color%s .. bold .. ';font-size: inherit; white-space: nowrap;">' .. lineN .. '%s</span>%s', -- [[Template:RouteBox]]</span>'
resultcroute = '<span style="background-color: #'%s; .. color .. ';border: .075em solid #'%s; .. border_color .. ';border-radius: .5em; padding: 0 .3em;color%scolor:' ..%s; text_color%s .. bold .. ';font-size: inherit; white-space: nowrap;">' .. lineN .. '%s</span>%s', -- [[Template:Bahnlinie]]
else
resultxroute = '<span style="background-colorborder:#' .. color .. ';border:.075em solid #'%s; .. border_colorborder-radius: ..5em; ';padding: 0 .3em;color%scolor:' ..#%s; text_color%s .. bold .. ';font-size: inherit; white-space: nowrap;">' .. lineN .. '%s</span>%s', -- [[Template:Bahnlinie]]
resultfallback = '<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:#' .. color .. '#%s;"> </span> %s %s</div>', .. line-- ..[[Template:Legend]] result(fallback; ..duplication '</div>'to simplify logic)
end
}
elseif inline == 'croute' then -- [[Template:Bahnlinie]]
 
if link then
local link_start = '">[[%s|<span style="'
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_end = ']]</span>'
else
 
result = '<span style="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>'
if link then
end
link_start = string.format(link_start, link)
elseif inline == 'xroute' then -- [[Template:Bahnlinie]]
else
if link then
link_start = " "
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>'
elselink_end = ""
end
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
if inline == 'route' thenor --inline [[Template:RouteBox]]== 'croute' then
else -- [[Template:Legend]] (fallback; duplication to simplify logic)
result = string.format(styles[inline], color, border_color, link_start, text_color, bold, lineN, link_end)
result = '<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:#' .. color .. '"> </span> ' .. line .. result .. '</div>'
elseif inline == 'croutexroute' then -- [[Template:Bahnlinie]]
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