Module:ItemTooltipSmall

local cargo = mw.ext.cargo local p = {}

local escp = function (str) return (mw.ustring.gsub(str == nil and '' or tostring(str), "'", "\\'")) end

function p.itemTooltip(frame) local itemName = frame.args[1] local quantity = frame.args[2] or ''

local item = cargo.query(		'Items',		'Items._pageName=page, Items.Name=name, Items.Icon=icon, Items.Subtype=type, Items.Rarity=rarity',		{			where = ("Items.Name='%s'"):format(escp(itemName)),		}	)

if #item == 0 then return  .. itemName ..  end

local item = item[1]

local showQuantity = string.len(quantity) >= 1 -- Creates HTML Table local tbl = mw.html.create('div') :css('border','none') :css('text-align','center') local rarity = (item.rarity == ) and  or ('★' .. item.rarity) local subtype = frame:expandTemplate{title='ItemSubtypeIcon', args = {item.type, 'x8px'}} local icon = (item.icon == ) and  or (''):format(item.icon, item.page) local mainIcon = mw.html.create('div') :css('display','inline-block') :css('position','relative') :wikitext('')

mainIcon:tag('span') -- Subtype Icon :css('position','absolute') :css('left','10.5%') :css('top','-7%') :wikitext(subtype)

mainIcon:tag('span') -- Item Icon :css('position','absolute') :css('left','6.5%') :css('top','9.5%') :wikitext(icon)

mainIcon:tag('span') -- Rarity Icon :css('position','absolute') :css('left','5%') :css('top','62%') :css('color','#ffca00') :css('font-size','80%') :css('text-shadow','1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 2px 0 #000') :css('text-align','right') :css('vertical-align','top') :wikitext(rarity)

if showQuantity then mainIcon:tag('span') :css('position','absolute') :css('right','1%') :css('top','75%') :css('color','#e0f2f2') :css('font-size','80%') :css('text-shadow','1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 2px 0 #000') :css('text-align','right') :css('vertical-align','top') :wikitext('x' .. quantity) end

--tbl:tag('tr') --:tag('td') -- Full Item Icon tbl:tag('span') :css('border','none') :css('background','none') :css('text-align','center') :css('display', 'inline-block') :wikitext(tostring(mainIcon))

local name =  .. item.name .. 

if showQuantity then name = name .. ' '

end

return tostring(tbl) end

return p