<?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%3APakistanSuperLeagueProgression</id>
	<title>Module:PakistanSuperLeagueProgression - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3APakistanSuperLeagueProgression"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:PakistanSuperLeagueProgression&amp;action=history"/>
	<updated>2026-08-10T01:42:39Z</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:PakistanSuperLeagueProgression&amp;diff=144261&amp;oldid=prev</id>
		<title>imported&gt;GeoffreyT2000: GeoffreyT2000 moved page Module:PakistanSuperLeague/LeagueProgression to Module:PakistanSuperLeagueProgression without leaving a redirect: Per requested move discussion at Module talk:PakistanSuperLeagueProgression#Requested move 1 November 2019.</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:PakistanSuperLeagueProgression&amp;diff=144261&amp;oldid=prev"/>
		<updated>2019-11-23T17:52:11Z</updated>

		<summary type="html">&lt;p&gt;GeoffreyT2000 moved page &lt;a href=&quot;/index.php?title=Module:PakistanSuperLeague/LeagueProgression&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Module:PakistanSuperLeague/LeagueProgression (page does not exist)&quot;&gt;Module:PakistanSuperLeague/LeagueProgression&lt;/a&gt; to &lt;a href=&quot;/research/Module:PakistanSuperLeagueProgression&quot; title=&quot;Module:PakistanSuperLeagueProgression&quot;&gt;Module:PakistanSuperLeagueProgression&lt;/a&gt; without leaving a redirect: Per &lt;a href=&quot;/index.php?title=WP:RM&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:RM (page does not exist)&quot;&gt;requested move discussion&lt;/a&gt; at &lt;a href=&quot;/index.php?title=Module_talk:PakistanSuperLeagueProgression&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Module talk:PakistanSuperLeagueProgression (page does not exist)&quot;&gt;Module talk:PakistanSuperLeagueProgression#Requested move 1 November 2019&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
    Module for generating league progresion tables intended for use in Pakistan Super League season articles.&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local _module = {}&lt;br /&gt;
