Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Alex.osheter/listtest
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 p = {} function parseDate(totalSeconds) local seconds = math.fmod(tonumber(totalSeconds),60) local minutes = math.floor(tonumber(totalSeconds) / 60) local hours = math.floor(minutes / 60) if hours == 0 then return string.format("%d:%02d", minutes, seconds) else return string.format("%d:%02d:%02d", hours, minutes, seconds) end end function p.parseNames(frame) local wikiEntity = mw.wikibase.getEntity() if frame.args[1] == "{{{from}}}" then if (wikiEntity:getAllStatements( 'tracklist' ) == nil) then return end else wikiEntity = mw.wikibase.getEntity( frame.args[1] ) end local funcArgs = {} for index, table in pairs(wikiEntity:getAllStatements( 'tracklist' )) do local trackEntity = mw.wikibase.getEntity( table["mainsnak"]["datavalue"]["value"]["id"] ) if trackEntity:getSitelink() == nil then funcArgs["title" .. index] = trackEntity:getLabel() else funcArgs["title" .. index] = frame:preprocess( "[[" .. trackEntity:getSitelink() .. "|" .. trackEntity:getLabel() .. "]]") end if table["qualifiers"] ~= nil then if table["qualifiers"]["P2047"] ~= nil then local timeInSeconds = table["qualifiers"]["P2047"][1]["datavalue"]["value"]["amount"] funcArgs["length" .. index] = parseDate(timeInSeconds) end end end if wikiEntity:getAllStatements( 'duration' ) ~= nil then local totalTime = tonumber(wikiEntity:getAllStatements( 'duration' )[1]["mainsnak"]["datavalue"]["value"]["amount"]) funcArgs["total_length"] = parseDate(totalTime) end return frame:expandTemplate{ title = 'tracklist', args = funcArgs } 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/Alex.osheter/listtest/doc
(
edit
)