Модуль: Infobox: различия между версиями 🔗


Материал из VEDA Wiki
Перейти к: навигация, поиск
Нет описания правки
Нет описания правки
Строка 24: Строка 24:


function p.event_members( frame )
function p.event_members( frame )
  local count = 0
   local t = {}
   local t = {}
   local name = frame.args[1]
   local name = frame.args[1]
Строка 57: Строка 56:
   <td>]]..l[3]..'</td></tr>')
   <td>]]..l[3]..'</td></tr>')


    count = count + l[3]
   end -- 'for i' cycle
   end -- 'for i' cycle



Версия от 20:56, 1 октября 2024

Для документации этого модуля может быть создана страница Модуль:Infobox/doc

local p = {} -- p stands for package

function p.synonyms( frame )
  local t = {}
  local name = frame.args[1]
  local listitem = frame.args['listitem'] == 'true' and '<br>' or '; ' -- additional param for items lists
  if #name == 0 then
    return ''
  end

  for i in string.gmatch(name, "[^;]+") do
    table.insert(t, "[[" .. i .. "]]")
  end

  --table.insert(t, ")")
  local out = table.concat(t, listitem)
  if listitem == '; ' then
    out = "(" .. out
    out = out .. ")"
  end
  return out
end


function p.event_members( frame )
  local t = {}
  local name = frame.args[1]
  for i in string.gmatch(name, "[^;]+") do

    table.insert(t, [[<tr>
  <td colspan="2" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold; text-align: center;">Участник</td>
</tr>]])

    local l = {}
    for k in string.gmatch(i, "[^!]+") do
      table.insert(l, k)
    end

    table.insert(t, 
[[<tr>
  <td colspan="2"><hr></td>
</tr><tr>
  <td align="left" width="10%" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold;">Участник:</td>
  <td>]]..l[1]..'</td></tr>'
..
[[<tr>
  <td colspan="2"><hr></td>
</tr><tr>
  <td align="left" width="10%" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold;">Категория:</td>
  <td>]]..l[2]..'</td></tr>'
..
[[<tr>
  <td colspan="2"><hr></td>
</tr><tr>
  <td align="left" width="10%" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold;">Количество:</td>
  <td>]]..l[3]..'</td></tr>')

  end -- 'for i' cycle

      table.insert(t, [[<tr>
  <td align="left" width="10%" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold;">Общее число:</td>
  <td>не менее 
]]..#t..'</td></tr>')


  return table.concat(t, "~")
end

return p