Module:Infobox military conflict: Difference between revisions
Jump to navigation
Jump to search
Module:Infobox military conflict (view source)
Revision as of 16:37, 21 October 2022
, 21 October 2022Replace Module:No globals with require( "strict" )
m (1 revision imported) |
(Replace Module:No globals with require( "strict" )) |
||
Line 1: | Line 1: | ||
require(' | require('strict') | ||
local infoboxStyle = mw.loadData('Module:WPMILHIST Infobox style') | local infoboxStyle = mw.loadData('Module:WPMILHIST Infobox style') | ||
local templatestyles = 'Module:Infobox military conflict/styles.css' | |||
local IMC = {} | local IMC = {} | ||
Line 77: | Line 78: | ||
:css('padding', 0) | :css('padding', 0) | ||
:css('border', 0) | :css('border', 0) | ||
:css('display', 'inline-table') | |||
if self.args.date then | if self.args.date then | ||
Line 99: | Line 101: | ||
:done() | :done() | ||
if self.args.coordinates then | if self.args.coordinates then | ||
builder:wikitext( | builder:wikitext(self.args.coordinates) | ||
end | end | ||
builder = builder:done():done() | builder = builder:done():done() | ||
Line 121: | Line 123: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
:addClass('status') | |||
:newline() | :newline() | ||
:wikitext(self.args.status or self.args.result) | :wikitext(self.args.status or self.args.result) | ||
Line 141: | Line 144: | ||
if self.args.campaignbox then | if self.args.campaignbox then | ||
-- this should be the same as using {{stack|clear=right|...}} | -- this should be the same as using {{stack|clear=right|...}} | ||
builder:wikitext(self.frame:expandTemplate{ title = 'stack begin', args = { clear='true'} }) | |||
end | end | ||
builder = builder:tag('table') | builder = builder:tag('table') | ||
Line 192: | Line 188: | ||
end | end | ||
self:renderPerCombatant(builder, 'Commanders and leaders', 'commander') | self:renderPerCombatant(builder, self.args.commanders_header or 'Commanders and leaders', 'commander') | ||
self:renderPerCombatant(builder, 'Units involved', 'units') | for _,v in ipairs{'a','b','c','d'} do | ||
self:renderPerCombatant(builder, 'Strength', 'strength') | self:renderPerCombatant(builder, nil, 'commander', v) | ||
self:renderPerCombatant(builder, 'Political support', 'polstrength') | end | ||
self:renderPerCombatant(builder, 'Military support', 'milstrength') | |||
self:renderPerCombatant(builder, 'Casualties and losses', 'casualties') | self:renderPerCombatant(builder, self.args.units_header or 'Units involved', 'units') | ||
self:renderPerCombatant(builder, self.args.strengths_header or 'Strength', 'strength') | |||
self:renderPerCombatant(builder, self.args.polstrengths_header or 'Political support', 'polstrength') | |||
self:renderPerCombatant(builder, self.args.milstrengths_header or 'Military support', 'milstrength') | |||
self:renderPerCombatant(builder, self.args.casualties_header or 'Casualties and losses', 'casualties') | |||
if self.args.notes then | if self.args.notes then | ||
Line 203: | Line 203: | ||
:tag('td') | :tag('td') | ||
:attr('colspan', self.combatants) | :attr('colspan', self.combatants) | ||
:css('border-top', infoboxStyle.section_border) | :css('border-top', infoboxStyle.section_border) | ||
:newline() | :newline() | ||
Line 213: | Line 212: | ||
:attr('colspan', self.combatants) | :attr('colspan', self.combatants) | ||
:css('border-top', infoboxStyle.internal_border) | :css('border-top', infoboxStyle.internal_border) | ||
:node(require('Module:Location map').main(self.frame, { | |||
self.args.map_type, | |||
relief = self.args.map_relief, | |||
coordinates = self.args.coordinates, | |||
width = self.args.map_size or 220, | |||
float = 'center', | |||
border = 'none', | |||
mark = self.args.map_mark, | |||
marksize = self.args.map_marksize or 8, | |||
label = self.args.map_label, | |||
alt = self.args.map_alt, | |||
caption = self.args.map_caption or ('Location within ' | |||
.. (require('Module:Location map').data(self.frame, {self.args.map_type, 'name'}))) | |||
})) | |||
end | end | ||
builder = builder:done() | builder = builder:done() | ||
if self.args.campaignbox then | if self.args.campaignbox then | ||
builder = builder:done() | builder = builder:done() | ||
builder:wikitext(self.args.campaignbox .. self.frame:expandTemplate{ title = 'stack end'}) | |||
end | end | ||
return builder | return builder | ||
Line 268: | Line 261: | ||
function p.main(frame) | function p.main(frame) | ||
return IMC.new(frame):render() | return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(IMC.new(frame):render()) | ||
end | end | ||
return p | return p |