Module:Sandbox/Was a bee/Dump

From blackwiki
< Module:Sandbox
Revision as of 04:37, 10 June 2018 by blackwiki>Was a bee (Replaced content with '-- Copied from Module:Wikidata. Main developer is User:RexxS. local p = {} -- internationalisation local i18n = { ["warnDump"] = "[[Category:Calle...')
Jump to navigation Jump to search

→ See Template:Dump.



-- Copied from [[Module:Wikidata]]. Main developer is [[User:RexxS]].

local p = {}

-- internationalisation
local i18n =
{
	["warnDump"] = "[[Category:Called function 'Dump' from module Wikidata]]",
}

function p.Dump(frame)
	local f = (frame.args[1] or frame.args.id) and frame or frame:getParent()
	local data = mw.wikibase.getEntityObject(f.args.id)
	local width = f.args.width or "100%"
	local height = f.args.height or ""
	local overflowY
	if (height ~= nil) and (height ~= "") then
		overflowY = "scroll"
	else
		overflowY = ""
	end
	mw.logObject(height)
	mw.logObject(overflowY)
	if not data then
		return i18n.warnDump
	end

	local i = 1
	while true do
		local index = f.args[i]
		if (not index) or (index == "") then
			return f:extensionTag{ name = 'syntaxhighlight', content = mw.dumpObject(data), args = {lang = "javascript", style = "width: " .. width .. ";"  .. "height: " .. height .. ";" .. "overflow-y: " .. overflowY .. ";" .. "overflow-x: hidden;" } } .. i18n.warnDump
		end

		data = data[index] or data[tonumber(index)]
		if not data then
			return i18n.warnDump
		end

		i = i + 1
	end
end

return p