Modul:Sitzeverteilung
Die Dokumentation für dieses Modul kann unter Modul:Sitzeverteilung/Doku erstellt werden
local p = {}
local getArgs = require('Modul:Arguments').getArgs
local farbe = require('Modul:Partei').farbe
local pipelink = require('Modul:Partei').pipelink
local function sitze(args)
local gesamt = 0
local data = {}
local num = 1
while (args['n'..num]) do
if (tonumber(args['n'..num])) then
if args['staat'] then
data[num] = {
nummer = args['n'..num] and tonumber(args['n'..num]),
farbe = args['f'..num] or farbe({args['p'..num], args['staat']}),
partei = pipelink({args['p'..num], args['staat']}),
akronym = args['p'..num]
}
else
data[num] = {
nummer = args['n'..num] and tonumber(args['n'..num]),
farbe = args['f'..num] or farbe({args['p'..num]}),
partei = args['p'..num]
}
end
gesamt = gesamt + data[num].nummer
num = num+1
else
error(string.format('Ungültiger Wert für n%d', num),2)
end
end
data['gesamt'] = gesamt
return data
end
local function diagramm(root, args, data)
local gesamt = 0
local width = args.width or 240
local range = root
local lastRotation = 0
for i, v in ipairs(data) do
if args['label'] then sitze = tostring(v.nummer) else sitze = '' end
if v.nummer > 0 then
range = range:tag('div')
range:css('transform', 'rotate('..tostring(180 * lastRotation)..'deg)')
range:css('width', tostring(width)..'px')
range:css('height', tostring(width/2)..'px')
range:css('position', 'relative')
range:css('transform-origin', 'bottom center')
range:css('border-top-left-radius', tostring(width/2)..'px')
range:css('border-top-right-radius', tostring(width/2)..'px')
range:css('background', '#'..v.farbe)
range:tag('div')
:css('text-align', 'center')
:css('width', tostring(width)..'px')
:css('height', tostring(width/2)..'px')
:css('position', 'absolute')
:css('transform', 'rotate('..tostring(-90 + 180 * (v.nummer/data.gesamt/2))..'deg)')
:css('transform-origin', 'bottom center')
:css('top', '-15px')
:css('line-height', '15px')
:css('padding-bottom', '15px')
:wikitext(sitze)
:done()
lastRotation = v.nummer/data.gesamt
end
end
root:tag('div')
:css('width', tostring(width*3/8)..'px')
:css('height', tostring(width*3/8)..'px')
:css('margin', tostring(-width*3/16)..'px auto')
:css('border-radius', tostring(width*3/16)..'px')
:css('transform', 'translate(0,0)')
:css('background', 'white')
:done()
:tag('div')
:css('width', tostring(width+1)..'px')
:css('height', tostring(width*3/8)..'px')
:css('transform', 'translate(0,0)')
:css('background', 'white')
:done()
return root
end
local function clegend(root, args, data)
local list = root:tag('ul')
list:css('column-count', '2')
list:css('margin-left', '0')
for i, v in ipairs(data) do
if args['staat'] then
if v.partei == v.akronym then partleg = '[['..v.akronym..']]'
else partleg = v.partei
end
else partleg = v.partei
end
list:tag('li')
:css('list-style-type', 'none')
:css('list-style-image', 'none')
:css('margin', '0')
:tag('span')
:css('border', 'none')
:css('width', '1.2em')
:css('height', '1.2em')
:css('background-color', '#'..v.farbe)
:css('margin-right', '0.3em')
:css('vertical-align', 'middle')
:css('display', 'inline-block')
:done()
:wikitext(partleg..': ' .. v.nummer)
:done()
end
return list
end
local function volksvertretung(root, args, data)
local width = args.width or 240
local maindiv = root:tag('div')
local inner = maindiv:tag('div')
maindiv:addClass(args['align'] or 't'..'right')
if args['legende'] or args['titel'] then
local miniatur = inner
miniatur:addClass('thumbinner')
miniatur:css('width', tostring(width*1.125)..'px')
miniatur:css('padding-right', '6.5px !important')
end
if args['titel'] then
local bildtitel = inner:tag('div')
bildtitel:addClass('thumbdescription')
bildtitel:css('font-weight', 'bold')
bildtitel:css('text-align', 'center')
bildtitel:css('font-size', '100%')
bildtitel:wikitext(args['titel'])
end
local bild = inner:tag('div')
bild:addClass('thumbimage')
bild:addClass('diagram')
bild:addClass('noprint')
bild:css('width', tostring(width)..'px')
bild:css('height', tostring(width/2)..'px')
bild:css('padding', tostring(width/15)..'px')
bild:css('overflow', 'hidden')
bild:css('background', 'white')
diagramm(bild, args, data)
if args['legende'] then
local bildlegende = inner:tag('div')
bildlegende:addClass('thumbcaption')
bildlegende:wikitext('Insgesamt '..tostring(data.gesamt)..' Sitze')
clegend(bildlegende, args, data)
end
return root
end
function p._sitzverteilung(args)
local root = mw.html.create('div')
local data = sitze(args)
return volksvertretung(root, args, data)
end
function p.sitzverteilung(frame)
return p._sitzverteilung(getArgs(frame))
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.