Module:AVDevice: Difference between revisions
Add conditional Time Base Correction section to AV device infobox — queries AV TBC subobjects, displays type/buffer/notes, only shown when TBC capabilities exist (via update-page on MediaWiki MCP Server) |
Move TBC section between Power and Links; use standard label/value rows instead of card layout to match infobox style (via update-page on MediaWiki MCP Server) |
||
| Line 289: | Line 289: | ||
end | end | ||
end | end | ||
end | end | ||
| Line 439: | Line 406: | ||
end | end | ||
addRow(container, 'Power', powerStr, false) | addRow(container, 'Power', powerStr, false) | ||
end | |||
end | |||
-- Time Base Correction section - query AV TBC subobjects | |||
-- Uses broadtable format and parses results into standard rows | |||
local tbcCountWikitext = | |||
'{{#ask:\n' .. | |||
' [[TBC type::+]]\n' .. | |||
' [[-Has subobject::' .. fullPageName .. ']]\n' .. | |||
' |format=count\n' .. | |||
'}}' | |||
local tbcCountResult = frame:preprocess(tbcCountWikitext) | |||
local hasTBC = tbcCountResult and tonumber(trim(tbcCountResult)) and tonumber(trim(tbcCountResult)) > 0 | |||
if hasTBC then | |||
addSectionRow(container, 'Time Base Correction') | |||
local tbcQueryWikitext = | |||
'{{#ask:\n' .. | |||
' [[TBC type::+]]\n' .. | |||
' [[-Has subobject::' .. fullPageName .. ']]\n' .. | |||
' |?TBC type\n' .. | |||
' |?TBC buffer size\n' .. | |||
' |?TBC notes\n' .. | |||
' |format=broadtable\n' .. | |||
' |headers=hide\n' .. | |||
' |link=none\n' .. | |||
'}}' | |||
local tbcResult = frame:preprocess(tbcQueryWikitext) | |||
if tbcResult then | |||
for rowContent in tbcResult:gmatch('<tr[^>]*>(.-)</tr>') do | |||
local cells = {} | |||
for cellContent in rowContent:gmatch('<td[^>]*>(.-)</td>') do | |||
local cleanContent = cellContent:gsub('<[^>]+>', '') | |||
table.insert(cells, cleanContent) | |||
end | |||
if #cells >= 2 then | |||
local tbcType = trim(cells[2]) | |||
local tbcBuffer = trim(cells[3]) | |||
local tbcNotes = trim(cells[4]) | |||
if tbcType then | |||
addRow(container, 'Type', tbcType, false) | |||
end | |||
if tbcBuffer then | |||
addRow(container, 'Buffer', tbcBuffer, false) | |||
end | |||
if tbcNotes then | |||
addRow(container, 'Notes', tbcNotes, false) | |||
end | |||
end | |||
end | |||
end | end | ||
end | end | ||