Plugin Directory

Changeset 1977603


Ignore:
Timestamp:
11/20/2018 06:24:32 PM (7 years ago)
Author:
martindrapeau
Message:

Standings for Football improvements

Location:
amilia-store/trunk/shortcodes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • amilia-store/trunk/shortcodes/amilia-store-standings.js

    r1974987 r1977603  
    186186
    187187    storeUrl.onchange = function() {
    188       Amilia.validateStoreUrlAndFetchProgramAndTags();
     188      validateStoreUrlAndFetchProgramAndTags();
    189189    };
    190190
  • amilia-store/trunk/shortcodes/amilia-store-standings.php

    r1974987 r1977603  
    2525    $errorWhenNojQuery = __("Amilia calendar requires jQuery. It cannot be shown.", 'amilia-store');
    2626    $errorNoProgram = __("No programs found.", 'amilia-store');
    27     $legend = __("GP = Games played, W = Win, T = Tie, L = Lost, F = Goals for, A = Goals against, GD = Goal differential, Pts = Points", 'amilia-store');
     27    $legend = $sport == 'football' ?
     28        __("GP = Games played, W = Win, T = Tie, L = Lost, % = Percentage, PDiff = Point difference, Pts = Points", 'amilia-store') :
     29        __("GP = Games played, W = Win, T = Tie, L = Lost, F = Goals for, A = Goals against, GD = Goal differential, Pts = Points", 'amilia-store');
    2830    $label_Team = __("Team", 'amilia-store');
    2931    $label_Home = __("Home", 'amilia-store');
     
    3638    $label_A = __("A", 'amilia-store');
    3739    $label_GD = __("GD", 'amilia-store');
     40    $label_Perc = __("%", 'amilia-store');
     41    $label_PDiff = __("PDiff", 'amilia-store');
    3842    $label_Pts = __("Pts", 'amilia-store');
    3943    $label_Location = __("Location", 'amilia-store');
     
    157161                        GP: 0,
    158162                        W: 0,
     163                        L: 0,
    159164                        T: 0,
    160                         L: 0,
     165                        GD: 0,
     166                        Pts: 0,
     167                        // Soccer
    161168                        F: 0,
    162169                        A: 0,
    163                         GD: 0,
    164                         Pts: 0
     170                        // Football
     171                        Perc: 0
    165172                    };
    166173                    id2team[id] = team;
     
    226233                var team = id2team[ids[i]];
    227234                team.GD = team.F - team.A;
     235                team.Perc = (team.W + team.T/2) / (team.W + team.T + team.L);
     236                if (isNaN(team.Perc)) team.Perc = 0;
    228237                teams.push(team);
    229238            }
     
    248257                    '<td>' + team.W + '</td>' +
    249258                    '<td>' + team.L + '</td>' +
    250                     '<td>' + team.T + '</td>' +
    251                     '<td>' + team.F + '</td>' +
    252                     '<td>' + team.A + '</td>' +
    253                     '<td>' + team.GD + '</td>' +
    254                     '<td>' + team.Pts + '</td>' +
     259                    '<td>' + team.T + '</td>';
     260                if (sport == 'football') {
     261                    html += '<td>' + (team.Perc ? Math.round(1000*team.Perc)/1000 : '-') + '</td>';
     262                } else {
     263                    html += '<td>' + team.F + '</td>' +
     264                            '<td>' + team.A + '</td>';
     265                }
     266                html += '<td>' + team.GD + '</td>' +
     267                        '<td>' + team.Pts + '</td>' +
    255268                    '</tr>';
    256269                addToCalendarTooltipHtml +=
     
    403416                <th>$label_L</th>
    404417                <th>$label_T</th>
     418EOD;
     419    if ($sport == 'football') {
     420        $html .= <<<EOD
     421                <th>$label_Perc</th>
     422                <th>$label_PDiff</th>
     423EOD;
     424    } else {
     425        $html .= <<<EOD
    405426                <th>$label_F</th>
    406427                <th>$label_A</th>
    407428                <th>$label_GD</th>
     429EOD;
     430    }
     431    $html .= <<<EOD
    408432                <th>$label_Pts</th>
    409433            </tr>
Note: See TracChangeset for help on using the changeset viewer.