Module:CRTModel: Difference between revisions
Add Control Ports section to infobox rendering (via update-page on MediaWiki MCP Server) |
Add audio properties to input queries and group inputs/outputs by location (Front, Rear, Side) (via update-page on MediaWiki MCP Server) |
||
| Line 56: | Line 56: | ||
fullDiv:wikitext(valueHtmlOrWikitext) | fullDiv:wikitext(valueHtmlOrWikitext) | ||
end | end | ||
end | |||
-- Helper to query inputs for a specific location | |||
local function queryInputsByLocation(frame, fullPageName, location) | |||
local locationFilter = '' | |||
if location then | |||
locationFilter = ' [[Has input location::' .. location .. ']]\n' | |||
end | |||
local queryWikitext = | |||
'{{#ask:\n' .. | |||
' [[Has CRT model::' .. fullPageName .. ']]\n' .. | |||
' [[Has video signal format::+]]\n' .. | |||
locationFilter .. | |||
' |?Has video signal format=signal\n' .. | |||
' |?Has connector type=connector\n' .. | |||
' |?Has input count=count\n' .. | |||
' |?Has audio type=audio\n' .. | |||
' |?Has audio connector=audio_connector\n' .. | |||
' |?Has audio shared with=audio_shared\n' .. | |||
' |format=ul\n' .. | |||
' |template=CRT input inline\n' .. | |||
' |named args=yes\n' .. | |||
' |link=none\n' .. | |||
' |searchlabel=\n' .. | |||
'}}' | |||
local result = frame:preprocess(queryWikitext) | |||
return trim(result) | |||
end | |||
-- Helper to count inputs for a specific location | |||
local function countInputsByLocation(frame, fullPageName, location) | |||
local locationFilter = '' | |||
if location then | |||
locationFilter = ' [[Has input location::' .. location .. ']]\n' | |||
end | |||
local countWikitext = | |||
'{{#ask:\n' .. | |||
' [[Has CRT model::' .. fullPageName .. ']]\n' .. | |||
' [[Has video signal format::+]]\n' .. | |||
locationFilter .. | |||
' |format=count\n' .. | |||
'}}' | |||
local result = frame:preprocess(countWikitext) | |||
local count = tonumber(trim(result)) or 0 | |||
return count | |||
end | |||
-- Helper to query outputs for a specific location | |||
local function queryOutputsByLocation(frame, fullPageName, location) | |||
local locationFilter = '' | |||
if location then | |||
locationFilter = ' [[Has output location::' .. location .. ']]\n' | |||
end | |||
local queryWikitext = | |||
'{{#ask:\n' .. | |||
' [[Has CRT model::' .. fullPageName .. ']]\n' .. | |||
' [[Has output signal format::+]]\n' .. | |||
locationFilter .. | |||
' |?Has output type=type\n' .. | |||
' |?Has output signal format=signal\n' .. | |||
' |?Has output connector=connector\n' .. | |||
' |?Has output count=count\n' .. | |||
' |?Has output label=label\n' .. | |||
' |format=ul\n' .. | |||
' |template=CRT output inline\n' .. | |||
' |named args=yes\n' .. | |||
' |link=none\n' .. | |||
' |searchlabel=\n' .. | |||
'}}' | |||
local result = frame:preprocess(queryWikitext) | |||
return trim(result) | |||
end | |||
-- Helper to count outputs for a specific location | |||
local function countOutputsByLocation(frame, fullPageName, location) | |||
local locationFilter = '' | |||
if location then | |||
locationFilter = ' [[Has output location::' .. location .. ']]\n' | |||
end | |||
local countWikitext = | |||
'{{#ask:\n' .. | |||
' [[Has CRT model::' .. fullPageName .. ']]\n' .. | |||
' [[Has output signal format::+]]\n' .. | |||
locationFilter .. | |||
' |format=count\n' .. | |||
'}}' | |||
local result = frame:preprocess(countWikitext) | |||
local count = tonumber(trim(result)) or 0 | |||
return count | |||
end | end | ||
| Line 466: | Line 563: | ||
end | end | ||
-- Inputs section: | -- Inputs section: grouped by location | ||
local | local locations = {'front', 'rear', 'side'} | ||
local locationLabels = {front = 'Front', rear = 'Rear', side = 'Side'} | |||
-- Count total inputs | |||
local totalInputs = 0 | |||
for _, loc in ipairs(locations) do | |||
local | totalInputs = totalInputs + countInputsByLocation(frame, fullPageName, loc) | ||
local hasInputs = | end | ||
local hasInputs = totalInputs > 0 | |||
if hasInputs then | if hasInputs then | ||
addSectionRow(container, 'Inputs') | |||
local inputsContent = '' | |||
addFullRow(container, | for _, loc in ipairs(locations) do | ||
local count = countInputsByLocation(frame, fullPageName, loc) | |||
if count > 0 then | |||
local locInputs = queryInputsByLocation(frame, fullPageName, loc) | |||
if locInputs and locInputs ~= '' then | |||
inputsContent = inputsContent .. "<div style='margin-bottom:0.3em;'><strong>" .. locationLabels[loc] .. "</strong><br/>" .. locInputs .. "</div>" | |||
end | |||
end | |||
end | |||
if inputsContent ~= '' then | |||
addFullRow(container, inputsContent, 'padding:0.2em 0.4em;', true) | |||
end | |||
end | end | ||
-- Outputs section: | -- Outputs section: grouped by location | ||
local | local totalOutputs = 0 | ||
for _, loc in ipairs(locations) do | |||
totalOutputs = totalOutputs + countOutputsByLocation(frame, fullPageName, loc) | |||
end | |||
local hasOutputs = totalOutputs > 0 | |||
local hasOutputs = | |||
if hasOutputs then | if hasOutputs then | ||
addSectionRow(container, 'Outputs') | |||
local outputsContent = '' | |||
addFullRow(container, | for _, loc in ipairs(locations) do | ||
local count = countOutputsByLocation(frame, fullPageName, loc) | |||
if count > 0 then | |||
local locOutputs = queryOutputsByLocation(frame, fullPageName, loc) | |||
if locOutputs and locOutputs ~= '' then | |||
outputsContent = outputsContent .. "<div style='margin-bottom:0.3em;'><strong>" .. locationLabels[loc] .. "</strong><br/>" .. locOutputs .. "</div>" | |||
end | |||
end | |||
end | |||
if outputsContent ~= '' then | |||
addFullRow(container, outputsContent, 'padding:0.2em 0.4em;', true) | |||
end | |||
end | end | ||