Jump to content

Module:SCOTUS-termlist-entry: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
mNo edit summary
m trying fix; case1 should not wikilink
Line 37: Line 37:
if args.case then args.case = "''[[" .. args.case .. "]]''" else args.case = nil end
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["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"] .. "]]''"
if args["case-article"] then args["case-article"] = "''[[" .. args["case-article"] .. "|" .. args["case-display"] .. "]]''"
else args["case-article"] = nil end
else args["case-article"] = nil end

Revision as of 19:37, 30 September 2016

local p = {}

-- Color palette and wikitext for the opinion arguments. Each group is only mentioned once, e.g. majority stands for majority, 
-- majority1, majority2, majority3, majority4 and majority5
-- The color comes first in the table, then wikitext for numbered values and finally wikitext for non-numbered values
-- Numbers in the wikitext are taken from the values themselves (e.g. majority1 has the wikitext "1" plus whatever wikitext that is
-- mentioned here.
-- Examples: plurality has the wikitext of "*" and the color "#00CD00"
--           plurality1 has the wikitext of "1*" - "1" is taken from the value itself and "*" comes from this table. It has 
--           the color "#00CD00"
   
local palette = {
	majority = {"#00CD00", "", ""},
	plurality = {"#00CD00", "*", "*"},
	concurrence = {"#00B2EE", "", ""},
	concurrencewithoutopinion = {"#00B2EE", "", "-"},
	concurrencedissent = {"#B23AEE", "", ""},
	dissent = {"red", "", ""},
	dissentwithoutopinion = {"red", "", "-"},
	joinmajority = {"#93DB70", "", ""},
	partjoinmajority = {"#93DB70", "*", "*"},
	joinplurality = {"#93DB70", "", ""},
	partjoinplurality = {"#93DB70", "*", "*"},
	joinconcurrence = {"#79CDCD", "", ""},
	partjoinconcurrence = {"#79CDCD", "*", "*"},
	joinconcurrencedissent = {"#CC99CC", "", "*"},
	partjoinconcurrencedissent = {"#CC99CC", "*", "*"},
	joindissent = {"#EE9572", "", ""},
	partjoindissent = {"#EE9572", "*", "*"},
	didnotparticipate = {"white", "", ""},
	def = "",
}

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
	local entry = mw.html.create("tr")
	entry
		:tag("td")
		:css({
			width = "20px",
			["vertical-align"] = "center"
			})
		:wikitext(args["#"])
		:newline()
		:newline()
		:tag("td")
			:css({
				width = "200px",
				["vertical-align"] = "top"
				})
			:tag("small")
				:wikitext((args.case or "") .. (args["case1"] or "") .. (args["case-article"] or "") .. "," .. (args.note or "") .. 
					' <span class="nowrap">' .. args.volume .. " U.S. " .. (args.page or "___") .. '</span>')
				:done()
			:done()
		:tag("td")
			:css({
				width = "200px",
				["vertical-align"] = "top",
				["text-align"] = "right"
				})
			:tag("small")
				:wikitext(args["argue-date"] or "")
				:done()
			:done()
		:tag("td")
			:css({
				["vertical-align"] = "top",
				["text-align"] = "right"
				})
			:tag("small")
				:wikitext(args["decision-date"])
	
	local width = {
		[1] = "",
		[2] = "24px",
		[3] = "16px",
		[4] = "12px",
		[5] = "9px",
	}
	local x = 1
	local z = 1
	while x < 9 or args["justice" .. x .. "-opinion1"] ~= nil do
		local entrysupp = mw.html.create("td")
		entrysupp
			:css({
				padding = "0px",
				margin = "0px",
				["vertical-align"] = "top"
				})
		local sortspanend = "</span>"
		local entrysuppend = '</td>'
		if args["justice" .. x .. "-opinion1"] ~= nil then
			entry:node(sortspan)
			local sortspan = '<span class="sortkey">' .. args["justice" .. x .. "-sortcode"] .. args["#"] .. 
			'</span><span class="sorttext">'
			local subtable = mw.html.create("table")
			subtable
			:css({
				width = "100%",
				height = "3.7em",
				margin = "0px",
				})
			:attr("cellspacing", "0")
			while z < 6 and args["justice" .. x .. "-opinion" .. z] ~= nil and mw.text.trim(args["justice" .. x .. "-opinion" .. z]) ~= "" do
				z = z + 1
			end
			local i = 1
			while i < 6 and args["justice" .. x .. "-opinion" .. i] ~= nil and mw.text.trim(args["justice" .. x .. "-opinion" .. i]) ~= "" do
				if string.find(mw.text.trim(args["justice" .. x .. "-opinion" .. i]), "%d$") then
					opiniontext = string.match(args["justice" .. x .. "-opinion" .. i], "%d") .. (palette[
						string.match(args["justice" .. x .. "-opinion" .. i], "%a+")][2] or "")
				else
					opiniontext = (palette[mw.text.trim(args["justice" .. x .. "-opinion" .. i]) or "def"][3] or "")
				end
				secuential = '<td style="min-width:' .. width[z-1] .. '; text-align:center; border-right:1px solid lightgray;' ..  
				'background-color:' .. palette[(string.match(args["justice" .. x .. "-opinion" .. i], "%a+") or "def")][1] .. '">' .. 
				opiniontext .. '</td>'
				subtable:node(secuential)
				i = i + 1
			end
			entrysupp:node(subtable)
		end
		entry:node(entrysupp)
		entry:node(entrysuppend)
		entry:node(sortspanend)
		x = x + 1
	end
	return tostring(entry)
end

return p