Changes

Jump to: navigation, search

Module:WikidataIB

238 bytes added, 12:03, 3 November 2018
allow rendersnak to filter quantities by unit; extend getValueByRefSource to use unit filter and set some defaults
-- roundto(); decimalPrecision(); decimalToDMS();
-------------------------------------------------------------------------------
local rendersnak = function(propval, args, linked, lpre, lpost, pre, post, uabbr, filter)
lpre = lpre or ""
lpost = lpost or ""
local usym = ""
local unitqid = string.match( dv.unit, "(Q%d+)" )
if filter and unitqid ~= filter then return nil end
if unitqid then
local uname = mw.wikibase.getLabelByLang(unitqid, args.lang) or ""
-- The Q-id of the value we want to match is in named parameter |qvalue=
local qval = (frame.args.match or ""):upper()
if qval == "" then return qval = "no match value suppliedQ21540096" end  local unit = (frame.args.unit or ""):upper() if unit == "" then unit = "Q4917" end
local onlysrc = parseParam(frame.args.onlysourced or frame.args.osd, true)
local linked = parseParam(frame.args.linked, true)
 
local uabbr = parseParam(frame.args.uabbr or frame.args.unitabbr, false)
-- qid not nil means no local parameter and the property exists
for k3, v3 in pairs(v2.snaks.P248) do
if v3.datavalue.value.id == qval then
out[#out+1], mlt[#out+1] = rendersnak(v1, frame.args, linked, "", "", "", "", uabbr, unit)
if not mlt[#out] then
-- we only need one match per property value
Anonymous user

Navigation menu