Module:Item Navbox: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Tag: Undo |
No edit summary |
||
| Line 89: | Line 89: | ||
end | end | ||
-- Generates the | -- Generates the Navbox using standard MediaWiki template structure | ||
function p.generate_full_navbox(frame) | function p.generate_full_navbox(frame) | ||
local debug_mode = type(frame) == "table" and frame.args and frame.args["debug_mode"] or nil | local debug_mode = type(frame) == "table" and frame.args and frame.args["debug_mode"] or nil | ||
local | local wikitext = {} | ||
table.insert( | -- Insert standard stylesheet call | ||
table.insert(wikitext, '<templatestyles src="User:Kai/mp/itemnavbox/styles.css"/>\n') | |||
-- Start building the {{Navbox}} call | |||
table.insert(wikitext, '{{Navbox') | |||
-- IMPORTANT: Change "Template:ItemNavbox" below to the actual name of your template page | |||
-- so that the v/d/e (view/discuss/edit) links in the top left work properly. | |||
table.insert(wikitext, '| name = Template:ItemNavbox') | |||
-- Title including your custom search container element floated to the right | |||
table.insert(wikitext, '| title = [[Items]] <div class="item-nav-search-container" style="display:inline-block; float:right;"></div>') | |||
local categories = { | local categories = { | ||
{ header = "Weapon", | { header = "Weapon", slot = "Weapon" }, | ||
{ header = "Vitality", slot = "Armor | { header = "Vitality", slot = "Armor" }, | ||
{ header = "Spirit", | { header = "Spirit", slot = "Tech" } | ||
} | } | ||
local tiers = { | local tiers = { | ||
{ label = "{{Souls|800}}", min = 0, max = 801 }, | { label = "{{Souls|800}}", min = 0, max = 801 }, | ||
| Line 110: | Line 119: | ||
{ label = "{{Souls|3200}}", min = 1601, max = 3201 }, | { label = "{{Souls|3200}}", min = 1601, max = 3201 }, | ||
{ label = "{{Souls|6400}}", min = 3201, max = 6401 }, | { label = "{{Souls|6400}}", min = 3201, max = 6401 }, | ||
{ label = "[[Street Brawl|{{Legendary|{{#invoke:Lang|get_string|Citadel_ItemDraft_Legendary}}}}]] | { label = '<span class="itemnav-legendary">[[Street Brawl|{{Legendary|{{#invoke:Lang|get_string|Citadel_ItemDraft_Legendary}}}}]]</span>', min = 6401, max = 99999 } | ||
} | } | ||
for | -- Loop through categories and build Navbox subgroups | ||
table.insert( | for i, cat in ipairs(categories) do | ||
table.insert( | table.insert(wikitext, '| group' .. i .. ' = ' .. cat.header) | ||
table.insert(wikitext, '| list' .. i .. ' = {{Navbox|child') | |||
for | |||
for j, tier in ipairs(tiers) do | |||
local | table.insert(wikitext, ' | group' .. j .. ' = ' .. tier.label) | ||
local items_string = get_item_icons(cat.slot, tier.min, tier.max, nil) | |||
table.insert( | -- Wrap the items in our flex container for layout | ||
table.insert(wikitext, ' | list' .. j .. ' = <div class="itemnav-cost-type-container">' .. items_string .. '</div>') | |||
end | end | ||
table.insert( | table.insert(wikitext, '}}') -- Close subgroup navbox | ||
end | end | ||
table.insert( | table.insert(wikitext, '}}') -- Close parent navbox | ||
-- Only ONE preprocess call for the entire structure | -- Only ONE preprocess call for the entire structure | ||
return process_debug_mode(table.concat( | return process_debug_mode(table.concat(wikitext, '\n'), debug_mode) | ||
end | end | ||
return p | return p | ||