Jump to content

Editing Module:Item

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 18: Line 18:
local note = lib.nilIfEmpty(args.note) or nil
local note = lib.nilIfEmpty(args.note) or nil
local ref = lib.nilIfEmpty(args.ref) or nil
local ref = lib.nilIfEmpty(args.ref) or nil
local typeInput = lib.nilIfEmpty(args['type']) or 'Item'
local type = lib.nilIfEmpty(args['type']) or 'Item'
local text = lib.nilIfEmpty(args.text) or item
local text = lib.nilIfEmpty(args.text) or item
local link = args.link or lib.ternary(item == 'Unknown', '', item)
local link = args.link or lib.ternary(item == 'Unknown', '', item)
local invert = lib.nilIfEmpty(args.invert)
local newline = tostring(args.newline) == '1'
local newline = tostring(args.newline) == '1'
local noText = tostring(args.no_text or args.notext) == '1'
local no_text = tostring(args.no_text or args.notext) == '1'
local white = tostring(args.white) == '1'
local white = tostring(args.white) == '1'


Line 29: Line 28:
local suffix = ' Icon'
local suffix = ' Icon'
if (typeInput ~= 'Neighbor' and item == 'Unknown') then
if (type ~= 'Neighbor' and item == 'Unknown') then
prefix = ''
prefix = ''
suffix = ' Icon'
suffix = ' Icon'
end
end
local invertIcon = require('Module:Item/Invert')
if (white) then suffix = suffix .. ' White' end
if not invert then
invert = invertIcon[item]
end
 
local invertClass = nil
if invert then
invert = invert:lower()
if invert == 'day' or invert == 'light' then
invertClass = 'day-invert-image'
elseif invert == 'night' or invert == 'dark' then
invertClass = 'night-invert-image'
end
end
if (white) then suffix = suffix .. ' White' end
local filename = 'File:' .. prefix .. item .. suffix .. '.png'
local fileName = 'File:' .. prefix .. item .. suffix .. '.png'
local file = '[[' .. filename .. '|' .. size .. 'x' .. size .. 'px|alt=' .. item .. '|link=' .. link .. ']]'
local class = invertClass and ('|class=' .. invertClass) or ''
local file = '[[' .. fileName .. '|' .. size .. 'x' .. size .. 'px|alt=' .. item .. '|link=' .. link .. class .. ']]'


local icon = nil
local icon = nil
Line 70: Line 54:
end
end


local outerClass = lib.ternary(typeInput:lower() == 'item', 'item', 'item ' .. typeInput:lower())
local outerClass = lib.ternary(type:lower() == 'item', 'item', 'item ' .. type:lower())
local result = mw.html.create():tag('span'):addClass(outerClass)
local result = mw.html.create():tag('span'):addClass(outerClass)


Line 127: Line 111:


local item_text = result:tag('span'):addClass('item-text')
local item_text = result:tag('span'):addClass('item-text')
if (not noText) then
if (not no_text) then
local before = newline and '' or ' '
local before = newline and '' or ' '
local ame = ((count or note) and {text, ''} or parseAmE(text, ''))
local ame = ((count or note) and {text, ''} or parseAmE(text, ''))
Line 146: Line 130:
count = table.concat(note and {count, ''} or parseAmE(count, ''), '')
count = table.concat(note and {count, ''} or parseAmE(count, ''), '')
if (ref and not note) then count:gsub('%s*$', '') end
if (ref and not note) then count:gsub('%s*$', '') end
item_text:wikitext((noText and '' or ' ') .. '×' .. count)
item_text:wikitext((no_text and '' or ' ') .. '×' .. count)
end
end
Line 152: Line 136:
local after = table.concat(parseAmE('', ''), '')
local after = table.concat(parseAmE('', ''), '')
if (ref) then after:gsub('%s*$', '') end
if (ref) then after:gsub('%s*$', '') end
item_text:tag('small'):wikitext(((noText and not count) and '' or ' '),'(', note, ')', after)
item_text:tag('small'):wikitext(((no_text and not count) and '' or ' '),'(', note, ')', after)
end
end
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see Petit Planet Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template
Below are commonly used wikitext from MediaWiki:Edittools. Click on any to insert them in the edit box.
File Pages==Summary====Licensing=={{Fairuse}}{{File|}}
Dynamic Page List¦²«»²{¦}²«»«/»«!----»
Array in DPL¹^2{}^2^2{¹}^2
Parser Functions{{#if:||}}
{{#ifeq:|||}}
{{#expr:}}
{{#switch:||#default=}}
{{#replace:||}}
{{#titleparts:}}
{{#tag:|}}
Markup{{}}|[][[]][[Category:]]#REDIRECT [[]] [[Category:Redirect Pages]]<code></code><includeonly></includeonly><noinclude></noinclude><nowiki></nowiki><!----><br>§
Notices{{Stub|}}{{Stub Dialogue}}{{Upcoming}}{{Under Construction}}{{Placeholder|}}
Magic Words{{!}}{{formatnum:}}{{lc:}}{{uc:}}{{PAGENAME}}{{FULLPAGENAME}}{{ROOTPAGENAME}}{{BASEPAGENAME}}{{SUBPAGENAME}}{{DISPLAYTITLE:|noreplace}}__TOC____NOTOC____EXPECTUNUSEDCATEGORY____HIDDENCAT__
HTML Entities&mdash;&nbsp;&comma;&shy;