https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3AOverlay%2Fsandbox
Module:Overlay/sandbox - Revision history
2025-06-01T01:15:02Z
Revision history for this page on the wiki
MediaWiki 1.45.0-wmf.3
https://en.wikipedia.org/w/index.php?title=Module:Overlay/sandbox&diff=1150193789&oldid=prev
Lemondoge at 20:24, 16 April 2023
2023-04-16T20:24:09Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 20:24, 16 April 2023</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 132:</td>
<td colspan="2" class="diff-lineno">Line 132:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local image = args['image'] or ''</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local image = args['image'] or ''</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> local width = tonumber(args['width'] or <del style="font-weight: bold; text-decoration: none;">'</del>500<del style="font-weight: bold; text-decoration: none;">'</del>) or 500</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> local width = tonumber(args['width'] or 500) or 500</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> local height = tonumber(args['height'] or <del style="font-weight: bold; text-decoration: none;">'</del>500<del style="font-weight: bold; text-decoration: none;">'</del>) or 500</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> local height = tonumber(args['height'] or 500) or 500</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> local columns = tonumber(args['columns'] or <del style="font-weight: bold; text-decoration: none;">'</del>3<del style="font-weight: bold; text-decoration: none;">'</del>) or 3</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> local columns = tonumber(args['columns'] or 3) or 3</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local grid = ((args['grid'] or ''):lower() == 'yes') and 'yes' or 'no'</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local grid = ((args['grid'] or ''):lower() == 'yes') and 'yes' or 'no'</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local legendbox = ((args['legendbox'] or ''):lower() == 'no') and 'no' or 'yes'</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local legendbox = ((args['legendbox'] or ''):lower() == 'no') and 'no' or 'yes'</div></td>
</tr>
</table>
Lemondoge
https://en.wikipedia.org/w/index.php?title=Module:Overlay/sandbox&diff=997692747&oldid=prev
WOSlinker: remove moz and webkit as standard now well supported
2021-01-01T19:46:59Z
<p>remove moz and webkit as standard now well supported</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 19:46, 1 January 2021</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 47:</td>
<td colspan="2" class="diff-lineno">Line 47:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('padding', ((tonumber(n) or 0) < 10) and '0px 4px' or '0px 2px')</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('padding', ((tonumber(n) or 0) < 10) and '0px 4px' or '0px 2px')</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('vertical-align', 'middle')</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('vertical-align', 'middle')</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> :css('-moz-border-radius', '3px')</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> :css('-webkit-border-radius', '3px')</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('border-radius', '3px')</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('border-radius', '3px')</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('background-color', c)</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('background-color', c)</div></td>
</tr>
</table>
WOSlinker
https://en.wikipedia.org/w/index.php?title=Module:Overlay/sandbox&diff=856579166&oldid=prev
Jonesey95: sync with live module
2018-08-26T06:26:58Z
<p>sync with live module</p>
<p><b>New page</b></p><div>-- this module implements [[Template:Overlay]]<br />
local p = {}<br />
<br />
local mArguments = require('Module:Arguments')<br />
<br />
-- used to cache the calculated font color to avoid repeat calculations<br />
local previous_backgroundcolor = ''<br />
local fontcolor = ''<br />
<br />
local function buildicon(n, form, lk, c, t)<br />
local res<br />
if form == 'text' then<br />
return tostring(<br />
mw.html.create('span')<br />
:css('font-weight', 'bold')<br />
:css('color', c)<br />
:wikitext(n)<br />
)<br />
elseif form == 'color' or form == 'colour' then<br />
return tostring(<br />
mw.html.create('span')<br />
:css('background-color', c)<br />
:wikitext('&#160;&#160;')<br />
)<br />
else<br />
-- check if the color is difference from the previous color<br />
if c ~= previous_backgroundcolor then<br />
-- color changed, so look up the best font color<br />
local greatercontrast = require('Module:Color contrast')._greatercontrast<br />
fontcolor = greatercontrast{c, 'white', 'black', bias = 1.3}<br />
-- update the previous value for the next check<br />
previous_backgroundcolor = c<br />
end<br />
-- build the inner span for the icon<br />
local span = mw.html.create('span')<br />
:css('color', fontcolor)<br />
:css('font-size', '88%')<br />
:css('font-weight', 'bold')<br />
:attr('title', t)<br />
:wikitext(n)<br />
-- build the outer div<br />
local div = mw.html.create('div')<br />
:css('display', 'inline-block')<br />
:css('width', 'auto')<br />
:css('height', 'auto')<br />
:css('text-align', 'center')<br />
:css('padding', ((tonumber(n) or 0) < 10) and '0px 4px' or '0px 2px')<br />
:css('vertical-align', 'middle')<br />
:css('-moz-border-radius', '3px')<br />
:css('-webkit-border-radius', '3px')<br />
:css('border-radius', '3px')<br />
:css('background-color', c)<br />
<br />
-- link the inner span if requested and insert in the div<br />
if lk ~= '' then<br />
div:wikitext('[[:' .. lk .. '|' .. tostring(span) .. ']]')<br />
else<br />
div:wikitext(tostring(span))<br />
end<br />
-- convert to a string<br />
return tostring(div)<br />
end<br />
end<br />
<br />
local function buildlegend(data, cols, border, caption)<br />
-- create the outer table to hold the columns<br />
local root = mw.html.create('table')<br />
:css('width', '100%')<br />
:css('border', (border ~= 'no') and '1px #ccc solid' or '')<br />
-- create the outer row which will contain the columns<br />
local outerrow = root:tag('tr')<br />
local percol = math.ceil((#data) / cols)<br />
local k = 0<br />
for j=1,cols do<br />
-- create the outer cell to hold this column<br />
local colcell = outerrow:tag('td')<br />
:css('width', (math.floor(10/cols)/10) .. '%')<br />
:css('vertical-align', 'top')<br />
-- create the inner table to hold the entries in the column<br />
local coltable = colcell:tag('table')<br />
:css('width', '100%')<br />
:css('font-size', '85%')<br />
:css('line-height', '95%')<br />
-- add the entries to the column<br />
for l = 1,percol do<br />
k = k + 1<br />
if k <= #data then<br />
local rdata = data[k]<br />
local tr = coltable:tag('tr'):css('vertical-align','top')<br />
tr:tag('td')<br />
:css('width', '12px')<br />
:css('text-align', 'right')<br />
:css('padding-bottom', '2px')<br />
:wikitext(rdata[1] or '')<br />
tr:tag('td')<br />
:css('padding-bottom', '2px')<br />
:wikitext(rdata[2] or '')<br />
end<br />
end<br />
end<br />
return caption .. tostring(root)<br />
end<br />
<br />
local function buildlegenditem(im, lk, t)<br />
local res = {im, ''}<br />
if t ~= '' then<br />
if lk ~= '' then<br />
res[2] = '[[:' .. lk .. '|' .. t .. ']]'<br />
else<br />
res[2] = t<br />
end<br />
else<br />
res[2] = '[[:' .. lk .. '|' .. lk .. ']]'<br />
end<br />
return res <br />
end<br />
<br />
function p.icon(frame)<br />
local args = mArguments.getArgs(frame)<br />
return tostring(<br />
mw.html.create('div')<br />
:css('display', 'inline-block')<br />
:css('line-height', '95%')<br />
:wikitext(buildicon(args['1'] or '', <br />
args['form'] or 'icon',<br />
args['link'] or '', <br />
args['2'] or 'red',<br />
args['tip'] or ''))<br />
)<br />
end<br />
<br />
function p.main(frame)<br />
local args = mArguments.getArgs(frame)<br />
<br />
local image = args['image'] or ''<br />
local width = tonumber(args['width'] or '500') or 500<br />
local height = tonumber(args['height'] or '500') or 500<br />
local columns = tonumber(args['columns'] or '3') or 3<br />
local grid = ((args['grid'] or ''):lower() == 'yes') and 'yes' or 'no'<br />
local legendbox = ((args['legendbox'] or ''):lower() == 'no') and 'no' or 'yes'<br />
local overlay = (image == '') and 'no' or ( ((args['overlay'] or ''):lower() == 'no') and 'no' or 'yes' )<br />
local float = args['float'] or 'center'<br />
local border = ((args['border'] or ''):lower() == 'no') and 'no' or 'yes'<br />
local padding = args['padding'] or ''<br />
<br />
-- create the root table<br />
local root = mw.html.create('table')<br />
if float == 'center' or float == 'centre' then<br />
root:css('margin-left', 'auto')<br />
:css('margin-right', 'auto')<br />
elseif float == 'right' then<br />
root:css('float', 'right')<br />
:css('clear', 'right')<br />
:css('margin-left', '1em')<br />
elseif float == 'left' then<br />
root:css('float', 'left')<br />
:css('clear', 'left')<br />
:css('margin-right', '1em')<br />
else<br />
root:css('float', float)<br />
end<br />
if border == 'yes' then<br />
root:css('border', '1px #ccc solid')<br />
end<br />
<br />
-- create a list of all the overlay numbers<br />
local itemnums = {}<br />
for k, v in pairs( args ) do<br />
local i = tonumber(tostring(k):match( '^%s*overlay([%d]+)%s*$' ) or '-1')<br />
if i > -1 then<br />
table.insert(itemnums, i)<br />
else<br />
i = tonumber(tostring(k):match( '^%s*overlay([%d]+)tip%s*$' ) or '-1')<br />
if i > -1 then<br />
table.insert(itemnums, i)<br />
end<br />
end<br />
end<br />
-- sort to process in order<br />
table.sort( itemnums )<br />
<br />
-- remove duplicates<br />
for k = 2,#itemnums do<br />
if itemnums[k] == itemnums[k-1] then<br />
table.remove(itemnums, k)<br />
end<br />
end<br />
<br />
-- build the overlay markers and text<br />
itemdata = {}<br />
local colori = args['color'] or args['colour'] or 'red'<br />
local formi = '' <br />
for k = 1,#itemnums do<br />
local i = itemnums[k]<br />
formi = args['overlay' .. i .. 'form'] or formi<br />
colori = args['overlay' .. i .. 'color'] or args['overlay' .. i .. 'colour'] or colori<br />
local linki = args['overlay' .. i .. 'link'] or ''<br />
local tipi = args['overlay' .. i .. 'tip'] or args['overlay' .. i] or ''<br />
local overlayi = args['overlay' .. i] or args['overlay' .. i .. 'tip'] or ''<br />
if (overlayi ~= '' or tipi ~= '') then<br />
local imagei = buildicon(i, formi, linki, colori, tipi)<br />
itemdata[k] = buildlegenditem(imagei, args['overlay' .. i .. 'link'] or '', overlayi)<br />
end<br />
end<br />
<br />
-- create the overlay image<br />
if image ~= '' then<br />
local cell = root:tag('tr'):tag('td')<br />
cell:attr('align', 'center')<br />
if( padding ~= '' ) then<br />
cell:css('padding', padding)<br />
end<br />
if( columns > 1 and legendbox == 'yes' ) then<br />
cell:attr('colspan', columns)<br />
end<br />
local imagediv = cell:tag('div')<br />
imagediv:css('position','relative')<br />
:css('left', '0px')<br />
:css('top', '0px')<br />
:css('width', ((grid == 'yes') and 940 or width) .. 'px')<br />
:css('height', ((grid == 'yes') and 940 or height) .. 'px')<br />
if grid == 'yes' then<br />
imagediv:tag('span')<br />
:css('position', 'absolute')<br />
:css('left', '0px')<br />
:css('top', '0px')<br />
:css('z-index', '2')<br />
:wikitext('[[File:Grid 99, 100 int red 50 int yellow (940).svg|940px]]')<br />
end<br />
imagediv:tag('span')<br />
:css('position', 'absolute')<br />
:css('left', '0px')<br />
:css('top', '0px')<br />
:css('z-index', '0')<br />
:css('width', width .. 'px')<br />
:css('height', height .. 'px')<br />
:wikitext('[[File:' .. image .. '|' .. width .. 'x' .. height .. 'px]]')<br />
if overlay == 'yes' then<br />
for k = 1,#itemnums do<br />
local i = itemnums[k]<br />
local imagei = (itemdata[k])[1]<br />
for j =0,3 do<br />
local overlayileftj = args['overlay' .. i .. 'left' .. ((j == 0) and '' or j)] or ''<br />
local overlayitopj = args['overlay' .. i .. 'top' .. ((j == 0) and '' or j)] or ''<br />
if overlayileftj ~= '' then<br />
imagediv:tag('div')<br />
:css('position', 'absolute')<br />
:css('left', overlayileftj .. 'px')<br />
:css('top', overlayitopj .. 'px')<br />
:css('line-height', '95%')<br />
:css('z-index', '1')<br />
:wikitext(imagei)<br />
end<br />
end<br />
end<br />
end<br />
end<br />
<br />
-- Split the legend items into sub-legends<br />
legend = {{}, {}, {}, {}, {}}<br />
local jmax = itemnums[#itemnums]<br />
for i=1,5 do<br />
if args['legend' .. i .. 'start'] then<br />
-- default is all items<br />
j1 = 0<br />
j2 = jmax<br />
-- set start item number to (legendistart) or (legend(i-1)end + 1)<br />
if args['legend' .. i .. 'start'] then<br />
j1 = tonumber(args['legend' .. i .. 'start']) or j1<br />
elseif args['legend' .. (i-1) .. 'end'] then<br />
j1 = (tonumber(args['legend' .. (i-1) .. 'end']) or j1) + 1<br />
end<br />
-- set end item number to (legendiend) or (legend(i+1)start - 1)<br />
if args['legend' .. i .. 'end'] then<br />
j2 = tonumber(args['legend' .. i .. 'end']) or j2<br />
elseif args['legend' .. (i+1) .. 'start'] then<br />
j2 = (tonumber(args['legend' .. (i+1) .. 'start']) or j2) - 1<br />
end<br />
-- get the items within the range, marking them as they are used<br />
for k=1,#itemnums do<br />
j = itemnums[k]<br />
if (j >= 0 and j >= j1 and j <= j2) then<br />
table.insert(legend[i], itemdata[k])<br />
itemnums[k] = -1<br />
end<br />
end<br />
end<br />
end<br />
<br />
-- Add any left over items to the first legend<br />
for k = 1,#itemnums do<br />
if itemnums[k] >= 0 then<br />
table.insert(legend[1], itemdata[k])<br />
end<br />
end<br />
<br />
-- Build the legend<br />
if columns > 0 then<br />
for i = 1,5 do<br />
local locallegend = legend[i]<br />
if (locallegend and #locallegend > 0) then<br />
local cell = root:tag('tr'):tag('td')<br />
cell:wikitext(buildlegend(locallegend, columns, border, args['legend' .. i .. 'title'] or ''))<br />
end<br />
end<br />
end<br />
<br />
return tostring(root)<br />
end<br />
<br />
return p</div>
Jonesey95