Modul:Europamandate
Erscheinungsbild
Die Dokumentation für dieses Modul kann unter Modul:Europamandate/Doku erstellt werden
local p = {}
local parteiname = require('Module:Partei').parteiname
local full = require('Module:Partei').full
local farbe = require('Module:Partei').farbe
local alt = require('Module:Partei').alt
local pipelink = require('Module:Partei').pipelink
local pzn = require('Module:Wahl Gruppen').pzn
local getArgs = require('Module:Arguments').getArgs
function p.fraktionen(frame)
local args = getArgs(frame)
local index, data = {}, {}
local num = 1
local gesamt = 0
local i = 0
for a = 1, 80 do i = i + 1
if args['p'..i] or args['f'..i] then table.insert(index, i) end
end
while (args['s'..num]) or (args['m'..num]) do
data[num] = {
s = tonumber(args['s'..num]) or tonumber(args['m'..num]),
}
gesamt = gesamt + data[num].s
num = num+1
end
if args['r1'] then a = 1 else a = 0 end
if args['v1'] then b = 1 else b = 0 end
if args['prozent'] then c = 1 else c = 0 end
if args['d1'] then d = 1 else d = 0 end
if args['p1'] then e = 2 else e = 0 end
if args['s1'] then f = 1 else f = 0 end
local col = 3 + a + b + c + d + e + f
local root = mw.html.create('table'):addClass('wikitable')
root
:tag('th'):attr('colspan', '2'):wikitext('Fraktion'):done()
if args['r1'] then
root
:tag('th'):wikitext('Richtung'):done()
end
if args['v1'] then
root
:tag('th'):wikitext('Vorsitzender'):done()
end
root
:tag('th'):wikitext('Mandate'):done()
if args['p1'] then
root
:tag('th'):attr('colspan', '2'):wikitext('Partei'):done()
:tag('th'):wikitext('Mandate'):done()
end
if args['prozent'] then
root
:tag('th'):wikitext('Prozent'):done()
end
if args['d1'] then
root
:tag('th'):wikitext('+/-'):done()
end
for i, v in ipairs(index) do root:tag('tr')
row = root:tag('tr')
if args['f'..v] then
row:tag('td')
:css('background', "#"..farbe({parteiname('EU-'..args['f'..v])}))
:attr('rowspan', args['n'..v])
row:tag('td')
:wikitext(full({args['f'..v], 'EU'}))
:attr('rowspan', args['n'..v])
if args['r'..v] then
row:tag('td')
:wikitext(args['r'..v])
end
if args['v'..v] then
row:tag('td')
:wikitext(args['v'..v])
end
row:tag('td')
:wikitext('<div>'..(args['m'..v] or args['s'..v])..' / '.. gesamt ..'</div><div style="width:100px;border:0.1px solid #AAA;background-color:#FFF;height:0.6em;position:relative;"><div style="background-color:#' ..farbe({parteiname('EU-'..args['f'..v])})..';width:'.. (args['m'..v] or args['s'..v])/gesamt*100 ..'px;height:0.6em;"></div></div>')
:attr('rowspan', args['n'..v])
if args['prozent'] then
row:tag('td')
:wikitext(pzn({args['m'..v], gesamt}))
:css('text-align', 'right')
end
end
if args['p'..v] then
row:tag('td')
:css('background', "#"..farbe({(args['p'.. v])}))
row:tag('td')
:wikitext(args['p'..v])
end
if args['d'..v] then
row:tag('td')
:css('text-align', 'center')
:wikitext(args['d'..v])
end
if args['s'..v] then
row:tag('td')
:wikitext('<div>'..args['s'..v]..' / '..gesamt..'</div><div style="width:100px;border:0.1px solid #AAA;background-color:#FFF;height:0.6em;position:relative;"><div style="background-color:#' ..farbe({(args['p'.. v])})..';width:'.. args['s'..v]/gesamt*100 ..'px;height:0.6em;"></div></div>')
end
end
if args['url'] then
row = root:tag('tr')
row:tag('td')
:attr('colspan', col)
row = root:tag('tr')
row:tag('td')
:wikitext('Quelle: ['.. args['url']..' Europäisches Parlament]')
:attr('colspan', col)
end
return root
end
function p.landeslisten(frame)
local args = getArgs(frame)
local index, data = {}, {}
local num = 1
local gesamt = 0
local i = 0
for a = 1, 80 do i = i + 1
if args['g'..i] then gruppe = true end
if args['p'..i] then partei = true end
if args['e'..i] then eupart = true end
if args['l'..i] or args['p'..i] then table.insert(index, i) end
end
while (args['s'..num]) do
data[num] = {
s = tonumber(args['s'..num]),
}
gesamt = gesamt + data[num].s
num = num+1
end
if partei then a = 2 else a = 0 end
if args['a1'] then b = 1 else b = 0 end
if args['z1'] then d = 1 else d = 0 end
if eupart or args['s1'] then e = 1 else e = 0 end
if args['k1'] or args['v1'] or args['f1'] then f = 1 else f = 0 end
if args['w1'] or args['r1'] then g = 1 else g = 0 end
if gruppe then h = 1 else h = 0 end
colth = 2 + a + h -- siehe colspan ZELLE "Listen/Parteien"
colq = 2 + a + b + d + e + f + g + h -- siehe colspan ZELLE "Quelle"
if args['quelle'] then quelle = args['quelle'] else quelle = 'Europäisches Parlament' end
local root = mw.html.create('table'):addClass('wikitable')
if args['s1'] then titel = 'Mandate' elseif eupart then titel = '[[Europäische politische Partei|Europapartei]]' end
titel2 = args['attribut'] or 'N.'
titel3 = args['amt'] or 'Erstplatzierter<br/>in der Liste'
titel4 = args['wahlkreis'] or 'Wahlkreise'
row = root:tag('tr')
if args['a1'] then
row:tag('th'):wikitext(titel2):done()
end
row:tag('th'):attr('colspan', colth):wikitext('Listen/Parteien'):done()
if args['z1'] then
row:tag('th'):wikitext('Name'):done()
end
row:tag('th'):wikitext(titel):done()
if args['f1'] then
row:tag('th'):wikitext('[[Fraktion im Europäischen Parlament|Fraktion]]'):done()
elseif args['k1'] or args['v1'] then
row:tag('th'):wikitext(titel3):done()
end
if args['w1'] or args['r1'] then
row:tag('th'):wikitext(titel4):done()
end
for i, v in ipairs(index) do root:tag('tr')
local p = args['p'..v] -- siehe colspan SPALTE "Listen/Parteien"
if p then b = 1 else if args['s1'] then b = 3 else b = 2 end end
row = root:tag('tr')
if args['a'..v] then
row:tag('td')
:css('background', '#F0F0F0')
:css('font-weight', 'bold')
:css('text-align', 'center')
:wikitext(args['a'..v])
:attr('rowspan', args['an'..v] or args['n'..v])
end
if args['l'..v] then
if args['farbliste'] then
row:tag('td')
:css('background', "#"..farbe({(args['p'..v] or args['l'..v])}))
:attr('rowspan', args['n'..v])
else
row:tag('td')
:css('background', "#"..farbe({(args['l'..v])}))
:attr('rowspan', args['n'..v])
end
if partei or gruppe then
if gruppe then
if args['g'..v] then
row:tag('td')
:wikitext(args['l'..v])
:attr('rowspan', args['n'..v])
else
if args['p'..v] then
row:tag('td')
:wikitext(args['l'..v])
:attr('rowspan', args['n'..v])
:attr('colspan', 2)
else
row:tag('td')
:wikitext(args['l'..v])
:attr('rowspan', args['n'..v])
:attr('colspan', 4)
end
end
else
if args['p'..v] then
row:tag('td')
:wikitext(args['l'..v])
:attr('rowspan', args['n'..v])
else
row:tag('td')
:wikitext(args['l'..v])
:attr('rowspan', args['n'..v])
:attr('colspan', 3)
end
end
else
row:tag('td')
:wikitext(args['l'..v])
end
end
if args['g'..v] then
row:tag('td')
:wikitext(args['g'..v])
:attr('rowspan', args['gn'..v])
end
if args['p'..v] then
row:tag('td')
:css('background', "#"..farbe({(args['p'..v])}))
row:tag('td')
:wikitext(args['p'..v])
end
if args['z'..v] then
row:tag('td')
:wikitext(args['z'..v])
end
if args['s'..v] then
row:tag('td')
:wikitext('<div>'..args['s'..v]..' / '.. gesamt ..'</div><div style="width:100px;border:0.1px solid #AAA;background-color:#FFF;height:0.6em;position:relative;"><div style="background-color:#' ..farbe({(args['p'..v]) or (args['l'..v])})..';width:'.. args['s'..v]/gesamt*100 ..'px;height:0.6em;"></div></div>')
end
if eupart then
if args['e'..v] then
row:tag('td')
:wikitext(pipelink({args['e'..v], 'EP'}))
else
row:tag('td')
:wikitext('–')
end
end
if args['f'..v] then
row:tag('td')
:wikitext(pipelink({args['f'..v], 'EU'}))
end
if args['k'..v] then
row:tag('td')
:wikitext(args['k'..v])
:attr('rowspan', args['an'..v] or args['n'..v])
end
if args['v'..v] then
row:tag('td')
:wikitext(args['v'..v])
end
if args['w'..v] then
row:tag('td')
:wikitext(args['w'..v])
:attr('rowspan', args['gn'..v] or args['n'..v])
end
if args['r'..v] then
row:tag('td')
:wikitext(args['r'..v])
end
end
if args['url'] or args['quellen'] then
row = root:tag('tr')
row:tag('td')
:attr('colspan', colq)
if args['url'] then
row = root:tag('tr')
row:tag('td')
:wikitext('Quelle: ['.. args['url']..' '..quelle..']')
:attr('colspan', colq)
else
row = root:tag('tr')
row:tag('td')
:wikitext('Quellen: ', args['quellen'])
:attr('colspan', colq)
end
end
return root
end
return p