Zum Inhalt springen

Modul:Benutzer:Zukunft99

aus Wikipedia, der freien Enzyklopädie

Die Dokumentation für dieses Modul kann unter Modul:Benutzer:Zukunft99/Doku erstellt werden

local p = {}
local getArgs = require('Modul:Arguments').getArgs
local name = require('Modul:Partei').name
local farbe = require('Modul:Partei').farbe
local hell = require('Modul:Partei').hell
local pipe = require('Modul:Partei').pipelink
local _, colour = pcall(require, "Modul:Vorlage:Standardfarbe")

function p.xx(frame)
	local args = getArgs(frame)
    kkk = colour().getColor
	return kkk(args[1], args[2], args['mode'])
end

local function legend(a)
	local legende = '<span style="border:0.1em solid #D0D0D0;margin-right:0.1em"><span style="border-right:1.2em solid;border-right-color:#'..a..'">&#xfeff;</span></span>'
	return legende
end

function p.tab(frame)
	local args = getArgs(frame)
	local staat = args['land']
	local link = args['link']
	if args['farbe'] then color = 'background-color:#DDFFD6' far = 'style="'..color..'"' else color = '' far = '' end
	local legende = legend
	local farb = args['hell'] and hell or farbe
	local breite = 0.8 + (args['breite'] and (args['breite'] * 1.4 - 0.1) or 0)
	if args[2] then l2 = legende(farb({args[2], staat, h=0.5})) p2 = ', '..pipe({args[2], staat}) else l2 = '' p2 = '' end
	if args[3] then l3 = legende(farb({args[3], staat, h=0.5})) p3 = ', '..pipe({args[3], staat}) else l3 = '' p3 = '' end
	if args[4] then l4 = legende(farb({args[4], staat, h=0.5})) p4 = ', '..pipe({args[4], staat}) else l4 = '' p4 = '' end
	if args[5] then l5 = legende(farb({args[5], staat, h=0.5})) p5 = ', '..pipe({args[5], staat}) else l5 = '' p5 = '' end
	if args[6] then l6 = legende(farb({args[6], staat, h=0.5})) p6 = ', '..pipe({args[6], staat}) else l6 = '' p6 = '' end
	col = far..'|'.. legende(farb({args[1], staat, h=0.5}))..l2..l3..l4..l5..l6..'<span style="padding-left:'..breite..'em">'..(link and '[['..link..']]' or pipe({args[1], staat})..p2..p3..p4..p5..p6)..'</span>\n'
	sitze = '| style="text-align:right;padding-right:20px;'..color..'"|'.. tonumber(args['sitze'])
	return string.format(col..sitze)
end

function p.tabelle(frame)
	local args = getArgs(frame)
	local staat = args['land']
	local legende = legend
	root = mw.html.create('table'):addClass('wikitable')
	
	root:tag('th')
		:wikitext('Parteien')
	root:tag('th')
		:wikitext('Mandate')
	root:tag('tr')
	
	for k, v in ipairs(args) do
		if k and (tonumber(args[k-1]) or (k == 1)) then
			a = args[k+1] 
			b = args[k+2]
			c = args[k+3]
			d = args[k+4]
			e = args[k+5]
			if k == tonumber(args['f']) then farze = '#DDFFD6' elseif k > tonumber(args['f']) then farze = false end
			root:tag('td')
				:wikitext(legende(farbe({args[k], staat}))..(tonumber(a) and '' or (legende(farbe({a, staat})).. (tonumber(b) and '' or (legende(farbe({b, staat})).. (tonumber(c) and '' or (legende(farbe({c, staat}))..(tonumber(d) and '' or (legende(farbe({d, staat}))..(tonumber(e) and '' or legende(farbe({e, staat})))))))))))..'<span style="padding-left:0.8em">'..(pipe({args[k], staat})..(tonumber(a) and '' or (', '..pipe({a, staat}).. (tonumber(b) and '' or (', '..pipe({b, staat}).. (tonumber(c) and '' or (', '..pipe({c, staat})..(tonumber(d) and '' or (', '..pipe({d, staat})..(tonumber(e) and '' or ', '..pipe({e, staat})))))))))))..'</span>')
				:css('background-color', farze or '#F8F9FA')
		end
		if k and tonumber(args[k]) then
			root:tag('td')
				:wikitext(args[tonumber(k)])
				:css('text-align', 'right')
				:css('background-color', farze or '#F8F9FA')
				:css('padding-right', '20px')
		end
		if args[k] == '1' or tonumber(args[k]) then
			root:tag('tr')
		end
	end
	return root
end

return p