Module:BPMTable: Difference between revisions
Jump to navigation
Jump to search
(Fixing it?) |
(Modified the table to return html instead) |
||
| Line 16: | Line 16: | ||
end | end | ||
local result = {} | local result = {} | ||
table.insert(result, ' | table.insert(result, '<table class="mw-collapsible mw-collapsed mw-made-collapsible"'.. | ||
'style="color:white;width:25%;clear:both;background:black;border-radius: 10px;">'.. | |||
'<tbody>'.. | |||
'<tr>'.. | |||
'<th align="center" style="color:white;background:#4A31FF;border-radius:7px;" width="50%">'.. | |||
'div style="margin-left:75px;">'.. | |||
'<font color="White">BPMs</font>'.. | |||
'</div>'.. | |||
'</th>'.. | |||
'<th align="center" style="color:white;background:#4A31FF;border-radius:7px;"><span'.. | |||
'class="mw-collapsible-toggle mw-collapsible-toggle-default mw-collapsible-toggle-collapsed"'.. | |||
'role="button" tabindex="0" aria-expanded="false"><a'.. | |||
'class="mw-collapsible-text">Expand</a></span>'..title.. | |||
'</th>'.. | |||
'</tr>') | |||
local i = 1 | local i = 1 | ||
while items[i] do | while items[i] do | ||
table.insert(result, " | table.insert(result, '<tr style="display: none;"><td>'..items[i]..'</td>') | ||
if labels[i] ~= nil then | if labels[i] ~= nil then | ||
table.insert(result, | table.insert(result, '<td>'..labels[i]..'</td>') | ||
end | end | ||
table.insert(result, '</tr>') | |||
i = i + 1 | i = i + 1 | ||
end | end | ||
table.insert(result, | table.insert(result, '</tr></tbody></table>') | ||
return table.concat(result, " | return table.concat(result, "") | ||
end | end | ||
return p | return p | ||
Revision as of 12:00, 9 July 2025
Module accepts 3 arguments:
- title: Name of the second column. Most likely to be "Beat", or "Game".
- Unnamed argument 1: List of tempos, separated by a comma. Ex: "120,125"
- Unnamed argument 2: List of labels. Displayed to the right of the corresponding tempo. Ex: "Tengoku,Megamix" or "0,16"
For instance:
{{#invoke:BPMTable|main|title=Beat|120,125|0,16}}
would resolve into:
<tbody></tbody>| div style="margin-left:75px;">BPMs | <spanclass="mw-collapsible-toggle mw-collapsible-toggle-default mw-collapsible-toggle-collapsed"role="button" tabindex="0" aria-expanded="false"><aclass="mw-collapsible-text">Expand</a>Beat |
|---|
{{#invoke:BPMTable|main|title=Game|180,175|Tengoku,Megamix}}
would resolve into:
<tbody></tbody>| div style="margin-left:75px;">BPMs | <spanclass="mw-collapsible-toggle mw-collapsible-toggle-default mw-collapsible-toggle-collapsed"role="button" tabindex="0" aria-expanded="false"><aclass="mw-collapsible-text">Expand</a>Game |
|---|
local p = {}
function p.main(frame)
local title = frame.args["title"]
local items = frame.args[1]
if items ~= nil then
items = mw.text.split(items, ",")
else
items = {}
end
local labels = frame.args[2]
if labels ~= nil then
labels = mw.text.split(labels, ",")
else
labels = {}
end
local result = {}
table.insert(result, '<table class="mw-collapsible mw-collapsed mw-made-collapsible"'..
'style="color:white;width:25%;clear:both;background:black;border-radius: 10px;">'..
'<tbody>'..
'<tr>'..
'<th align="center" style="color:white;background:#4A31FF;border-radius:7px;" width="50%">'..
'div style="margin-left:75px;">'..
'<font color="White">BPMs</font>'..
'</div>'..
'</th>'..
'<th align="center" style="color:white;background:#4A31FF;border-radius:7px;"><span'..
'class="mw-collapsible-toggle mw-collapsible-toggle-default mw-collapsible-toggle-collapsed"'..
'role="button" tabindex="0" aria-expanded="false"><a'..
'class="mw-collapsible-text">Expand</a></span>'..title..
'</th>'..
'</tr>')
local i = 1
while items[i] do
table.insert(result, '<tr style="display: none;"><td>'..items[i]..'</td>')
if labels[i] ~= nil then
table.insert(result, '<td>'..labels[i]..'</td>')
end
table.insert(result, '</tr>')
i = i + 1
end
table.insert(result, '</tr></tbody></table>')
return table.concat(result, "")
end
return p