Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:QuidAppearances
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local yesno = require('Module:Yesno') local ordinal = require('Module:Ordinal')._ordinal local p = {} function p.style(pos, host) local style = (host and "border:3px solid red;" or '') if pos == '1' then style = style .. "background-color:gold;" elseif pos == '2' then style = style .. "background-color:silver;" elseif pos == '3' then style = style .. "background-color:#CC9966;" elseif pos == '4' then style = style .. "background-color:#9ACDFF;" end return (style ~= '' and ('style="' .. style .. '" ') or '') end function p.filter_position(pos) -- Parse position string (`H`, `Q`, `.` or digits) local actual_pos, suffix = mw.ustring.match(pos, "^H?([QW%.])(.*)") if actual_pos == nil then actual_pos, suffix = mw.ustring.match(pos, "^H?(%d+)(.*)") end if actual_pos == nil then actual_pos, suffix = pos, "" end return actual_pos, suffix end function p.sort_value(pos) local n = '' if pos == '.' then n = 999 elseif pos == 'W' then n = 998 elseif pos == 'Q' then n = 997 else n = pos end return 'data-sort-value="' .. n .. '" ' end function p.content(pos) if tonumber(pos) then return ordinal(pos) elseif pos == '.' then return "β’" elseif pos == 'W' then return "{{Tooltip|WD|Withdrew}}" elseif pos == 'Q' then return "{{Tooltip|Q|Qualified}}" else return pos end end function p.cell(pos) local host = false if pos == nil then return '' end if mw.ustring.sub(pos, 1, 1) == 'H' then host = true -- pos = mw.ustring.sub(pos, 2) end local actual_pos, suffix = p.filter_position(pos) return p.style(pos, host) .. p.sort_value(actual_pos) .. '| ' .. p.content(actual_pos) .. suffix end function p.appeared(pos) return mw.ustring.sub(pos, 1, 1) == 'H' and tonumber(mw.ustring.sub(pos, 2)) or tonumber(pos) end function p.main(frame) -- If called via #invoke, use the args passed into the invoking template. if frame == mw.getCurrentFrame() then args = frame:getParent().args else args = frame.args end local result = '| style="text-align:left;" | {{quid|' .. args[1] .. '}} || ' local appearances = 0 for key, value in ipairs(args) do if key ~= 1 then result = result .. p.cell(value) .. ' || ' if p.appeared(value) then appearances = appearances + 1 end end end result = result .. " '''" .. appearances .. "'''\n|-\n" return frame:preprocess(result) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:QuidAppearances/doc
(
edit
)