&lt;br /&gt;
_module.create = function(frame)&lt;br /&gt;
    &lt;br /&gt;
    ------------- Functions -------------&lt;br /&gt;
    local strFind = string.find&lt;br /&gt;
    local strMatch = string.match&lt;br /&gt;
    local strSplit = mw.text.split&lt;br /&gt;
    local strFormat = string.format&lt;br /&gt;
    local strTrim = mw.text.trim&lt;br /&gt;
    local strSub = string.sub&lt;br /&gt;
    local strRepeat = string.rep&lt;br /&gt;
    local strUpper = string.upper&lt;br /&gt;
    &lt;br /&gt;
    ------------- Arguments -------------&lt;br /&gt;
    local args = frame.args&lt;br /&gt;
    local matchesPerTeam = tonumber(args.matchesPerTeam) or error(&amp;quot;Invalid or missing parameter &amp;#039;matchesPerTeam&amp;#039;&amp;quot;)&lt;br /&gt;
    local ktype = tonumber(args.knockoutType) or error(&amp;quot;Invalid or missing parameter &amp;#039;knockoutType&amp;#039;&amp;quot;)&lt;br /&gt;
    local teams = strSplit(args.teams or error(&amp;quot;Invalid or missing parameter &amp;#039;knockoutType&amp;#039;&amp;quot;), &amp;#039;,&amp;#039;, true)&lt;br /&gt;
    local matchReportArticle = args.matchReportArticle or &amp;#039;&amp;#039;&lt;br /&gt;
    local caption = args.caption&lt;br /&gt;
&lt;br /&gt;
    -- The colours for each result&lt;br /&gt;
    local colours_win           = &amp;quot;#99FF99&amp;quot;   -- Win&lt;br /&gt;
    local colours_loss          = &amp;quot;#FFDDDD&amp;quot;   -- Loss&lt;br /&gt;
    --local colours_tie           = &amp;quot;&amp;quot;&lt;br /&gt;
    local colours_noResult      = &amp;quot;#DFDFFF&amp;quot;   -- No result&lt;br /&gt;
    local colours_eliminated    = &amp;quot;#DCDCDC&amp;quot;   -- Eliminated&lt;br /&gt;
    local colours_notPossible   = &amp;quot;#DCDCDC&amp;quot;   -- Not technically possible (only used for some playoff matches with knockoutType=2)&lt;br /&gt;
    &lt;br /&gt;
    -- The CSS classes applied to the cells of each result&lt;br /&gt;
    local classes_win       = &amp;quot;yes table-yes2&amp;quot;&lt;br /&gt;
    local classes_loss      = &amp;quot;no table-no2&amp;quot;&lt;br /&gt;
    local classes_noResult  = &amp;quot;noresult&amp;quot;&lt;br /&gt;
    --local classes_tie       = &amp;quot;&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    -- The output buffer&lt;br /&gt;
    local output = {}&lt;br /&gt;
    local outputIndex = 1&lt;br /&gt;
    function print(s)&lt;br /&gt;
        output[outputIndex] = s&lt;br /&gt;
        outputIndex = outputIndex + 1&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    local kMatches = ({ 2, 3 }) [ktype]&lt;br /&gt;
    if not kMatches then&lt;br /&gt;
        error(&amp;quot;Invalid knockout type: &amp;quot; .. ktype)&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    -- Construct the header&lt;br /&gt;
    print(strFormat([[&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;%s&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; rowspan=&amp;quot;2&amp;quot; | Team&lt;br /&gt;
! colspan=&amp;quot;%d&amp;quot; style=&amp;quot;border-left: 4px solid #454545&amp;quot; | Group matches&lt;br /&gt;
! colspan=&amp;quot;%d&amp;quot; style=&amp;quot;border-left: 4px solid #454545&amp;quot; | Playoffs&lt;br /&gt;
|-&lt;br /&gt;
]],&lt;br /&gt;
    caption and &amp;#039;\n|+&amp;#039; .. caption or &amp;#039;&amp;#039;, matchesPerTeam, kMatches))&lt;br /&gt;
    &lt;br /&gt;
    for i = 1, matchesPerTeam do&lt;br /&gt;
        -- Generate the headers for each group match&lt;br /&gt;
        print(strFormat(&amp;#039;! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 30px;%s&amp;quot; | %d\n&amp;#039;, i == 1 and &amp;quot; border-left: 4px solid #454545&amp;quot; or &amp;quot;&amp;quot;, i))&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    --[[&lt;br /&gt;
        Headers specific to each knockout type&lt;br /&gt;
    ]]&lt;br /&gt;
    &lt;br /&gt;
    local knockoutHeaders = {&lt;br /&gt;
    -- Knockout type 1 (used from 2008 to 2010)&lt;br /&gt;
[[&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 32px; border-left: 4px solid #454545&amp;quot; | &amp;lt;abbr title=&amp;quot;Semi-final&amp;quot;&amp;gt;SF&amp;lt;/abbr&amp;gt;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 32px&amp;quot; | &amp;lt;abbr title=&amp;quot;Final&amp;quot;&amp;gt;F&amp;lt;/abbr&amp;gt;]],&lt;br /&gt;
    -- Knockout type 2&lt;br /&gt;
[[&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 32px; border-left: 4px solid #454545&amp;quot; | &amp;lt;abbr title=&amp;quot;Qualifier 1 or Eliminator&amp;quot;&amp;gt;Q1/E&amp;lt;/abbr&amp;gt;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 32px&amp;quot; | &amp;lt;abbr title=&amp;quot;Qualifier 2&amp;quot;&amp;gt;Q2&amp;lt;/abbr&amp;gt;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 32px&amp;quot; | &amp;lt;abbr title=&amp;quot;Final&amp;quot;&amp;gt;F&amp;lt;/abbr&amp;gt;]]&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    print(knockoutHeaders[ktype])&lt;br /&gt;
    &lt;br /&gt;
    local argCounter = 1&lt;br /&gt;
    &lt;br /&gt;
    -- Generate the table&lt;br /&gt;
    for i = 1, #teams do&lt;br /&gt;
    &lt;br /&gt;
        local team = strTrim(teams[i])&lt;br /&gt;
        print(&amp;#039;\n|-\n! scope=&amp;quot;row&amp;quot; style=&amp;quot;text-align: left; padding-right: 10px&amp;quot; | [[&amp;#039; .. team .. &amp;#039;]]\n&amp;#039;)   -- Add the team name&lt;br /&gt;
        local gs, ks = args[argCounter] or &amp;#039;&amp;#039;, args[argCounter + 1] or &amp;#039;&amp;#039;&lt;br /&gt;
        local j, comma, runningScore, lastMatch = 0, 0, 0, 0&lt;br /&gt;
        argCounter = argCounter + 2&lt;br /&gt;
        &lt;br /&gt;
        repeat&lt;br /&gt;
            j = j + 1&lt;br /&gt;
            if j &amp;gt; matchesPerTeam then&lt;br /&gt;
                error(strFormat(&amp;quot;Too many group stage matches. Expected %d (team: %s)&amp;quot;, matchesPerTeam, team))&lt;br /&gt;
            end&lt;br /&gt;
            &lt;br /&gt;
            local startPos = comma + 1&lt;br /&gt;
            comma = strFind(gs, &amp;#039;,&amp;#039;, startPos, true) or 0&lt;br /&gt;
            &lt;br /&gt;
            print(j == 1 and &amp;#039;| style=&amp;quot;border-left: 4px solid #454545; &amp;#039; or &amp;#039;|| style=&amp;quot;&amp;#039;)&lt;br /&gt;
            &lt;br /&gt;
            local rpos = strFind(gs, &amp;#039;%S&amp;#039;, startPos)&lt;br /&gt;
            if rpos and (rpos &amp;lt; comma or comma == 0) then&lt;br /&gt;
                local result, match = strUpper(strSub(gs, rpos, rpos)), tonumber(strMatch(strSub(gs, rpos + 1, comma - 1), &amp;#039;^(.-)%s*$&amp;#039;))&lt;br /&gt;
&lt;br /&gt;
                -- Check that the match number is a valid non-negative integer greater than the preceding match number.&lt;br /&gt;
                if not match or match &amp;lt;= 0 or match % 1 ~= 0 then&lt;br /&gt;
                    error(strFormat(&amp;quot;Match number does not exist or is not a valid integer greater than 0 for group stage result #%d (team: %s)&amp;quot;, j, team))&lt;br /&gt;
                elseif match &amp;lt;= lastMatch then&lt;br /&gt;
                    error(strFormat(&amp;quot;Invalid match number: %d for group stage result #%d, must be greater than the preceding match number (%d) (team: %s)&amp;quot;, match, j, lastMatch, team))&lt;br /&gt;
                end&lt;br /&gt;
                lastMatch = match&lt;br /&gt;
                &lt;br /&gt;
                if result == &amp;#039;W&amp;#039; then    -- Win&lt;br /&gt;
                    runningScore = runningScore + 2&lt;br /&gt;
                    print(strFormat(&amp;#039;background-color: %s&amp;quot; class=&amp;quot;%s&amp;quot; | [[%s#match%s|%d]] &amp;#039;, colours_win, classes_win, matchReportArticle, match, runningScore))&lt;br /&gt;
                elseif result == &amp;#039;L&amp;#039; then     -- Loss&lt;br /&gt;
                    print(strFormat(&amp;#039;background-color: %s&amp;quot; class=&amp;quot;%s&amp;quot; | [[%s#match%s|%d]] &amp;#039;, colours_loss, classes_loss, matchReportArticle, match, runningScore))&lt;br /&gt;
                elseif result == &amp;#039;N&amp;#039; then     -- No result&lt;br /&gt;
                    runningScore = runningScore + 1&lt;br /&gt;
                    print(strFormat(&amp;#039;background-color: %s&amp;quot; class=&amp;quot;%s&amp;quot; | [[%s#match%s|%d]] &amp;#039;, colours_noResult, classes_noResult, matchReportArticle, match, runningScore))&lt;br /&gt;
                --elseif result == &amp;#039;T&amp;#039; then     -- Tie&lt;br /&gt;
                --    runningScore = runningScore + 1&lt;br /&gt;
                --    print(strFormat(&amp;#039;background-color: %s&amp;quot; class=&amp;quot;%s&amp;quot; | [[%s#match%s|%d]] &amp;#039;, colours_tie, classes_tie, matchReportArticle, match, runningScore))&lt;br /&gt;
                else&lt;br /&gt;
                    error(strFormat(&amp;quot;Invalid group stage result #%d: &amp;#039;%s&amp;#039;, expecting &amp;#039;W&amp;#039;, &amp;#039;L&amp;#039;, &amp;#039;N&amp;#039;, or &amp;#039;T&amp;#039; as first character (team: %s)&amp;quot;, j, result, team))&lt;br /&gt;
                end&lt;br /&gt;
            else&lt;br /&gt;
                -- Result not given&lt;br /&gt;
                print(&amp;#039;&amp;quot; | &amp;#039;)&lt;br /&gt;
            end&lt;br /&gt;
        until comma == 0&lt;br /&gt;
        if j ~= matchesPerTeam then    -- Output empty cells for the remaining matches&lt;br /&gt;
            print(strRepeat(&amp;#039;|| &amp;#039;, matchesPerTeam - j))&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        j, comma = 0, 0&lt;br /&gt;
&lt;br /&gt;
        repeat&lt;br /&gt;
            j = j + 1&lt;br /&gt;
            if j &amp;gt; kMatches then&lt;br /&gt;
                error(strFormat(&amp;quot;Too many playoff stage matches. Expected %d (team: %s)&amp;quot;, kMatches, team))&lt;br /&gt;
            end&lt;br /&gt;
            &lt;br /&gt;
            local startPos = comma + 1&lt;br /&gt;
            comma = strFind(ks, &amp;#039;,&amp;#039;, startPos, true) or 0&lt;br /&gt;
            &lt;br /&gt;
            print(j == 1 and &amp;#039;|| style=&amp;quot;border-left: 4px solid #454545; &amp;#039; or &amp;#039;|| style=&amp;quot;&amp;#039;)&lt;br /&gt;
            &lt;br /&gt;
            local rpos = strFind(ks, &amp;#039;%S&amp;#039;, startPos)&lt;br /&gt;
            if rpos and (rpos &amp;lt; comma or comma == 0) then&lt;br /&gt;
                local result, match = strUpper(strSub(ks, rpos, rpos)), tonumber(strMatch(strSub(ks, rpos + 1, comma - 1), &amp;#039;^(.-)%s*$&amp;#039;))&lt;br /&gt;
                &lt;br /&gt;
                if result == &amp;#039;E&amp;#039; then&lt;br /&gt;
                    if comma ~= 0 then&lt;br /&gt;
                        error(&amp;quot;The result &amp;#039;E&amp;#039; must be the last result in the playoff stage result list. (team: &amp;quot; .. team ..&amp;quot;)&amp;quot;)&lt;br /&gt;
                    end&lt;br /&gt;
                    print(strFormat(&amp;#039;background-color: %s&amp;quot; colspan=&amp;quot;%d&amp;quot; | &amp;#039;, colours_eliminated, kMatches - j + 1))&lt;br /&gt;
                    j = kMatches    -- To avoid printing empty cells for the remaining matches&lt;br /&gt;
                    break&lt;br /&gt;
                elseif result == &amp;#039;U&amp;#039; then&lt;br /&gt;
                    print(&amp;#039;background-color: &amp;#039; .. colours_notPossible .. &amp;#039;&amp;quot; | &amp;#039;)&lt;br /&gt;
                else&lt;br /&gt;
                    if not match or match &amp;lt; 0 or match % 1 ~= 0 then&lt;br /&gt;
                        error(strFormat(&amp;quot;Match number does not exist or is invalid for playoff stage result #%d (team: %s)&amp;quot;, j, team))&lt;br /&gt;
                    elseif match &amp;lt;= lastMatch then&lt;br /&gt;
                        error(strFormat(&amp;quot;Invalid match number: %d for group stage result #%d, must be greater than the preceding match number (%d) (team: %s)&amp;quot;, match, j, lastMatch, team))&lt;br /&gt;
                    end&lt;br /&gt;
                    &lt;br /&gt;
                    lastMatch = match&lt;br /&gt;
                    &lt;br /&gt;
                    if result == &amp;#039;W&amp;#039; then&lt;br /&gt;
                        print(strFormat(&amp;#039;background-color: %s&amp;quot; class=&amp;quot;%s&amp;quot; | [[%s#match%s|W]] &amp;#039;, colours_win, classes_win, matchReportArticle, match))&lt;br /&gt;
                    elseif result == &amp;#039;L&amp;#039; then&lt;br /&gt;
                        print(strFormat(&amp;#039;background-color: %s&amp;quot; class=&amp;quot;%s&amp;quot; | [[%s#match%s|L]] &amp;#039;, colours_loss, classes_loss, matchReportArticle, match))&lt;br /&gt;
                    elseif result == &amp;#039;N&amp;#039; then&lt;br /&gt;
                        print(strFormat(&amp;#039;background-color: %s&amp;quot; class=&amp;quot;%s&amp;quot; | [[%s#match%s|N]] &amp;#039;, colours_noResult, classes_noResult, matchReportArticle, match))&lt;br /&gt;
                    --elseif result == &amp;#039;T&amp;#039; then&lt;br /&gt;
                    --    print(strFormat(&amp;#039;background-color: %s&amp;quot; class=&amp;quot;%s&amp;quot; | [[%s#match%s|T]] &amp;#039;, colours_tie, classes_tie, matchReportArticle, match))&lt;br /&gt;
                    else&lt;br /&gt;
                        error(strFormat(&amp;quot;Invalid group stage result #%d: &amp;#039;%s&amp;#039;, expecting &amp;#039;W&amp;#039;, &amp;#039;L&amp;#039;, &amp;#039;N&amp;#039;, &amp;#039;, &amp;#039;E&amp;#039; or &amp;#039;U&amp;#039; as first character (team: %s)&amp;quot;, j, result, team))&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
            else&lt;br /&gt;
                -- Result not given&lt;br /&gt;
                print(&amp;#039;&amp;quot; | &amp;#039;)&lt;br /&gt;
            end&lt;br /&gt;
        until comma == 0&lt;br /&gt;
        if j ~= kMatches then    -- Output empty cells for the remaining matches&lt;br /&gt;
            print(strRepeat(&amp;#039;|| &amp;#039;, kMatches - j))&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    -- Footer&lt;br /&gt;
    print(strFormat([[&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float: right; width: 20%%; text-align: center; font-size: 90%%&amp;quot;&lt;br /&gt;
| class=&amp;quot;%s&amp;quot; style=&amp;quot;background-color: %s&amp;quot; | Win&lt;br /&gt;
| class=&amp;quot;%s&amp;quot; style=&amp;quot;background-color: %s&amp;quot; | Loss&lt;br /&gt;
| class=&amp;quot;%s&amp;quot; style=&amp;quot;background-color: %s&amp;quot; | No result&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul style=&amp;quot;font-size: 90%%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;#039;&amp;#039;&amp;#039;Note&amp;#039;&amp;#039;&amp;#039;: The total points at the end of each group match are listed.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;#039;&amp;#039;&amp;#039;Note&amp;#039;&amp;#039;&amp;#039;: Click on the points (group matches) or W/L (playoffs) to see the match summary.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;]],&lt;br /&gt;
    classes_win, colours_win, classes_loss, colours_loss, classes_noResult, colours_noResult))&lt;br /&gt;
    &lt;br /&gt;
    return table.concat(output)&lt;br /&gt;
    &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return _module&lt;/div&gt;</summary>
		<author><name>imported&gt;GeoffreyT2000</name></author>
	</entry>
</feed>