Модуль:Tools: различия между версиями
Нет описания правки |
Нет описания правки |
||
Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local libHero = require('Module:HeroData') | |||
function p.getTodoTable(frame) | function p.getTodoTable(frame) | ||
Строка 79: | Строка 81: | ||
for k, v in ipairs(data['heroes']) do | for k, v in ipairs(data['heroes']) do | ||
if k < 6 then | if k < 6 then | ||
str = str .. mw.ustring.format('{{sih|hero=%s|size=60px}}', | str = str .. mw.ustring.format('{{sih|hero=%s|size=60px}}', k) | ||
else | else | ||
str = str .. mw.ustring.format('<div style="margin-bottom: -4px; margin-right: 10px;">[[Новые герои|Смотреть всех героев]]</div>') | str = str .. mw.ustring.format('<div style="margin-bottom: -4px; margin-right: 10px;">[[Новые герои|Смотреть всех героев]]</div>') | ||
Строка 90: | Строка 92: | ||
return frame:preprocess(tostring(divNode)) | return frame:preprocess(tostring(divNode)) | ||
end | |||
function p.getFullNoveltyHeroes(frame) | |||
local divNode = mw.html.create('div') | |||
local str = "" | |||
tableNode | |||
:addClass('custom-table') | |||
:cssText('width: 100%; display: table; margin: 0 auto; text-align: center;') | |||
:newline() | |||
tableNode | |||
:tag('tr') | |||
:css('white-space', 'nowrap') | |||
:tag('th') | |||
:wikitext('Дата') | |||
:done() | |||
:tag('th') | |||
:wikitext('Имя') | |||
:done() | |||
:tag('th') | |||
:wikitext('Иконка') | |||
:done() | |||
:tag('th') | |||
:wikitext('Раса') | |||
:done() | |||
:tag('th') | |||
:wikitext('Класс') | |||
:done() | |||
:tag('th') | |||
:wikitext('Альянс') | |||
:done() | |||
:done() | |||
local data = mw.loadData('Module:Tools/novelty') | |||
local data_heroes = mw.loadData('Module:HeroData/data') | |||
for k, v in ipairs(data['heroes']) do | |||
local rowNode = mw.html.create('tr') | |||
rowNode | |||
:tag('td') | |||
:wikitext(mw.ustring.format('%s', v[1])) | |||
:done() | |||
:tag('td') | |||
:wikitext(mw.ustring.format('%s', k)) | |||
:done() | |||
:tag('td') | |||
:wikitext(mw.ustring.format('%s', data_heroes[k]['race'])) | |||
:done() | |||
:tag('td') | |||
:wikitext(mw.ustring.format('%s', data_heroes[k]['class'])) | |||
:done() | |||
:tag('td') | |||
:wikitext(mw.ustring.format('%s', libHero.AllianceIcon(data_heroes[k]['alliance'], "45px"))) | |||
:done() | |||
:done() | |||
tableNode:node(rowNode):newline() | |||
end | |||
return frame:preprocess(tostring(tableNode)) | |||
end | end | ||
Версия от 05:23, 17 апреля 2022
local p = {} local libHero = require('Module:HeroData') function p.getTodoTable(frame) local tableNode = mw.html.create('table') tableNode :addClass('pc-block service-table') :cssText('width: 100%; display: table; margin: 0 auto; text-align: center;') :newline() tableNode :tag('tr') :css('white-space', 'nowrap') :tag('th') :wikitext('Задача') :done() :tag('th') :wikitext('Описание') :done() :tag('th') :wikitext('Ответственный') :done() :tag('th') :wikitext('Статус') :done() :done() local list = mw.loadData('Module:Tools/todo') local statuses = mw.loadData('Module:Tools/todo/statuses') local member = "" local status = "" for k, v in ipairs(list) do if v[3] == "" or v[3] == nil then member = "Все желающие" else member = mw.ustring.format('[[Участник:%s|%s]]', v[3], v[3]) end if v[4] == 1 then status = mw.ustring.format('{{Цвет|обы|%s}}', statuses[v[4]]) elseif v[4] == 2 then status = mw.ustring.format('{{Цвет|жел|%s}}', statuses[v[4]]) elseif v[4] == 3 then status = mw.ustring.format('{{Цвет|зел|%s}}', statuses[v[4]]) end local rowNode = mw.html.create('tr') rowNode :tag('td') :css('color', '#25a6f2') :wikitext(mw.ustring.format('%s', v[1])) :done() :tag('td') :css('text-align', 'left') :wikitext(mw.ustring.format('%s', v[2])) :done() :tag('td') :wikitext(mw.ustring.format('%s', member)) :done() :tag('td') :wikitext(mw.ustring.format('%s', status)) :done() :done() tableNode:node(rowNode):newline() end return frame:preprocess(tostring(tableNode)) end function p.getNoveltyHeroes(frame) local divNode = mw.html.create('div') local str = "" divNode :cssText('display: flex; flex-flow: row wrap; justify-content: space-evenly;') :newline() local data = mw.loadData('Module:Tools/novelty') for k, v in ipairs(data['heroes']) do if k < 6 then str = str .. mw.ustring.format('{{sih|hero=%s|size=60px}}', k) else str = str .. mw.ustring.format('<div style="margin-bottom: -4px; margin-right: 10px;">[[Новые герои|Смотреть всех героев]]</div>') end end divNode :wikitext(mw.ustring.format('%s', str)) :done() return frame:preprocess(tostring(divNode)) end function p.getFullNoveltyHeroes(frame) local divNode = mw.html.create('div') local str = "" tableNode :addClass('custom-table') :cssText('width: 100%; display: table; margin: 0 auto; text-align: center;') :newline() tableNode :tag('tr') :css('white-space', 'nowrap') :tag('th') :wikitext('Дата') :done() :tag('th') :wikitext('Имя') :done() :tag('th') :wikitext('Иконка') :done() :tag('th') :wikitext('Раса') :done() :tag('th') :wikitext('Класс') :done() :tag('th') :wikitext('Альянс') :done() :done() local data = mw.loadData('Module:Tools/novelty') local data_heroes = mw.loadData('Module:HeroData/data') for k, v in ipairs(data['heroes']) do local rowNode = mw.html.create('tr') rowNode :tag('td') :wikitext(mw.ustring.format('%s', v[1])) :done() :tag('td') :wikitext(mw.ustring.format('%s', k)) :done() :tag('td') :wikitext(mw.ustring.format('%s', data_heroes[k]['race'])) :done() :tag('td') :wikitext(mw.ustring.format('%s', data_heroes[k]['class'])) :done() :tag('td') :wikitext(mw.ustring.format('%s', libHero.AllianceIcon(data_heroes[k]['alliance'], "45px"))) :done() :done() tableNode:node(rowNode):newline() end return frame:preprocess(tostring(tableNode)) end function p.getNoveltyBosses(frame) local divNode = mw.html.create('div') local str = "" divNode :cssText('display: flex; flex-flow: row wrap; justify-content: space-evenly;') :newline() local data = mw.loadData('Module:Tools/novelty') for k, v in ipairs(data['bosses']) do if k < 6 then str = str .. mw.ustring.format('{{sib|boss=%s|size=60px|border=3px ridge #3d8ac2}}', data['bosses'][k]) end end divNode :wikitext(mw.ustring.format('%s', str)) :done() return frame:preprocess(tostring(divNode)) end function p.getNoveltyItems(frame) local divNode = mw.html.create('div') local str = "" divNode :cssText('display: flex; flex-flow: row wrap; justify-content: space-evenly;') :newline() local data = mw.loadData('Module:Tools/novelty') for k, v in ipairs(data['items']) do if k < 6 then str = str .. mw.ustring.format('{{sii|item=%s|size=60px}}', data['items'][k]) end end divNode :wikitext(mw.ustring.format('%s', str)) :done() return frame:preprocess(tostring(divNode)) end function p.getNoveltyRecipes(frame) local divNode = mw.html.create('div') local str = "" divNode :cssText('display: flex; flex-flow: row wrap; justify-content: space-evenly;') :newline() local data = mw.loadData('Module:Tools/novelty') for k, v in ipairs(data['recipes']) do if k < 6 then str = str .. mw.ustring.format('{{sii|item=%s|size=60px}}', data['recipes'][k]) end end divNode :wikitext(mw.ustring.format('%s', str)) :done() return frame:preprocess(tostring(divNode)) end return p