Anonymous

Module:Navboxes: Difference between revisions

From Melvor Idle
getLogNavbox: Automate manual navigation template
(getPetNavbox: Exclude content from search results)
(getLogNavbox: Automate manual navigation template)
Line 451: Line 451:


return table.concat(resultPart)
return table.concat(resultPart)
end
function p.getLogNavbox(frame)
-- Generate navbox content
local trees = Shared.shallowClone(SkillData.Woodcutting.trees)
table.sort(trees, function(a, b) return a.level < b.level end)
local contentPart = {}
for i, tree in ipairs(trees) do
local log = Items.getItemByID(tree.productId)
if log ~= nil then
table.insert(contentPart, Icons.Icon({log.name, type='item'}))
end
end
-- Generate navbox table
local resultTable = mw.html.create('table')
-- Table classes & styles
resultTable
:addClass('wikitable')
:addClass('navigation-not-searchable')
:css('text-align', 'center')
:css('margin', 'auto')
:css('clear', 'both')
:css('width', '100%')
-- Header row
:tag('tr')
:tag('th')
:css('background-color', '#275C87')
:css('color', '#FFFFFF')
:wikitext(Icons.Icon({'Woodcutting', 'Logs', type='skill', section='Logs'}))
:done()
:done()
-- Content, list of logs
:tag('tr')
:tag('td')
:wikitext(table.concat(contentPart, ' • '))
:done()
:done()
:done()
return tostring(resultTable)
end
end