Μετάβαση στο περιεχόμενο

Module:Αριθμόςταχυδρομικώνκωδικών

Από τη Βικιπαίδεια, την ελεύθερη εγκυκλοπαίδεια
Documentation icon Τεκμηρίωση module[δημιουργία]
local p = {}

local function in_array(element, array)
	for _, i in ipairs(array) do
		if i == element then
			return true
		end
	end
	return false
end

function p.main(frame)
	local entity = mw.wikibase.getEntity()
	if not entity or not entity.claims or not entity.claims.P281 then
		mw.log("no claims")
		return nil
	end
	local claims = {}
	for _, cl in ipairs(entity.claims.P281) do
		if cl.mainsnak.snaktype == "value" then
			local value = cl.mainsnak.datavalue.value
			if not in_array(value, claims) then
				table.insert(claims, value)
			end
		end
	end
	return #claims
end

return p