Modul:Direktwahl
Die Dokumentation für dieses Modul kann unter Modul:Direktwahl/Doku erstellt werden
local p = {}
local farbe = require('Module:Partei').farbe
local alt = require('Module:Partei').alt
local getArgs = require('Module:Arguments').getArgs
function p.bar(frame)
local args = getArgs(frame)
local index, data = {}, {}
local num = 1
local gesamt = 0
local i = 0
for a = 1, 30 do i = i + 1
if args['%'..i] or args['%z'..i] or args['m'..i] then table.insert(index, i) end
if args['zeile'..i] then zeile = true end
if zeile then hohe = '26px' else hohe = '20px' end
end
local root = mw.html.create('table'):addClass('wikitable'):css('width', '100%'):css('margin-top', '2px'):css('margin-bottom', '1px'):css('background-color', '#FCFCFC'):css('max-width', '446px')
if args['m1'] then
while (args['m'..num]) do
data[num] = {
s = tonumber(args['m'..num]),
}
gesamt = gesamt + data[num].s
num = num+1
end
for i, v in ipairs(index) do root:tag('tr')
row = root:tag('tr')
if args['l'..v] then
row:tag('td')
:wikitext(args['l'..v])
:css('text-align', 'left')
:css('width', '45%')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #F0F0F0')
row:tag('td')
:wikitext('<div style="width:100px;border:0.1px solid #D0D0D0;background-color:#FFF;height:1.2em;position:relative;"><div style="background-color:#' ..farbe({(args['l'..v])})..';width:'.. args['m'..v]*100/gesamt ..'px;height:1.2em"></div></div>')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #F0F0F0')
row:tag('td')
:wikitext(args['m'..v]..' / '..gesamt)
:css('border-bottom', '0.1px solid #C0C0C0')
end
end
end
if args['stimmen3'] then minbreite = '246px' else minbreite = '198px' end
if args['%z1'] then
root:tag('th')
:wikitext('1. Wahlgang')
:attr('colspan', '3')
:css('background', '#F2F2F4')
:css('height', '2em')
:css('font-weight', 'bold')
:css('border-bottom', '0.1px solid #C0C0C0')
end
if args['k1'] then
for i, v in ipairs(index) do
row = root:tag('tr')
if args['zeile'..v] then sep = '<br />' else sep = ' ' end
if args['k'..v] then
row:tag('td')
:wikitext(args['k'..v], sep..'('..args['p'..v]..')')
:css('text-align', 'left')
:css('font-size', '96%')
:css('min-width', minbreite)
:css('line-height', '13px')
:css('height', hohe)
:css('max-height', '26px')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #D0D0D0')
row:tag('td')
:wikitext('<div style="margin-left:-6px;background-color:#'..(args['f'..v] or farbe({(args['p'..v])}))..';width:'.. (string.gsub(args['%'..v], "%,", "%."))*100/(string.gsub(args['%1'], "%,", "%.")) ..'px;max-width:100px;height:1.2em;min-width:2px;"></div>')
:css('max-width', '102px')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #F0F0F0')
row:tag('td')
:wikitext(args['%'..v]..' %')
:css('width', '60px')
:css('border-bottom', '0.1px solid #C0C0C0')
end
end
if args['%sonstige'] then
row = root:tag('tr')
row:tag('td')
:wikitext('Sonstige < '.. (args['ak'] or '3') ..' %')
:css('text-align', 'left')
:css('font-size', '96%')
:css('height', hohe)
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #D0D0D0')
row:tag('td')
:wikitext('<div style="margin-left:-6px;background-color:#DABAD0;width:'.. (string.gsub(args['%sonstige'], "%,", "%."))*100/(string.gsub(args['%1'], "%,", "%.")) ..'px;height:1.2em;min-width:2px;"></div>')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #F0F0F0')
row:tag('td')
:wikitext(args['%sonstige']..' %')
:css('width', '60px')
:css('border-bottom', '0.1px solid #C0C0C0')
end
end
if args['%z1'] then
root:tag('th')
:wikitext('2. Wahlgang')
:attr('colspan', '3')
:css('background', '#F2F2F4')
:css('height', '2em')
:css('font-weight', 'bold')
:css('border-bottom', '0.1px solid #C0C0C0')
end
if args['zeile1'] then sep1 = '<br />' else sep1 = ' ' end
if args['zeile2'] then sep2 = '<br />' else sep2 = ' ' end
if args['k1'] then
if args['invz'] then
kand1 = args['k2']..sep2..'('..args['p2']..')'
kand2 = args['k1']..sep1..'('..args['p1']..')'
color1 = args['f2'] or farbe({args['p2']})
color2 = args['f1'] or farbe({args['p1']})
else
kand1 = args['k1']..sep1..'('..args['p1']..')'
kand2 = args['k2']..sep2..'('..args['p2']..')'
color1 = args['f1'] or farbe({args['p1']})
color2 = args['f2'] or farbe({args['p2']})
end
end
if args['%z3'] then
for i, v in ipairs(index) do
row = root:tag('tr')
if args['zeile'..v] then sep = '<br />' else sep = ' ' end
if args['%z'..v] then
row:tag('td')
:wikitext(args['kz'..v], sep..'('..args['pz'..v]..')')
:css('text-align', 'left')
:css('font-size', '96%')
:css('min-width', minbreite)
:css('line-height', '13px')
:css('height', hohe)
:css('max-height', '26px')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #D0D0D0')
row:tag('td')
:wikitext('<div style="margin-left:-6px;background-color:#'..(args['fz'..v] or farbe({(args['pz'..v])}))..';width:'.. (string.gsub(args['%z'..v], "%,", "%."))*100/(string.gsub(args['%z1'], "%,", "%.")) ..'px;max-width:100px;height:1.2em;"></div>')
:css('max-width', '102px')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #F0F0F0')
row:tag('td')
:wikitext(args['%z'..v]..' %')
:css('width', '60px')
:css('border-bottom', '0.1px solid #C0C0C0')
end
end
else
if args['%z1'] then
row = root:tag('tr')
row:tag('td')
:wikitext(kand1)
:css('text-align', 'left')
:css('font-size', '96%')
:css('max-width', maxbreite)
:css('line-height', '13px')
:css('height', hohe)
:css('max-height', '26px')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #D0D0D0')
row:tag('td')
:wikitext('<div style="margin-left:-6px;background-color:#' ..color1..';width:100px;height:1.2em;"></div>')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #F0F0F0')
row:tag('td')
:wikitext(args['%z1']..' %')
:css('width', '60px')
:css('border-bottom', '0.1px solid #C0C0C0')
row = root:tag('tr')
row:tag('td')
:wikitext(kand2)
:css('text-align', 'left')
:css('font-size', '96%')
:css('line-height', '13px')
:css('height', hohe)
:css('max-height', '26px')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #D0D0D0')
row:tag('td')
:wikitext('<div style="margin-left:-6px;background-color:#' ..color2..';width:'.. (string.gsub(args['%z2'], "%,", "%."))*100/(string.gsub(args['%z1'], "%,", "%.")) ..'px;height:1.2em;"></div>')
:css('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #F0F0F0')
row:tag('td')
:wikitext(args['%z2']..' %')
:css('width', '60px')
:css('border-bottom', '0.1px solid #C0C0C0')
end
end
return root
end
function p.gewahlt(frame)
local args = getArgs(frame)
if args['align'] then option = '<div style="text-align:'..args['align']..'">' close = '</div>' else option = '  ' close = '' end
if args[1] == 'N' then return ''..option..'<span style="background-color:#FF4A45;padding-left:6px;padding-right:6px;padding-top:1px;padding-bottom:1px;line-height:8px;border-radius:4px 4px 4px;font-size:80%;border:0.1px solid #FF0700;text-align:center;font-weight:bold;color:#FFFFFF;">Nicht gewählt</span>'..close
else return ''..option..'<span style="background-color:#4BBD71;padding-left:6px;padding-right:6px;padding-top:1px;padding-bottom:1px;line-height:8px;border-radius:4px 4px 4px;font-size:80%;border:0.1px solid #3A9157;text-align:center;font-weight:bold;color:#FFFFFF;">'.. (args[1] or 'Gewählt')..'</span>'..close
end
end
function p.gew(frame) -- SUPPORT Vorlage:Parlamentswahl
local args = getArgs(frame)
local max = tonumber(args[1]) or 0 -- 0 otherwise error in artikel vorlage:achse --
local v = tonumber(args[2]) or 0
local d = tonumber(args[3]) or 0
num = v+d
z = v + 2
if v == 0 then
return '<div style="z-index:1; position:relative; height:'..(6*d-1)..'px; border-top:1px solid #CCC; border-bottom:1px solid #777;"><div style="position:absolute; bottom:'.. (6*d-12+1) ..'px; background-color:#FFFFFF; padding:0 2px 0 0; color:#777;"> '..d..'</div><div style="position:absolute; bottom:-10px; background-color:#FFFFFF; padding:0 1px 0 0; color:#777;"> 0</div></div><div style="z-index:3; position:relative; height:'..(6*d-1)..'px; border-bottom:1px solid #CCC;"><div style="position:absolute; bottom:-10px; background-color:#FFFFFF; padding:0 1px 0 0; color:#777;">'..-d..'</div></div>'
else
if max > v then
return '<div style="z-index:'..z..'; position:relative; height:'..(6*d-1)..'px; border-top:1px solid #CCC;"><div style="position:absolute; bottom:'.. (6*d-12+1) ..'px; background-color:#FFFFFF; padding:0 2px 0 0; color:#777;"> '..num..'</div></div>'
end
end
end
function p.ver(frame)
local args = getArgs(frame)
local min = tonumber(args[1]) or 0
local v = tonumber(args[2]) or 0
local d = args[3] or 0
num = v-d
if min < v then
return '<div style="z-index:3; position:relative; height:'..(6*d-1)..'px; border-bottom:1px solid #CCC;"><div style="position:absolute; bottom:-10px; background-color:#FFFFFF; padding:0 1px 0 0; color:#777;">'..num..'</div></div>'
end
end
return p