RuneScape Wiki
Advertisement

Documentation for this module may be created at Module:Recolours/doc

-- <nowiki>
-- Implements {{Recolours}}
--

local p = {}

function p.main(frame)
    local args = frame:getParent().args
    local colourPrefix = 'colour'
    local namePrefix = 'colour'
    local tbl = mw.html.create('table')
        :addClass('recolour-table')
    local row
    local curArg
    
    for i=1, 16 do
        curColour = args[colourPrefix .. tostring(i)] or '#fff'
        curName = args[namePrefix .. tostring(i)] or 'White'

        if i % 4 == 1 then
            if row then
                tbl = row:done()
                        :tag('tr')
                            :addClass('rec-empty-row')
                            :tag('td')
                                :addClass('rec-empty-cell')
                                :done()
                            :done()
            end
            
            row = tbl:tag('tr')
        end
        
        row:tag('td')
            :css('background', curColour)
            :attr('title', curName)
            :done()
        
        if i % 4 ~= 0 then
            row:tag('td')
                :addClass('rec-empty-cell')
                :done()
        end
    
    end
    
    return tostring(tbl:allDone())
end

return p
Advertisement