Content added Content deleted
mNo edit summary |
mNo edit summary |
||
Line 48: | Line 48: | ||
if count and tonumber(count) > 1 then |
if count and tonumber(count) > 1 then |
||
root:tag('div') |
root:tag('div') |
||
:addClass('theme-primary') |
|||
:css({ |
:css({ |
||
['bottom'] = 0, |
['bottom'] = 0, |
||
Line 53: | Line 54: | ||
['position'] = 'absolute', |
['position'] = 'absolute', |
||
['padding'] = '0 5px', |
['padding'] = '0 5px', |
||
['background'] = '#00cdba', |
|||
['border-radius'] = '5px 0 5px 0', |
['border-radius'] = '5px 0 5px 0', |
||
['user-select'] = 'none' |
['user-select'] = 'none' |
Revision as of 02:29, 2 November 2021
local getArgs = require('Module:Arguments').getArgs
local cargo = mw.ext.cargo
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
local item = string.lower(args['item'] or '')
local image = nil
local link = nil
local count = args['count']
local icon_size = '80px'
if item then
local tables = 'Items'
local fields = '_pageName, image'
local args = {
where = string.format("item_name = '%s'", item),
}
local result = cargo.query( tables, fields, args )
if #result > 0 then
image = result[1]['image']
link = result[1]['_pageName']
end
end
image = args['image'] or image or ''
link = args['link'] or link or ''
local root = mw.html.create('div')
root:css({
['position'] = 'relative',
['height'] = icon_size,
['width'] = icon_size
})
:wikitext(string.format(
'[[File:%s|80px|link=%s|%s]]',
image,
link,
link
))
if count and tonumber(count) > 1 then
root:tag('div')
:addClass('theme-primary')
:css({
['bottom'] = 0,
['right'] = 0,
['position'] = 'absolute',
['padding'] = '0 5px',
['border-radius'] = '5px 0 5px 0',
['user-select'] = 'none'
})
:wikitext('x' .. count)
end
return tostring(root)
end
return p