Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Habst/Athletics results
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!
p = {} local P_POINTINTIME = 'P585' local P_PARTICIPANTOF = 'P1344' local P_SPORTSDISCIPLINE = 'P2416' local P_RACETIME = 'P2781' local P_POINTS = 'P1358' local P_DISTANCE = 'P2043' local marks = { P_RACETIME, P_POINTS, P_DISTANCE } p.athleticsResults = function(frame) local qid = frame.args[1] local ent = mw.wikibase.getEntity(qid) local participantOfClaims = ent['claims'][P_PARTICIPANTOF] local years = {} local output = '' output = output .. '{| class="wikitable mw-collapsible" border="1" style="border-collapse:collapse; width:100%; font-size:90%;"\n' output = output .. '!colspan=11|Results for Usain Bolt\n' output = output .. '|-\n' output = output .. '!scope="col" style="width:5%;"|Date!!scope="col" style="width:20%;"|Meeting!!scope="col" style="width:10%;"|Location!!scope="col" style="width:10%;"|Ctry.!!scope="col" style="width:5%;"|Cat.!!scope="col" style="width:10%;"|Event!!scope="col" style="width:5%;"|H!!scope="col" style="width:5%;"|Pl.!!scope="col" style="width:10%;"|Perf.!!scope="col" style="width:5%;"|W!!scope="col" style="width:5%;"|N\n' for i, pc in ipairs(participantOfClaims) do mw.logObject(mw.wikibase.renderSnak(pc['mainsnak'])) if pc['qualifiers'] then local fulldate = pc['qualifiers'][P_POINTINTIME][1]['datavalue']['value']['time'] local year = fulldate:sub(2, 5) local serialized = fulldate -- e.g. "+2017-06-28T00:00:00Z" 21 characters long if pc['qualifiers'][P_SPORTSDISCIPLINE] then serialized = serialized .. '\'\'\'' .. mw.wikibase.renderSnak(pc['qualifiers'][P_SPORTSDISCIPLINE][1]) .. ':\'\'\' ' end local markProperty = nil for j, pm in ipairs(marks) do if pc['qualifiers'][pm] then markProperty = pm end end if markProperty ~= nil then -- mw.logObject(pc['qualifiers'][markProperty]) serialized = serialized .. mw.wikibase.renderSnak(pc['qualifiers'][markProperty][1]):match('([^Β±]*)') end meetname = mw.wikibase.renderSnak(pc['mainsnak']) if meetname ~= 'no value' then serialized = serialized .. ' at [[' .. meetname .. ']]' end if not years[year] then years[year] = {} end table.insert(years[year], serialized) end end yearsort = {} for n in pairs(years) do table.insert(yearsort, n) end table.sort(yearsort) for i, year in ipairs(yearsort) do --results = years[year] --ressort = {} --for k, v in pairs(results) do table.insert(ressort, v) end --table.sort(ressort) output = output .. '|-\n' output = output .. '|colspan=11 style="text-align:center; margin:0; padding:0;"|\n' output = output .. '{| class="wikitable mw-collapsible mw-collapsed" border="1" style="border-collapse:collapse; width:100%; margin:0;"\n' output = output .. '!colspan=11|' .. year .. '\n' for i, res in ipairs(years[year]) do output = output .. '|-\n' output = output .. '|style="width:5%;"|' .. res:sub(7,11) output = output .. '||style="width:20%;"|test' .. '||style="width:10%;"|[[Kingston]]||style="width:10%;"|Jamaica||style="width:5%;"|F' output = output .. '||style="width:10%;"|' .. '200 m' output = output .. '||style="width:5%;"|SF2||style="width:5%;"|1||style="width:10%;"|22.08||style="width:5%;"|0.0||style="width:5%;"|PB\n' -- output = output .. ' | ' .. res:sub(22) .. '\n' end output = output .. ' |}\n' end output = output .. '|}\n' return output 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:Sandbox/Habst/Athletics results/doc
(
edit
)