<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3APolitical_party%2Ftesttable</id>
	<title>Module:Political party/testtable - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3APolitical_party%2Ftesttable"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Political_party/testtable&amp;action=history"/>
	<updated>2026-04-24T14:12:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Political_party/testtable&amp;diff=144372&amp;oldid=prev</id>
		<title>imported&gt;Paine Ellsworth: sp.</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Political_party/testtable&amp;diff=144372&amp;oldid=prev"/>
		<updated>2022-11-28T07:18:00Z</updated>

		<summary type="html">&lt;p&gt;sp.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
local contrastRatio = require(&amp;#039;Module:Color contrast&amp;#039;)._ratio&lt;br /&gt;
&lt;br /&gt;
function __genOrderedIndex(t)&lt;br /&gt;
    local orderedIndex = {}&lt;br /&gt;
    for key in pairs(t) do&lt;br /&gt;
        table.insert(orderedIndex, key)&lt;br /&gt;
    end&lt;br /&gt;
    table.sort(orderedIndex)&lt;br /&gt;
    return orderedIndex&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function orderedNext(t, state)&lt;br /&gt;
    -- Equivalent of the next function, but returns the keys in the alphabetic&lt;br /&gt;
    -- order. We use a temporary ordered key table that is stored in the&lt;br /&gt;
    -- table being iterated.&lt;br /&gt;
&lt;br /&gt;
    local key = nil&lt;br /&gt;
    if state == nil then&lt;br /&gt;
        -- the first time, generate the index&lt;br /&gt;
        t.__orderedIndex = __genOrderedIndex(t)&lt;br /&gt;
        key = t.__orderedIndex[1]&lt;br /&gt;
    else&lt;br /&gt;
        -- fetch the next value&lt;br /&gt;
        for i = 1, #(t.__orderedIndex) do&lt;br /&gt;
            if t.__orderedIndex[i] == state then&lt;br /&gt;
                key = t.__orderedIndex[i + 1]&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if key then&lt;br /&gt;
        return key, t[key]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- no more value to return, cleanup&lt;br /&gt;
    t.__orderedIndex = nil&lt;br /&gt;
    return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function orderedPairs(t)&lt;br /&gt;
    -- Equivalent of the pairs() function on tables. Allows to iterate in order.&lt;br /&gt;
    return orderedNext, t, nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function isContrastValid(text, background)&lt;br /&gt;
	if not background or background == &amp;quot;&amp;quot; then&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ratio = tonumber(contrastRatio({text, background}))&lt;br /&gt;
	if not ratio then&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	if ratio &amp;gt; 4.5 and ratio &amp;lt; 7.0 then&lt;br /&gt;
		return &amp;quot;AA&amp;quot;&lt;br /&gt;
	elseif ratio &amp;gt; 7.0 then&lt;br /&gt;
		return &amp;quot;AAA&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;quot;Failed&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function isColorValid(color)&lt;br /&gt;
	if not color or color == &amp;quot;&amp;quot; then&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Convert to lowercase.&lt;br /&gt;
	color = color:lower()&lt;br /&gt;
	&lt;br /&gt;
	-- Check if color is using an HTML color name.&lt;br /&gt;
	local HTMLcolor = mw.loadData(&amp;#039;Module:Color contrast/colors&amp;#039;)&lt;br /&gt;
	if HTMLcolor[color] then&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Added as a valid color in https://www.w3.org/TR/css-color-3/#transparent&lt;br /&gt;
	if color == &amp;quot;transparent&amp;quot; then&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Remove leading # if there is one.&lt;br /&gt;
	color = string.gsub(color, &amp;quot;^#&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	local cs = mw.text.split(color, &amp;#039;&amp;#039;)&lt;br /&gt;
	if #cs == 6 or #cs == 3 then&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Example of having all the data - color and names - in one table. Requires one page to be edited instead of two when adding a new party.&lt;br /&gt;
function p.tables(frame)&lt;br /&gt;
	-- Initialise and populate variables&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	local index = args.letter&lt;br /&gt;
	&lt;br /&gt;
	-- Load data from submodule&lt;br /&gt;
	local data = require(&amp;#039;Module:Political party/&amp;#039; .. index)&lt;br /&gt;
	&lt;br /&gt;
	-- helper function&lt;br /&gt;
	local function table_row(party_name, party_info)&lt;br /&gt;
		local res = mw.html.create(&amp;#039;&amp;#039;)&lt;br /&gt;
		res:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
			:attr(&amp;#039;scope&amp;#039;, &amp;#039;row&amp;#039;)&lt;br /&gt;
			:wikitext(party_name)&lt;br /&gt;
		res:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;background-color&amp;#039;, party_info.color)&lt;br /&gt;
			:wikitext(party_info.color)&lt;br /&gt;
		res:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:wikitext(party_info.abbrev)&lt;br /&gt;
		res:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:wikitext(party_info.shortname)&lt;br /&gt;
		res:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:wikitext(tostring(isColorValid(party_info.color)))&lt;br /&gt;
		res:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:wikitext(isContrastValid(&amp;quot;black&amp;quot;, party_info.color))&lt;br /&gt;
		res:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:wikitext(isContrastValid(&amp;quot;#0645AD&amp;quot;, party_info.color))&lt;br /&gt;
		res:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:wikitext(isContrastValid(&amp;quot;#0B0080&amp;quot;, party_info.color))&lt;br /&gt;
&lt;br /&gt;
		return tostring(res)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- build table&lt;br /&gt;
	local root = mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
	root:addClass(&amp;#039;wikitable&amp;#039;)&lt;br /&gt;
		:addClass(&amp;#039;sortable&amp;#039;)&lt;br /&gt;
		:addClass(&amp;#039;plainrowheaders&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;background-color&amp;#039;, &amp;#039;transparent&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;font-size&amp;#039;, &amp;#039;90%&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;line-height&amp;#039;, &amp;#039;100%&amp;#039;)&lt;br /&gt;
		:cssText(style)&lt;br /&gt;
	local row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;scope&amp;#039;, &amp;#039;col&amp;#039;)&lt;br /&gt;
		:wikitext(&amp;#039;Political party name&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;scope&amp;#039;, &amp;#039;col&amp;#039;)&lt;br /&gt;
		:addClass(&amp;#039;unsortable&amp;#039;)&lt;br /&gt;
		:wikitext(&amp;#039;color&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;scope&amp;#039;, &amp;#039;col&amp;#039;)&lt;br /&gt;
		:wikitext(&amp;#039;abbrev&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;scope&amp;#039;, &amp;#039;col&amp;#039;)&lt;br /&gt;
		:wikitext(&amp;#039;shortname&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;scope&amp;#039;, &amp;#039;col&amp;#039;)&lt;br /&gt;
		:wikitext(&amp;#039;Is color valid?&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;scope&amp;#039;, &amp;#039;col&amp;#039;)&lt;br /&gt;
		:wikitext(&amp;#039;Contrast normal text&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;scope&amp;#039;, &amp;#039;col&amp;#039;)&lt;br /&gt;
		:wikitext(&amp;#039;Contrast unvisited link&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;scope&amp;#039;, &amp;#039;col&amp;#039;)&lt;br /&gt;
		:wikitext(&amp;#039;Contrast visited link&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
	for party_name, party_vals in orderedPairs(data.full) do&lt;br /&gt;
		row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		row:wikitext(table_row(party_name, party_vals))&lt;br /&gt;
	end&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Paine Ellsworth</name></author>
	</entry>
</feed>