Module:Succession table monarch

local getArgs = require('Module:Arguments').getArgs
local TableTools = require('Module:TableTools')
local messages = mw.loadData('Module:Succession table monarch/messages')

local p = {}

p.fromArgs = function(argElements)
	local mainTag = mw.html.create('table')
		:attr('cellspacing', '0')
		:css('text-align', 'center')
		:tag('tr')
			:tag('th'):cssText('width: 25%; border: solid #aaa; border-width: 1px 1px 1px 1px; background: #B9D1FF; font-size: 105%;'):wikitext(messages.name or 'Name'):done()
			:tag('th'):cssText('width: 10%; border: solid #aaa; border-width: 1px 1px 1px 0px; background: #B9D1FF; font-size: 105%;'):wikitext(messages.lifespan or 'Lifespan'):done()
			:tag('th'):cssText('width: 10%; border: solid #aaa; border-width: 1px 1px 1px 0px; background: #B9D1FF; font-size: 105%;'):wikitext(messages.reignStart or 'Reign start'):done()
			:tag('th'):cssText('width: 10%; border: solid #aaa; border-width: 1px 1px 1px 0px; background: #B9D1FF; font-size: 105%;'):wikitext(messages.reignEnd or 'Reign end'):done()
			:tag('th'):cssText('width: 25%; border: solid #aaa; border-width: 1px 1px 1px 0px; background: #B9D1FF; font-size: 105%;'):wikitext(messages.notes or 'Notes'):done()
			:tag('th'):cssText('width: 10%; border: solid #aaa; border-width: 1px 1px 1px 0px; background: #B9D1FF; font-size: 105%;'):wikitext(messages.family or 'Family'):done()
			:tag('th'):cssText('width: 10%; border: solid #aaa; border-width: 1px 1px 1px 0px; background: #B9D1FF; font-size: 105%;'):wikitext(messages.image or 'Image'):done()
			:done()
	
	for _,eachElement in ipairs(argElements) do
		if eachElement.name then
			local namePlainList = ''
			if eachElement.nickname or eachElement.native then
				namePlainList = mw.getCurrentFrame():expandTemplate{
					title = messages.plainlistTemplateName or 'Plainlist',
					args = {'\n' .. 
						table.concat(TableTools.compressSparseArray({
							eachElement.nickname and ('* ' .. tostring(mw.html.create('small'):wikitext("<i>" .. eachElement.nickname .. "</i>"))) or nil,
							eachElement.native and ('* ' .. eachElement.native) or nil
					}), '\n')}
				}
			end
			local rowTr = mainTag:tag('tr')
			
			rowTr:tag('td')
					:cssText('border: solid #aaa; border-width: 0px 1px 1px 1px; background: #F0F8FF; vertical-align: middle;')
					:wikitext(eachElement.name .. namePlainList)
					:done()
				:tag('td')
					:cssText('border: solid #aaa; border-width: 0px 1px 1px 0px; background: white;')
					:wikitext(eachElement.life)
				:tag('td')
					:cssText('border: solid #aaa; border-width: 0px 1px 1px 0px; background: white;')
					:wikitext(eachElement.reignstart)
				:tag('td')
					:cssText('border: solid #aaa; border-width: 0px 1px 1px 0px; background: white;')
					:wikitext(eachElement.reignend)
				:tag('td')
					:cssText('border: solid #aaa; border-width: 0px 1px 1px 0px; background: white;')
					:wikitext(eachElement.notes)
				:tag('td')
					:cssText('border: solid #aaa; border-width: 0px 1px 1px 0px; background: white;')
					:wikitext(eachElement.family)
			
			local imageTd = rowTr
				:tag('td')
					:cssText('border: solid #aaa; border-width: 0px 1px 1px 0px; background: white;')
			if eachElement.image then
				imageTd:tag('span')
					:addClass('photo')
					:wikitext('[[File:' .. eachElement.image .. '|80px|alt=' .. (eachElement.alt or '') .. ']]')
			end
		end
	end
	return tostring(mainTag)
end

p.fromArray = function(args)
	local argElements = TableTools.numData(args, true)
	return p.fromArgs(argElements)
end

p.fromFrame = function(frame)
	local args = getArgs(frame)
	return p.fromArray(args)
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.

  1. 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:
  2. 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.
  3. 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.
  4. 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.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.