„Modul:Direktwahl“ – Versionsunterschied
Zur Navigation springen
Zur Suche springen
[gesichtete Version] | [gesichtete Version] |
Inhalt gelöscht Inhalt hinzugefügt
Höhe |
Fix |
||
Zeile 11: | Zeile 11: | ||
local i = 0 |
local i = 0 |
||
for a = 1, 30 do i = i + 1 |
for a = 1, 30 do i = i + 1 |
||
if args['%'..i] or args['%z' |
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 args['zeile'..i] then zeile = true end |
||
end |
end |
||
Zeile 27: | Zeile 27: | ||
for i, v in ipairs(index) do root:tag('tr') |
for i, v in ipairs(index) do root:tag('tr') |
||
row = root:tag('tr') |
row = root:tag('tr') |
||
if args['l' |
if args['l'..v] then |
||
row:tag('td') |
row:tag('td') |
||
:wikitext(args['l' |
:wikitext(args['l'..v]) |
||
:css('text-align', 'left') |
:css('text-align', 'left') |
||
:css('width', '45%') |
:css('width', '45%') |
||
Zeile 35: | Zeile 35: | ||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext('<div style="width:100px;border:0.1px solid #F0F0F0;background-color:#FFF;height:1.2em;position:relative;"><div style="background-color:#' ..farbe({(args['l' |
:wikitext('<div style="width:100px;border:0.1px solid #F0F0F0;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-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext(args['m' |
:wikitext(args['m'..v]..' / '..gesamt) |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
end |
end |
||
Zeile 64: | Zeile 64: | ||
if zeile then hohe = '26px' else hohe = '20px' end |
if zeile then hohe = '26px' else hohe = '20px' end |
||
if args['k' |
if args['k'..v] then |
||
row:tag('td') |
row:tag('td') |
||
:wikitext(args['k' |
:wikitext(args['k'..v], sep..'('..args['p'..v]..')') |
||
:css('text-align', 'left') |
:css('text-align', 'left') |
||
:css('font-size', '96%') |
:css('font-size', '96%') |
||
:css('min-width', minbreite) |
:css('min-width', minbreite) |
||
:css('line-height', '13px') |
:css('line-height', '13px') |
||
:css('height', hohe) |
:css('height', hohe) |
||
:css('max-height', '26px') |
:css('max-height', '26px') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext('<div style="background-color:#' |
:wikitext('<div style="background-color:#'..(args['f'..v] or farbe({(args['p'..v])}))..';width:'.. (string.gsub(args['%'..v], "%,", "%."))*100/(string.gsub(args['%1'], "%,", "%.")) ..'px;min-width:1px;max-width:100px;height:1.2em;"></div>') |
||
:css('max-width', '102px') |
:css('max-width', '102px') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext(args['%' |
:wikitext(args['%'..v]..' %') |
||
:css('width', '60px') |
:css('width', '60px') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
Zeile 93: | Zeile 93: | ||
:css('font-size', '96%') |
:css('font-size', '96%') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext('<div style="background-color:#DABAD0;width:'.. (string.gsub(args['%sonstige'], "%,", "%."))*100/(string.gsub(args['%1'], "%,", "%.")) ..'px;height:1.2em;min-width:1px;"></div>') |
:wikitext('<div style="background-color:#DABAD0;width:'.. (string.gsub(args['%sonstige'], "%,", "%."))*100/(string.gsub(args['%1'], "%,", "%.")) ..'px;height:1.2em;min-width:1px;"></div>') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext(args['%sonstige']..' %') |
:wikitext(args['%sonstige']..' %') |
||
Zeile 143: | Zeile 143: | ||
if zeile then hohe = '26px' else hohe = '20px' end |
if zeile then hohe = '26px' else hohe = '20px' end |
||
if args['%z' |
if args['%z'..v] then |
||
row:tag('td') |
row:tag('td') |
||
:wikitext(args['kz' |
:wikitext(args['kz'..v], sep..'('..args['pz'..v]..')') |
||
:css('text-align', 'left') |
:css('text-align', 'left') |
||
:css('font-size', '96%') |
:css('font-size', '96%') |
||
:css('min-width', minbreite) |
:css('min-width', minbreite) |
||
:css('line-height', '13px') |
:css('line-height', '13px') |
||
:css('height', hohe) |
:css('height', hohe) |
||
:css('max-height', '26px') |
:css('max-height', '26px') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext('<div style="background-color:#' |
:wikitext('<div style="background-color:#'..(args['fz'..v] or farbe({(args['pz'..v])}))..';width:'.. (string.gsub(args['%z'..v], "%,", "%."))*100/(string.gsub(args['%z1'], "%,", "%.")) ..'px;min-width:1px;max-width:100px;height:1.2em;"></div>') |
||
:css('max-width', '102px') |
:css('max-width', '102px') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext(args['%z' |
:wikitext(args['%z'..v]..' %') |
||
:css('width', '60px') |
:css('width', '60px') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
Zeile 174: | Zeile 174: | ||
:css('max-width', maxbreite) |
:css('max-width', maxbreite) |
||
:css('line-height', '13px') |
:css('line-height', '13px') |
||
:css('height', hohe) |
:css('height', hohe) |
||
:css('max-height', '26px') |
:css('max-height', '26px') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext('<div style="background-color:#' ..color1..';width:100px;height:1.2em;"></div>') |
:wikitext('<div style="background-color:#' ..color1..';width:100px;height:1.2em;"></div>') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext(args['%z1']..' %') |
:wikitext(args['%z1']..' %') |
||
Zeile 192: | Zeile 192: | ||
:css('font-size', '96%') |
:css('font-size', '96%') |
||
:css('line-height', '13px') |
:css('line-height', '13px') |
||
:css('height', hohe) |
:css('height', hohe) |
||
:css('max-height', '26px') |
:css('max-height', '26px') |
||
:css('border-bottom', '0.1px solid #C0C0C0') |
:css('border-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext('<div style="background-color:#' ..color2..';width:'.. (string.gsub(args['%z2'], "%,", "%."))*100/(string.gsub(args['%z1'], "%,", "%.")) ..'px;height:1.2em;"></div>') |
:wikitext('<div style="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-bottom', '0.1px solid #C0C0C0') |
||
:css('border-right', '0.1px solid #F0F0F0') |
:css('border-right', '0.1px solid #F0F0F0') |
||
row:tag('td') |
row:tag('td') |
||
:wikitext(args['%z2']..' %') |
:wikitext(args['%z2']..' %') |
Version vom 15. Mai 2024, 17:29 Uhr
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
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 #F0F0F0;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 zeile then hohe = '26px' else hohe = '20px' 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 #F0F0F0')
row:tag('td')
:wikitext('<div style="background-color:#'..(args['f'..v] or farbe({(args['p'..v])}))..';width:'.. (string.gsub(args['%'..v], "%,", "%."))*100/(string.gsub(args['%1'], "%,", "%.")) ..'px;min-width:1px;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['%'..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('border-bottom', '0.1px solid #C0C0C0')
:css('border-right', '0.1px solid #F0F0F0')
row:tag('td')
:wikitext('<div style="background-color:#DABAD0;width:'.. (string.gsub(args['%sonstige'], "%,", "%."))*100/(string.gsub(args['%1'], "%,", "%.")) ..'px;height:1.2em;min-width:1px;"></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['k1'] then
if args['invz'] then
kand1 = args['k2']
kand2 = args['k1']
gruppe1 = args['p2']
gruppe2 = args['p1']
color1 = args['f2'] or farbe({args['p2']})
color2 = args['f1'] or farbe({args['p1']})
else
kand1 = args['k1']
kand2 = args['k2']
gruppe1 = args['p1']
gruppe2 = args['p2']
color1 = args['f1'] or farbe({args['p1']})
color2 = args['f2'] or farbe({args['p2']})
end
end
if args['sep1'] then sep1 = '<br />' hohe = '26px' else sep1 = ' ' hohe = '20px' end
if args['sep2'] then sep2 = '<br />' hohe = '26px' else sep2 = ' ' hohe = '20px' 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['%z3'] then
for i, v in ipairs(index) do
row = root:tag('tr')
if args['zeile'..v] then sep = '<br />' else sep = ' ' end
if zeile then hohe = '26px' else hohe = '20px' 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 #F0F0F0')
row:tag('td')
:wikitext('<div style="background-color:#'..(args['fz'..v] or farbe({(args['pz'..v])}))..';width:'.. (string.gsub(args['%z'..v], "%,", "%."))*100/(string.gsub(args['%z1'], "%,", "%.")) ..'px;min-width:1px;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, sep1..'('.. gruppe1..')')
: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 #F0F0F0')
row:tag('td')
:wikitext('<div style="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, sep2..'('.. gruppe2..')')
: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 #F0F0F0')
row:tag('td')
:wikitext('<div style="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)
return '  <span style="background-color:#4BBD71;padding-left:6px;padding-right:6px;line-height:6px;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>'
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