Module:Tw: Difference between revisions
Appearance
DJ Hoi Bok (talk | contribs) i don't know if this will work but eh |
DJ Hoi Bok (talk | contribs) No edit summary |
||
| Line 41: | Line 41: | ||
local hiddenText = table.concat(hidden) | local hiddenText = table.concat(hidden) | ||
-- collapse/expand should probably be fixed, i don't give a shit about it though | |||
local out = {} | local out = {} | ||
table.insert(out, visibleText) | table.insert(out, visibleText) | ||
table.insert(out, '<div class="collapsibletoggle center">[<span class="mw-customtoggle-tw showhidetext"><span class="collapsibletoggletext hiddentext">Collapse | table.insert(out, '<div class="collapsibletoggle center">[<span class="mw-customtoggle-tw showhidetext"><span class="collapsibletoggletext hiddentext">Collapse/Expand</span></span>]</div>') | ||
table.insert(out, '<div id="mw-customcollapsible-tw" class="mw-collapsible mw-collapsed noexcerpt">') | table.insert(out, '<div id="mw-customcollapsible-tw" class="mw-collapsible mw-collapsed noexcerpt">') | ||
table.insert(out, hiddenText) | table.insert(out, hiddenText) | ||
Revision as of 15:34, 12 November 2026
Documentation for this module may be created at Module:Tw/doc
local p = {}
local MAX_DISPLAYED = 5
function p.main(frame)
local pframe = frame:getParent()
local args = pframe.args
local items = {}
local i = 1
while true do
local v = args[i]
if v == nil then break end
if v ~= '' then
table.insert(items, v)
end
i = i + 1
end
if #items == 0 then
return ''
end
local visible, hidden = {}, {}
for idx, v in ipairs(items) do
if idx <= 2 then
table.insert(visible, v)
elseif idx <= MAX_DISPLAYED then
table.insert(hidden, v)
else
break
end
end
local visibleText = table.concat(visible)
local hiddenText = table.concat(hidden)
-- collapse/expand should probably be fixed, i don't give a shit about it though
local out = {}
table.insert(out, visibleText)
table.insert(out, '<div class="collapsibletoggle center">[<span class="mw-customtoggle-tw showhidetext"><span class="collapsibletoggletext hiddentext">Collapse/Expand</span></span>]</div>')
table.insert(out, '<div id="mw-customcollapsible-tw" class="mw-collapsible mw-collapsed noexcerpt">')
table.insert(out, hiddenText)
table.insert(out, '</div>')
return table.concat(out, '\n')
end
return p