Module:Skills/Gathering/Sandbox: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 163: Line 163:


function p.getFishingJunkTable(frame)
function p.getFishingJunkTable(frame)
local resultPart = {}
local html = mw.html.create('table')
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
html:addClass('wikitable sortable stickyHeader')
table.insert(resultPart, '\r\n|- class="headerRow-0"')
 
table.insert(resultPart, '\r\n!colspan="2"|Item!!Value')
-- Add header row
local headerRow = html:tag('tr'):addClass('headerRow-0')
headerRow:tag('th'):attr('colspan', '2'):wikitext('Item')
headerRow:tag('th'):wikitext('Value')


local itemArray = {}
local itemArray = {}
Line 177: Line 180:
table.sort(itemArray, function(a, b) return a.name < b.name end)
table.sort(itemArray, function(a, b) return a.name < b.name end)


-- Add item rows
for i, item in ipairs(itemArray) do
for i, item in ipairs(itemArray) do
table.insert(resultPart, '\r\n|-')
local row = html:tag('tr')
table.insert(resultPart, '\r\n|class="table-img"| ' .. Icons.Icon({item.name, type='item', notext=true}))
row:tag('td'):addClass('table-img')
table.insert(resultPart, '\r\n| ' .. Icons.Icon({item.name, type='item', noicon=true}))
:wikitext(Icons.Icon({item.name, type='item', notext=true}))
table.insert(resultPart, '\r\n|data-sort-value="' .. item.sellsFor .. '"| ' .. Items.getValueText(item))
row:tag('td'):wikitext(Icons.Icon({item.name, type='item', noicon=true}))
row:tag('td')
:attr('data-sort-value', item.sellsFor)
:wikitext(Items.getValueText(item))
end
end
table.insert(resultPart, '\r\n|}')
 
return table.concat(resultPart)
return tostring(html)
end
end


2,875

edits