FANDOM


-- <nowiki>
-- {{GEItem}} internal method
--
--
-- @param item {string} Item to get data for
-- @return {string}
--
local p = {}
 
local timeago = require( 'Module:TimeAgo' )._ago
local changeperday = require( 'Module:ChangePerDay' )._change
 
function p.table( data )
    -- set variables here to make the row building easier to follow
    local unknown = '<i>Unknown</i>'
    local item = data.item
    local div = unknown
    local limit = data.limit and addcommas( data.limit ) or unknown
    local members = unknown
 
    if data.last then
        local link = 'http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj=' .. data.itemId
        local change = math.abs( changeperday( {data.price, data.last, data.date, data.lastDate} ) )
 
        if data.price > data.last then
            arrow = '[[File:Up.png|20px|link=' .. link .. ']]'
        elseif data.price < data.last then
            arrow = '[[File:Down.png|20px|link=' .. link .. ']]'
        else
            arrow = '[[File:Unchg.png|40px|link=' .. link .. ']]'
        end
 
        if change >= 0.04 then
            arrow = arrow  .. arrow .. arrow
        elseif change >= 0.02 then
            arrow = arrow .. arrow
        end
 
        div = mw.html.create( 'div' )
            :css( 'white-space', 'nowrap' )
            :wikitext( arrow )
 
        div = tostring( div )
    end
 
    if data.members == true then
        members = '[[File:P2P icon.png|30px|link=Members]]'
    elseif data.members == false then
        members = '[[File:F2P icon.png|30px|link=Free-to-play]]'
    end
 
    -- build table row
    local tr = mw.html.create( 'tr' )
        :tag( 'td' )
            :wikitext( '[[File:' .. item .. '.png|' .. item .. ']]' )
            :done()
        :tag( 'td' )
            :css( {
                ['width'] = '15%',
                ['text-align'] = 'left'
            } )
            :wikitext( '[[' .. item .. ']]' )
            :done()
        :tag( 'td' )
            :wikitext( addcommas( data.price ) )
            :done()
        :tag( 'td' )
            :wikitext( div )
            :done()
 
    if data.alchable == nil or yesno( data.alchable ) then
        local low, high = unknown, unknown
 
        if data.value then
            low = addcommas( math.floor( data.value * 0.4 ) )
            high = addcommas( math.floor( data.value * 0.6 ) )
        end
 
        tr
            :tag( 'td' )
                :wikitext( low )
                :done()
            :tag( 'td' )
                :wikitext( high )
                :done()
    else
        tr
            :tag( 'td' )
                :attr( 'colspan', '2' )
                :wikitext( '<i>Cannot be alchemised</i>' )
                :done()
    end
 
    tr
        :tag( 'td' )
            :wikitext( limit )
            :done()
        :tag( 'td' )
            :wikitext( members )
            :done()
        :tag( 'td' )
            :css( 'white-space', 'nowrap' )
            :wikitext( '[[Exchange:' .. item .. '|view]]' )
            :done()
        :tag( 'td' )
            :css( 'font-size', '85%' )
            :wikitext( timeago{data.date} )
            :done()
 
    return tostring( tr )
 
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.