Plugin Directory

Changeset 1974987


Ignore:
Timestamp:
11/15/2018 03:06:48 PM (7 years ago)
Author:
martindrapeau
Message:

Standings: football WIP

Location:
amilia-store/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • amilia-store/trunk/amilia-store.php

    r1973325 r1974987  
    66Author: Martin Drapeau <martin.drapeau@amilia.com>
    77Copyright: 2014-2018 Amilia
    8 Version: 2.8.4
     8Version: 2.8.5
    99Author URI: http://www.amilia.com/
    1010License: Apache License 2.0
     
    107107            "standings-instructions-p2" => __("Choose the program in which you have activities representing teams (1 activity = 1 team).", 'amilia-store'),
    108108            "standings-instructions-p3" => __("You can optionally filter activities shown by tags allowing you to exclude activities which are not teams.", 'amilia-store'),
     109            "standings-instructions-p4" => __("The sport you choose determines how to count and display score and standings.", 'amilia-store'),
    109110            "select-program" => __("Select a program", 'amilia-store'),
    110111            "show-hidden-activities" => __("Show hidden activities", 'amilia-store'),
     112            "select-sport" => __("Select a sport", 'amilia-store'),
     113            "soccer" => __("Soccer", 'amilia-store'),
     114            "football" => __("Football", 'amilia-store'),
    111115
    112116            "button-title" => __("Insert a styled button link your Amilia Store", 'amilia-store'),
  • amilia-store/trunk/shortcodes/amilia-store-standings.js

    r1968084 r1974987  
    1010    '  <input type="text" name="store-url" />',
    1111    '  <div class="input-helper store-url"></div>',
     12    '</div>',
     13    '<div class="form-group">',
     14    '  <label>{select-sport} <a class="amilia-help" href="#">(?)</a></label>',
     15    '  <select name="sport">',
     16    '    <option value="soccer">{soccer}</option>',
     17    '    <option value="football">{football}</option>',
     18    '  </select>',
    1219    '</div>',
    1320    '<div class="form-group">',
     
    4754    '  <p>{standings-instructions-p2}</p>',
    4855    '  <p>{standings-instructions-p3}</p>',
     56    '  <p>{standings-instructions-p4}</p>',
    4957    '</div>'
    5058  ].join('\n');
     
    6977    var storeUrl = modal.querySelector('input[name=store-url]'),
    7078        storeUrlError = modal.querySelector('div.store-url'),
     79        sportSelect = modal.querySelector('select[name="sport"]'),
    7180        programSelect = modal.querySelector('select[name="program"]'),
    7281        programSelectError = modal.querySelector('div.input-helper.program'),
     
    184193      var program = getSelectedProgram();
    185194      var tags = getSelectedTags();
    186       return '[' + SHORTCODE + " url='{url}' program='{program}' tags='{tags}' showhidden='{show-hidden}' show='{show}' api='{api}']"
     195      return '[' + SHORTCODE + " url='{url}' sport='{sport}' program='{program}' tags='{tags}' showhidden='{show-hidden}' show='{show}' api='{api}']"
    187196        .replace('{url}', storeUrl.value)
     197        .replace('{sport}', sportSelect.value)
    188198        .replace('{program}', program)
    189199        .replace('{tags}', tags.join(','))
     
    232242        storeUrl.value = activeShortcode.shortcode.attrs.named.url;
    233243        Amilia.validateStoreUrl(storeUrl, storeUrlError);
     244        sportSelect.value = activeShortcode.shortcode.attrs.named.sport || 'soccer';
    234245
    235246        var program = activeShortcode.shortcode.attrs.named.program;
  • amilia-store/trunk/shortcodes/amilia-store-standings.php

    r1970350 r1974987  
    33function amilia_store_standings_shortcode_handler($atts, $content = null) {
    44    $a = shortcode_atts(array(
     5        'sport' => 'soccer',
    56        'program' => '',
    67        'tags' => '',
     
    1314    $uid = rand();
    1415    $api = $a['api'];
     16    $sport = $a['sport'];
    1517    $program = $a['program'];
    1618    if (!is_numeric($program)) $program = 'null';
     
    6769        }
    6870        var api = '$api';
     71        var sport = '$sport';
    6972        var tagIds = [$tags];
    7073        var eventsUrl = api + 'Events';
     
    193196                        team1.L += 1;
    194197                        team2.W += 1;
    195                         team2.Pts += 3;
     198                        team2.Pts += sport == 'football' ? 2 : 3;
    196199                    } else if (goals1 > goals2) {
    197200                        team2.L += 1;
    198201                        team1.W += 1;
    199                         team1.Pts += 3;
     202                        team1.Pts += sport == 'football' ? 2 : 3;
    200203                    }
    201204                    team1.F += goals1;
Note: See TracChangeset for help on using the changeset viewer.