fbpx
วิกิพีเดีย

มอดูล:Infobox military conflict

คู่มือการใช้งานมอดูล[สร้าง]
require('มอดูล:No globals')  local infoboxStyle = mw.loadData('มอดูล:WPMILHIST Infobox style') local templatestyles = 'มอดูล:Infobox military conflict/styles.css'  local IMC = {} IMC.__index = IMC  function IMC:renderPerCombatant(builder, headerText, prefix, suffix)  prefix = prefix or ''  suffix = suffix or ''  local colspans = {}   -- This may result in colspans[1] getting set twice, but  -- this is no big deal. The second set will be correct.  local lastCombatant = 1   for i = 1,self.combatants do  if self.args[prefix .. i .. suffix] then  colspans[lastCombatant] = i - lastCombatant  lastCombatant = i  end  end   local jointText = self.args[prefix .. (self.combatants + 1) .. suffix]   if headerText and (colspans[1] or jointText) then  builder:tag('tr')  :tag('th')  :attr('colspan', self.combatants)  :cssText(infoboxStyle.header_raw)  :wikitext(headerText)  end   -- The only time colspans[1] wouldn't be set is if no  -- combatant has a field with the given prefix and suffix.  if colspans[1] then  -- Since each found argument set the colspan for the previous  -- one, the final one wasn't set above, so set it now.  colspans[lastCombatant] = self.combatants - lastCombatant + 1  builder = builder:tag('tr')  for i = 1,self.combatants do  -- At this point, colspans[i] will be set for i=1 unconditionally, and for  -- any other value of i where self.args[prefix .. i .. suffix] is set.  if colspans[i] then  builder:tag('td')  -- don't bother emitting colspan="1"  :attr('colspan', colspans[i] ~= 1 and colspans[i] or nil)  :css('width', math.floor(100 / self.combatants * colspans[i] + 0.5) .. '%')  -- no border on the right of the rightmost column  :css('border-right', i ~= lastCombatant and infoboxStyle.internal_border or nil)  -- no padding on the left of the leftmost column  :css('padding-left', i ~= 1 and '0.25em' or nil)  -- don't show the border if we're directly under a header  :css('border-top', not headerText and infoboxStyle.internal_border or nil)  :newline()  :wikitext(self.args[prefix .. i .. suffix])  end  end  end   if jointText then  builder:tag('tr')  :tag('td')  :attr('colspan', self.combatants)  :css('text-align', 'center')  -- don't show the border if we're directly under a header  :css('border-top', (not headerText or colspans[1]) and infoboxStyle.internal_border or nil)  :newline()  :wikitext(jointText)  end end  function IMC:renderHeaderTable(builder)  builder = builder:tag('table')  :css('width', '100%')  :css('margin', 0)  :css('padding', 0)  :css('border', 0)   if self.args.date then  builder:tag('tr')  :tag('th')  :css('padding-right', '1em')  :wikitext('วันที่')  :done()  :tag('td')  :wikitext(self.args.date)  end   builder = builder:tag('tr')  :tag('th')  :css('padding-right', '1em')  :wikitext('สถานที่')  :done()  :tag('td')  :tag('span')  :addClass('location')  :wikitext(self.args.place or '{&#123;{place}&#125;}') -- hack so that people who don't know Lua know that this parameter is required  :done()  if self.args.coordinates then  builder:wikitext(self.args.coordinates)  end  builder = builder:done():done()   -- only for "Putsch"  if self.args.action then  builder:tag('tr')  :tag('th')  :css('padding-right', '1em')  :wikitext(self.args.action and 'ความพยายาม')  :done()  :tag('td')  :wikitext(self.args.action)  end   if self.args.status or self.args.result then  builder:tag('tr')  :tag('th')  :css('padding-right', '1em')  :wikitext(self.args.status and 'สถานะ' or 'ผล')  :done()  :tag('td')  :addClass('status')  :newline()  :wikitext(self.args.status or self.args.result)  end   if self.args.territory then  builder:tag('tr')  :tag('th')  :css('padding-right', '1em')  :wikitext('ดินแดน<br />เปลี่ยนแปลง')  :done()  :tag('td')  :newline()  :wikitext(self.args.territory)  end end  function IMC:render()  local builder = mw.html.create()  if self.args.campaignbox then  -- this should be the same as using {{stack|clear=right|...}}  builder:wikitext(self.frame:expandTemplate{ title = 'stack begin', args = { clear='true'} })  end  builder = builder:tag('table')  :addClass('infobox vevent')  :cssText(infoboxStyle.main_box_raw)  :css('width', self.args.width or nil)   builder:tag('tr')  :tag('th')  :addClass('summary')  :attr('colspan', self.combatants)  :cssText(infoboxStyle.header_raw)  :wikitext(self.args.conflict or mw.title.getCurrentTitle().text)  if self.args.partof then  builder:tag('tr')  :tag('td')  :attr('colspan', self.combatants)  :cssText(infoboxStyle.sub_header_raw)  :wikitext('ส่วนหนึ่งของ ' .. self.args.partof)  end  if self.args.image then  builder:tag('tr')  :tag('td')  :attr('colspan', self.combatants)  :cssText(infoboxStyle.image_box_raw)  :wikitext(string.format('%s%s%s',  require('Module:InfoboxImage').InfoboxImage{args = {  image = self.args.image,  size = self.args.image_size,  sizedefault = 'frameless',  upright = 1,  alt = self.args.alt  }},  self.args.caption and '<br />' or '',  self.args.caption or ''  ))  end  self:renderHeaderTable(builder:tag('tr'):tag('td'):attr('colspan', self.combatants))  self:renderPerCombatant(builder, self.args.combatants_header or 'คู่สงคราม', 'combatant')  -- can be un-hardcoded once gerrit:165108 is merged  for _,v in ipairs{'a','b','c','d'} do  self:renderPerCombatant(builder, nil, 'combatant', v)  end   self:renderPerCombatant(builder, self.args.commanders_header or 'ผู้บังคับบัญชาและผู้นำ', 'commander')  for _,v in ipairs{'a','b','c','d'} do  self:renderPerCombatant(builder, nil, 'commander', v)  end   self:renderPerCombatant(builder, 'หน่วยที่เกี่ยวข้อง', 'units')  self:renderPerCombatant(builder, 'กำลัง', 'strength')  self:renderPerCombatant(builder, 'กำลังสนับสนุนทางการเมือง', 'polstrength')  self:renderPerCombatant(builder, 'กำลังสนับสนุนทางทหาร', 'milstrength')  self:renderPerCombatant(builder, 'ความสูญเสีย', 'casualties')   if self.args.notes then  builder:tag('tr')  :tag('td')  :attr('colspan', self.combatants)  :css('border-top', infoboxStyle.section_border)  :newline()  :wikitext(self.args.notes)  end  if self.args.map_type then  builder:tag('tr')  :tag('td')  :attr('colspan', self.combatants)  :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 ('ที่ตั้งใน'  .. (require('Module:Location map').data(self.frame, {self.args.map_type, 'name'})))  }))  end  builder = builder:done()  if self.args.campaignbox then  builder = builder:done()  builder:wikitext(self.args.campaignbox .. self.frame:expandTemplate{ title = 'stack end'})  end  return builder end  function IMC.new(frame, args)  if not args then  args = require('Module:Arguments').getArgs(frame, {wrappers = 'แม่แบบ:กล่องข้อมูล ความขัดแย้งทางทหาร'})  end  local obj = {  frame = frame,  args = args  }   -- until gerrit:165108 is merged, there's still a cap on combatants, but as soon as it merges, we can update this little bit of code to uncap it  -- also, don't try to make this more efficient, or references could be in the wrong order  obj.combatants = 2  for _,v in ipairs{'', 'a', 'b', 'c', 'd'} do  for i = 1,5 do  if args['combatant' .. i .. v] then  obj.combatants = math.max(obj.combatants, i)  end  end  end   return setmetatable(obj, IMC) end  local p = {}  function p.main(frame)  return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(IMC.new(frame):render()) end  return p 

มอด, infobox, military, conflict, อการใช, งานมอด, สร, าง, ณอาจจะต, องการสร, างค, อการใช, งานของมอด, ลน, เข, ยนสามารถทำการทดลองได, กระบะทราย, สร, าง, ดลอก, และช, ดทดสอบ, สร, าง, ของมอด, ลน, โปรดเพ, มหมวดหม, ไปท, หน, าย, อย, หน, าย, อยของมอด, ลน, require, มอด, g. khumuxkarichnganmxdul srang khunxaccatxngkarsrangkhumuxkarichngankhxngmxdulniphuekhiynsamarththakarthdlxngidthikrabathray srang khdlxk aelachudthdsxb srang khxngmxdulnioprdephimhmwdhmuipthihnayxy doc hnayxykhxngmxdulnirequire mxdul No globals local infoboxStyle mw loadData mxdul WPMILHIST Infobox style local templatestyles mxdul Infobox military conflict styles css local IMC IMC index IMC function IMC renderPerCombatant builder headerText prefix suffix prefix prefix or suffix suffix or local colspans This may result in colspans 1 getting set twice but this is no big deal The second set will be correct local lastCombatant 1 for i 1 self combatants do if self args prefix i suffix then colspans lastCombatant i lastCombatant lastCombatant i end end local jointText self args prefix self combatants 1 suffix if headerText and colspans 1 or jointText then builder tag tr tag th attr colspan self combatants cssText infoboxStyle header raw wikitext headerText end The only time colspans 1 wouldn t be set is if no combatant has a field with the given prefix and suffix if colspans 1 then Since each found argument set the colspan for the previous one the final one wasn t set above so set it now colspans lastCombatant self combatants lastCombatant 1 builder builder tag tr for i 1 self combatants do At this point colspans i will be set for i 1 unconditionally and for any other value of i where self args prefix i suffix is set if colspans i then builder tag td don t bother emitting colspan 1 attr colspan colspans i 1 and colspans i or nil css width math floor 100 self combatants colspans i 0 5 no border on the right of the rightmost column css border right i lastCombatant and infoboxStyle internal border or nil no padding on the left of the leftmost column css padding left i 1 and 0 25em or nil don t show the border if we re directly under a header css border top not headerText and infoboxStyle internal border or nil newline wikitext self args prefix i suffix end end end if jointText then builder tag tr tag td attr colspan self combatants css text align center don t show the border if we re directly under a header css border top not headerText or colspans 1 and infoboxStyle internal border or nil newline wikitext jointText end end function IMC renderHeaderTable builder builder builder tag table css width 100 css margin 0 css padding 0 css border 0 if self args date then builder tag tr tag th css padding right 1em wikitext wnthi done tag td wikitext self args date end builder builder tag tr tag th css padding right 1em wikitext sthanthi done tag td tag span addClass location wikitext self args place or amp 123 place amp 125 hack so that people who don t know Lua know that this parameter is required done if self args coordinates then builder wikitext self args coordinates end builder builder done done only for Putsch if self args action then builder tag tr tag th css padding right 1em wikitext self args action and khwamphyayam done tag td wikitext self args action end if self args status or self args result then builder tag tr tag th css padding right 1em wikitext self args status and sthana or phl done tag td addClass status newline wikitext self args status or self args result end if self args territory then builder tag tr tag th css padding right 1em wikitext dinaedn lt br gt epliynaeplng done tag td newline wikitext self args territory end end function IMC render local builder mw html create if self args campaignbox then this should be the same as using stack clear right builder wikitext self frame expandTemplate title stack begin args clear true end builder builder tag table addClass infobox vevent cssText infoboxStyle main box raw css width self args width or nil builder tag tr tag th addClass summary attr colspan self combatants cssText infoboxStyle header raw wikitext self args conflict or mw title getCurrentTitle text if self args partof then builder tag tr tag td attr colspan self combatants cssText infoboxStyle sub header raw wikitext swnhnungkhxng self args partof end if self args image then builder tag tr tag td attr colspan self combatants cssText infoboxStyle image box raw wikitext string format s s s require Module InfoboxImage InfoboxImage args image self args image size self args image size sizedefault frameless upright 1 alt self args alt self args caption and lt br gt or self args caption or end self renderHeaderTable builder tag tr tag td attr colspan self combatants self renderPerCombatant builder self args combatants header or khusngkhram combatant can be un hardcoded once gerrit 165108 is merged for v in ipairs a b c d do self renderPerCombatant builder nil combatant v end self renderPerCombatant builder self args commanders header or phubngkhbbychaaelaphuna commander for v in ipairs a b c d do self renderPerCombatant builder nil commander v end self renderPerCombatant builder hnwythiekiywkhxng units self renderPerCombatant builder kalng strength self renderPerCombatant builder kalngsnbsnunthangkaremuxng polstrength self renderPerCombatant builder kalngsnbsnunthangthhar milstrength self renderPerCombatant builder khwamsuyesiy casualties if self args notes then builder tag tr tag td attr colspan self combatants css border top infoboxStyle section border newline wikitext self args notes end if self args map type then builder tag tr tag td attr colspan self combatants 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 thitngin require Module Location map data self frame self args map type name end builder builder done if self args campaignbox then builder builder done builder wikitext self args campaignbox self frame expandTemplate title stack end end return builder end function IMC new frame args if not args then args require Module Arguments getArgs frame wrappers aemaebb klxngkhxmul khwamkhdaeyngthangthhar end local obj frame frame args args until gerrit 165108 is merged there s still a cap on combatants but as soon as it merges we can update this little bit of code to uncap it also don t try to make this more efficient or references could be in the wrong order obj combatants 2 for v in ipairs a b c d do for i 1 5 do if args combatant i v then obj combatants math max obj combatants i end end end return setmetatable obj IMC end local p function p main frame return frame extensionTag name templatestyles args src templatestyles tostring IMC new frame render end return p ekhathungcak https th wikipedia org w index php title mxdul Infobox military conflict amp oldid 9678427, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม