Modul:Wahlkreise
Zur Navigation springen
Zur Suche springen
Die Dokumentation für dieses Modul kann unter Modul:Wahlkreise/Doku erstellt werden
local p = {}
local getArgs = require('Module:Arguments').getArgs
local cfg = mw.loadData('Modul:Wahlkreise/Liste');
function p.link(a, beg, x)
local args = getArgs(frame)
if beg then b = ' ('..beg..')' else b = '' end
name = 'Wahlkreis '..a..b
if x then c = ('#'..x) else c = '' end
if name == mw.title.getCurrentTitle().prefixedText then
code = '<span style="font-weight:bold">Wahlkreis '..a..'</span>'
else
code = '[['..name..c..'|Wahlkreis '..a..']]'
end
return code
end
function p.region(frame)
local args = getArgs(frame)
local code = args[1]
local region = cfg.einheit[code]
return region[1]
end
function p.tabelle(frame)
local args = getArgs(frame)
local root = mw.html.create('table'):addClass('wikitable floatright mw-collapsible mw-collapsed'):css('font-size', '89%'):css('line-height', '1.45em')
root:tag('tr')
:tag('th'):wikitext('Wahlkreise – ' ..(args['k'] or args['z']) ..' – [['..p.region({args[1]})..']] '):attr('colspan', 3):css('line-height', '2em'):done()
root:tag('tr')
:tag('th'):wikitext('Provinz'):attr('colspan', '2'):css('font-size', '90%'):css('line-height', '2em'):done()
:tag('th'):wikitext('Gemeinden nach Provinzen ⮞ Wahlkreis'):css('font-size', '90%'):css('line-height', '2em'):done()
local prov = {}
for k, v in pairs(cfg.info) do
prov[#prov+1] = k
end
table.sort(prov)
for _, value in pairs(prov) do
local datum = cfg.info[value]
if args['jahr'] then provinz = args[1]..'-'..args['jahr'] else provinz = args[1] end
if args['jahr'] then einheit = mw.ustring.find(value, args['jahr']) end
if einheit then
division = mw.ustring.sub(value, 1, (einheit - 2))
else
if mw.ustring.find(value, '/') then
division = mw.ustring.sub(value, 1, ((mw.ustring.find(value, '/') - 1)))
titel = '↳ <span style="font-style:italic">'..mw.ustring.sub(value, ((mw.ustring.find(value, '/') +1)))..':</span><br/>'
else
division = value
end
end
if provinz == datum[1] then
if args['z'] then
gemeinden = datum['zg1'] or 'alle'
gemeinden2 = datum['zg2'] or ''
gemeinden3 = datum['zg3'] or ''
gemeinden4 = datum['zg4'] or ''
gemeinden5 = datum['zg5'] or ''
gemeinden6 = datum['zg6'] or ''
gemeinden7 = datum['zg7'] or ''
gemeinden8 = datum['zg8'] or ''
gemeinden9 = datum['zg9'] or ''
else
gemeinden = ((datum['g1'] and datum['t1']) and datum['g1']..'<small> + '..datum['t1']..'</small>') or (datum['t1'] and '<small>'..datum ['t1']..'</small>') or (datum['g1'] or 'alle')
gemeinden2 = ((datum['g2'] and datum['t2']) and datum['g2']..'<small> + '..datum['t2']..'</small>') or datum['g2'] or (datum['t2'] and '<small>'..datum ['t2']..'</small>') or ''
gemeinden3 = ((datum['g3'] and datum['t3']) and datum['g3']..'<small> + '..datum['t3']..'</small>') or datum['g3'] or (datum['t3'] and '<small>'..datum ['t3']..'</small>') or ''
gemeinden4 = ((datum['g4'] and datum['t4']) and datum['g4']..'<small> + '..datum['t4']..'</small>') or datum['g4'] or (datum['t4'] and '<small>'..datum ['t4']..'</small>') or ''
gemeinden5 = ((datum['g5'] and datum['t5']) and datum['g5']..'<small> + '..datum['t5']..'</small>') or datum['g5'] or (datum['t5'] and '<small>'..datum ['t5']..'</small>') or ''
gemeinden6 = ((datum['g6'] and datum['t6']) and datum['g6']..'<small> + '..datum['t6']..'</small>') or datum['g6'] or (datum['t6'] and '<small>'..datum ['t6']..'</small>') or ''
gemeinden7 = ((datum['g7'] and datum['t7']) and datum['g7']..'<small> + '..datum['t7']..'</small>') or datum['g7'] or (datum['t7'] and '<small>'..datum ['t7']..'</small>') or ''
gemeinden8 = ((datum['g8'] and datum['t8']) and datum['g8']..'<small> + '..datum['t8']..'</small>') or datum['g8'] or (datum['t8'] and '<small>'..datum ['t8']..'</small>') or ''
gemeinden9 = ((datum['g9'] and datum['t9']) and datum['g9']..'<small> + '..datum['t9']..'</small>') or datum['g9'] or (datum['t9'] and '<small>'..datum ['t9']..'</small>') or ''
end
if (args['z'] and datum['zw9']) or datum['w9'] then element9 = '<br/>'..gemeinden9..' ⮞ '..p.link((args['z'] and datum['zw9']) or datum['w9'], (args['z'] and datum['zk9']) or datum['k9'], (args['z'] and datum['zp9']) or datum['p9']) else element9 = '' end
if (args['z'] and datum['zw8']) or datum['w8'] then element8 = '<br/>'..gemeinden8..' ⮞ '..p.link((args['z'] and datum['zw8']) or datum['w8'], (args['z'] and datum['zk8']) or datum['k8'], (args['z'] and datum['zp8']) or datum['p8']) else element8 = '' end
if (args['z'] and datum['zw7']) or datum['w7'] then element7 = '<br/>'..gemeinden7..' ⮞ '..p.link((args['z'] and datum['zw7']) or datum['w7'], (args['z'] and datum['zk7']) or datum['k7'], (args['z'] and datum['zp7']) or datum['p7']) else element7 = '' end
if (args['z'] and datum['zw6']) or datum['w6'] then element6 = '<br/>'..gemeinden6..' ⮞ '..p.link((args['z'] and datum['zw6']) or datum['w6'], (args['z'] and datum['zk6']) or datum['k6'], (args['z'] and datum['zp6']) or datum['p6']) else element6 = '' end
if (args['z'] and datum['zw5']) or datum['w5'] then element5 = '<br/>'..gemeinden5..' ⮞ '..p.link((args['z'] and datum['zw5']) or datum['w5'], (args['z'] and datum['zk5']) or datum['k5'], (args['z'] and datum['zp5']) or datum['p5']) else element5 = '' end
if (args['z'] and datum['zw4']) or datum['w4'] then element4 = '<br/>'..gemeinden4..' ⮞ '..p.link((args['z'] and datum['zw4']) or datum['w4'], (args['z'] and datum['zk4']) or datum['k4'], (args['z'] and datum['zp4']) or datum['p4']) else element4 = '' end
if (args['z'] and datum['zw3']) or datum['w3'] then element3 = '<br/>'..gemeinden3..' ⮞ '..p.link((args['z'] and datum['zw3']) or datum['w3'], (args['z'] and datum['zk3']) or datum['k3'], (args['z'] and datum['zp3']) or datum['p3']) else element3 = '' end
if (args['z'] and datum['zw2']) or datum['w2'] then element2 = '<br/>'..gemeinden2..' ⮞ '..p.link((args['z'] and datum['zw2']) or datum['w2'], (args['z'] and datum['zk2']) or datum['k2'], (args['z'] and datum['zp2']) or datum['p2']) else element2 = '' end
if (args['z'] and datum['zw2']) or datum['w2'] then element = ''..gemeinden..' ⮞ ' ..p.link((args['z'] and datum['zw1']) or datum['w1'], (args['z'] and datum['zk1']) or datum['k1'], (args['z'] and datum['zp1']) or datum['p1'])..element2..element3..element4..element5..element6..element7..element8..element9
else element = gemeinden..' ⮞ '..p.link((args['z'] and datum['zw1']) or datum['w1'], (args['z'] and datum['zk1']) or datum['k1'], (args['z'] and datum['zp1']) or datum['p1'])
end
if mw.ustring.find(value, '-') then
if datum['map'] then
unity = value
else
unity = division
end
else unity = value
end
local kart = cfg.info[unity]
karte = kart['map']
if not datum['anzahl'] and not mw.ustring.find(value, '/') then
root:tag('tr')
end
if mw.ustring.find(value, '/') then
if datum['anzahl'] then
root
:tag('td'):wikitext('[[Datei:'..karte..'|50x50px]]'):attr('rowspan', datum['anzahl']):done()
:tag('td'):wikitext('[['..division..']]<br/><small>('..datum['i']..' Gemeinden)</small>'):attr('rowspan', datum['anzahl']):done()
:tag('td'):wikitext(titel..element):done()
else
root:tag('tr')
:tag('td'):wikitext(titel..element):done()
end
else
root
:tag('td'):wikitext('[[Datei:'..karte..'|50x50px]]'):done()
:tag('td'):wikitext('[['..division..']]<br/><small>('..datum['i']..' Gemeinden)</small>'):done()
:tag('td'):wikitext(element):done()
end
end
end
return root
end
return p