Module:SCOTUS-termlist-entry
Appearance
Implements {{SCOTUS-termlist-entry}}
local p = {}
local cfg = mw.loadData('Module:SCOTUS-termlist-entry/config')
local palette = cfg.palette
function p.main(frame)
local pframe = frame:getParent()
local args = pframe.args
if args.case then args.case = "''[[" .. args.case .. "]]''" else args.case = nil end
if args["case1"] then args["case1"] = "''" .. args["case1"] .. "''" else args["case1"] = nil end
if args["case-article"] then args["case-article"] = "''[[" .. args["case-article"] .. "|" .. args["case-display"] .. "]]''"
else args["case-article"] = nil end
if args.page ~= nil and mw.text.trim(args.page) ~= "" then args.page = args.page else args.page = "___" end
local entry = mw.html.create("tr")
entry
:tag("td")
:addClass('scotus-termlist-no')
:wikitext(args["#"])
:done()
:tag("td")
:addClass('scotus-termlist-case')
:wikitext((args.case or "") .. (args["case1"] or "") .. (args["case-article"] or "") .. "," .. (args.note or "") ..
' <span class="nowrap">' .. args.volume .. " U.S. " .. (args.page) .. '</span>')
:done()
:tag("td")
:addClass('scotus-termlist-date')
:wikitext(args["argue-date"] or "")
:done()
:tag("td")
:addClass('scotus-termlist-date')
:wikitext(args["decision-date"])
:done()
local x = 1
while x < 9 or args["justice" .. x .. "-opinion1"] ~= nil do
local opinioncell = mw.html.create("td")
opinioncell
:addClass('scotus-termlist-opinion')
:attr("data-sort-value", args["justice" .. x .. "-sortcode"])
if args["justice" .. x .. "-opinion1"] ~= nil then
local subopinions = mw.html.create("div")
subopinions
:addClass('scotus-termlist-sub')
local i = 1
while i < 6 and args["justice" .. x .. "-opinion" .. i] ~= nil and mw.text.trim(args["justice" .. x .. "-opinion" .. i]) ~= "" do
local justice_x_opinion_i = args["justice" .. x .. "-opinion" .. i]
local opiniontext
if string.find(mw.text.trim(justice_x_opinion_i), "%d$") then
opiniontext = string.match(justice_x_opinion_i, "%d") .. (palette[
string.match(justice_x_opinion_i, "%a+")][2] or "")
else
opiniontext = (palette[mw.text.trim(justice_x_opinion_i) or "def"][3] or "")
end
local opinion = mw.text.trim(justice_x_opinion_i, "%d$")
local subopinion = mw.html.create('div')
local cell_class = palette[(string.match(justice_x_opinion_i, "%a+") or "def")][1]
subopinion
:addClass(cell_class)
:attr('aria-label', 'justice ' .. x .. ' ' .. palette[opinion][4])
:wikitext(opiniontext)
:done()
subopinions:node(subopinion)
i = i + 1
end
opinioncell:node(subopinions)
end
entry:node(opinioncell:allDone())
x = x + 1
end
return tostring(entry)
end
return p