Module:Sandbox/BrandonXLF/3: Difference between revisions

Content deleted Content added
No edit summary
Use list instead of table
Line 19:
 
local function getImage(image)
local file = nilnull
 
if string.match(image, '.-%.') then
Line 29:
file = mw.getCurrentFrame():expandTemplate{title = 'flagdeco', args = {image, noredlink = 'y'}}
end
 
return file
end
Line 38:
local entries = {}
local i = 1
local keyHandlesknownKeys = {
[''] = getCountrytrue,
['date'] = getTimespantrue,
flag = getImagetrue
}
 
Line 55:
local key, val = line:match('^([a-z]*):? *(.*)$')
if keyHandlesknownKeys[key] then
data[key] = keyHandles[key](val)
else
return require('Module:Error').error{'Invalid key ' .. key .. ' in argument ' .. i}
Line 62:
end
if not data[''] then
data[''] = getCountry(data[''])
else
return require('Module:Error').error{'A country is required in argument ' .. i}
end
if not data['date'] then
data['date'] = getTimespan(data['date'])
else
return require('Module:Error').error{'A date is required in argument ' .. i}
end
Line 73 ⟶ 77:
hasFlags = true
end
})
data['flag'] = getImage(data['flag'] or '')
table.insert(entries, data)
i = i + 1
end
local outTablecontainer = mw.html.create('tablediv')
:addClass('historical-affiliation')
:css({
:css('float =', args.float or 'left',)
padding = '5px',
float = args.float or 'left',
local titleId = math.random()
['background-color'] = '#f8f9fa',
border = '1px solid #aaa',
width = '20em',
['font-size'] = '90%'
})
 
outTablecontainer:tag('trdiv')
:tagattr('thid', titleId)
:addClass('historical-affiliation-title')
:attr('colspan', hasFlags and 2 or 1)
:wikitext(args.title and args.title or 'Historical affiliations')
:css({
['text-align'] = 'center',
local list = container:tag('ul')
['font-size'] = 'larger',
:attr('aria-labelledby', titleId)
['font-weight'] = 'bold'
:addClass('historical-affiliation-list')
})
:wikitext(args.title and args.title or 'Historical affiliations')
 
for i, entry in ipairs(entries) do
local rowitem = outTablelist:tag('trli');
rowitem:tag('tdspan')
if entry.flag then
row:tagwikitext('td'entry.flag)
:css('vertical-align', 'top')
:wikitext(entry.flag)
elseif hasFlags then
row:tag('td')
end
rowitem:tag('tdspan')
:css({
width = '100%',
['vertical-align'] = 'top'
})
:wikitext(entry[''] .. entry['date'])
end
 
return tostring(outTablecontainer) .. frame:extensionTag{
name = 'templatestyles',
args = { src = 'User:BrandonXLF/J/styles.css' }
}
end