Home
Random
Log in
Settings
About the Deadlock Wiki
Search
Editing
Module:NavboxGenerator
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.
Anti-spam check. Do
not
fill this in!
local p = {} local function generateNavbox(data, level) local result = {} local boxSizePercent = 100 - (level-1)*15 -- 15% less per level, 100%, 85%, 70%, 55%, etc. local fontSize = 170 - (level * 15) -- Adjust font size reduction per level for key, value in pairs(data) do if key == "Style" then -- Skip "Style" as it's just an attribute holder elseif key == "Display" then -- Leaf node, render Display content table.insert(result, string.format( '<div style="text-align: center; font-size:%d%%;">%s</div>', fontSize, value )) elseif type(value) == "table" then -- Nested node, render title with optional Style and recurse table.insert(result, string.format( '<div style="width: %s%%; margin-left: auto; margin-right: auto; text-align: center; font-size:%d%%; border:1px solid #aaa; %s">%s</div>', boxSizePercent, fontSize, value.Style or "", key )) table.insert(result, generateNavbox(value, level + 1)) -- Recursively process next level end end return mw.getCurrentFrame():preprocess(table.concat(result, "\n")) end function p.createNavbox(frame) local dataPageName = frame.args[1] if dataPageName == nil then return "dataPageName parameter missing" end local jsonData = mw.loadJsonData(dataPageName) return generateNavbox(jsonData, 1) end return p
Summary:
Please note that all contributions to Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Deadlock: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
Templates used on this page:
Data:Dictionary
(
edit
)
Data:GenericData.json
(
edit
)
Data:ItemData.json
(
edit
)
Data:ItemNavbox.json
(
edit
)
Data:ItemNavboxSample.json
(
edit
)
Data:LangCodes.json
(
edit
)
Data:Lang en.json
(
edit
)
Template:Icon/Black
(
edit
)
Template:ItemBox
(
edit
)
Template:Souls
(
edit
)
Module:Dictionary
(
edit
)
Module:GenericData
(
edit
)
Module:ItemData
(
edit
)
Module:ItemData/nav
(
edit
)
Module:Lang
(
edit
)
Module:NavboxGenerator
(
edit
)
Module:NavboxGenerator/doc
(
edit
)
Module:Utilities
(
edit
)