Changeset 1928763
- Timestamp:
- 08/22/2018 06:39:47 PM (8 years ago)
- File:
-
- 1 edited
-
amilia-store/trunk/amilia-store.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
amilia-store/trunk/amilia-store.php
r1928745 r1928763 6 6 Author: Martin Drapeau <martin.drapeau@amilia.com> 7 7 Copyright: 2014-2017 Amilia 8 Version: 2.5. 38 Version: 2.5.4 9 9 Author URI: http://www.amilia.com/ 10 10 License: Apache License 2.0 … … 311 311 $view = $a['view']; 312 312 $date = $a['date']; 313 if (empty($date)) $date = date('Y-m-d'); 313 314 $time = $a['time']; 314 315 $api = $a['api']; … … 608 609 $label_GD = __("GD", 'amilia-store'); 609 610 $label_Pts = __("Pts", 'amilia-store'); 611 $label_Location = __("Location", 'amilia-store'); 612 $label_Date = __("Date/time", 'amilia-store'); 610 613 $pleaseWait = __("Please wait...", 'amilia-store'); 614 $rankings = __("Rankings", 'amilia-store'); 615 $games = __("Games", 'amilia-store'); 611 616 $warning = __("Less or more than 2 teams meeting at same time and place", 'amilia-store'); 612 617 … … 648 653 return match && match.length >= 1 ? match[0].trim() : null; 649 654 } 655 function formatGameDateTime(start, end) { 656 var startDate = moment(start).format('YYYY-MM-DD'); 657 var startTime = moment(start).format('H:mm'); 658 var endDate = moment(end).format('YYYY-MM-DD'); 659 var endTime = moment(end).format('H:mm'); 660 return startDate + ' ' + startTime + ' - ' + (startDate == endDate ? endTime : (endDate + ' ' + endTime)); 661 } 650 662 651 663 function renderRankings() { 652 console.log(events.length);653 654 664 var ids = []; 655 665 var id2team = {}; … … 657 667 var game2events = {}; 658 668 var warnings = []; 669 var gamesHtml = ''; 659 670 660 671 for (var i = 0; i < events.length; i++) { … … 668 679 } 669 680 } 670 if (!found) break;681 if (!found) continue; 671 682 } 672 683 … … 690 701 id2team[id] = team; 691 702 } 692 game = event.Location + ': ' + moment(event.start).format('YYYY-MM-DD hh:mm') + ' - ' + moment(event.end).format('YYYY-MM-DD hh:mm');703 game = event.Location + ': ' + formatGameDateTime(event.start, event.end); 693 704 if (!game2events[game]) { 694 705 game2events[game] = []; … … 697 708 game2events[game].push(event); 698 709 } 710 console.log(game2events); 699 711 700 712 for (var i = 0; i < games.length; i++) { … … 707 719 var goals1 = event1.AttendanceSummary && event1.AttendanceSummary.ValueCounts && event1.AttendanceSummary.ValueCounts.GOAL ? event1.AttendanceSummary.ValueCounts.GOAL : 0; 708 720 var goals2 = event2.AttendanceSummary && event2.AttendanceSummary.ValueCounts && event2.AttendanceSummary.ValueCounts.GOAL ? event2.AttendanceSummary.ValueCounts.GOAL : 0; 709 team1.GP += 1; 710 team2.GP += 1; 721 var gamePlayed = goals1 || goals2 || 722 (event1.AttendanceSummary && event1.AttendanceSummary.StatusCounts && event1.AttendanceSummary.StatusCounts.Present && 723 event2.AttendanceSummary && event2.AttendanceSummary.StatusCounts && event2.AttendanceSummary.StatusCounts.Present); 724 team1.GP += gamePlayed ? 1 : 0; 725 team2.GP += gamePlayed ? 1 : 0; 711 726 if (goals1 == goals2) { 712 727 team1.T += 1; … … 727 742 team1.A += goals2; 728 743 team2.A += goals1; 744 gamesHtml += '<tr>' + 745 '<td>' + event1.Location + '</td>' + 746 '<td>' + formatGameDateTime(event1.start, event1.end) + '</td>' + 747 '<td>' + team1.Name + ' ' + (gamePlayed ? goals1 : '') + '</td>' + 748 '<td>' + team2.Name + ' ' + (gamePlayed ? goals2 : '') + '</td>' + 749 '</tr>'; 729 750 } else { 730 751 var names = []; … … 734 755 } 735 756 } 757 document.getElementById('amilia-store-games-tbody').innerHTML = gamesHtml; 758 759 var teams = []; 760 for (var i = 0; i < ids.length; i++) { 761 teams.push(id2team[ids[i]]); 762 } 763 teams.sort(function(a,b) { 764 if (a.Pts == b.Pts) return 0; 765 return a.Pts < b.Pts; 766 }); 736 767 737 768 var html = ''; 738 for (var i = 0; i < ids.length; i++) { 739 var id = ids[i]; 740 var team = id2team[id]; 769 for (var i = 0; i < teams.length; i++) { 770 var team = teams[i]; 741 771 html += '<tr>' + 742 772 '<td class="team">' + team.Name + '</td>' + … … 751 781 '</tr>'; 752 782 } 753 document.getElementById('amilia-store- table-tbody').innerHTML = html;783 document.getElementById('amilia-store-rankings-tbody').innerHTML = html; 754 784 755 785 if (warnings.length) { 756 786 html = '<strong>Warnings!</strong><br/>' + warnings.join('<br/>'); 757 document.getElementById('amilia-store- table-warnings').innerHTML = html;787 document.getElementById('amilia-store-rankings-warnings').innerHTML = html; 758 788 } 759 789 } … … 808 838 </style> 809 839 <div id="amilia-store-rankings-container"> 840 <h3>$rankings</h3> 810 841 <table class="amilia-store-table"> 811 842 <thead> … … 822 853 </tr> 823 854 </thead> 824 <tbody id="amilia-store- table-tbody">855 <tbody id="amilia-store-rankings-tbody"> 825 856 <tr><td colspan="9" style="text-align:center;font-style:italic;">$pleaseWait</td></tr> 826 857 </tbody> 827 858 </table> 828 859 <p class="amilia-store-table-legend">$legend</p> 829 <p id="amilia-store-table-warnings"></p> 860 <p id="amilia-store-rankings-warnings"></p> 861 <h3>$games</h3> 862 <table class="amilia-store-table"> 863 <thead> 864 <tr> 865 <th class="location">$label_Location</th> 866 <th class="date">$label_Date</th> 867 <th>$label_Team 1</th> 868 <th>$label_Team 2</th> 869 </tr> 870 </thead> 871 <tbody id="amilia-store-games-tbody"> 872 <tr><td colspan="4" style="text-align:center;font-style:italic;">$pleaseWait</td></tr> 873 </tbody> 874 </table> 830 875 </div> 831 876 EOD;
Note: See TracChangeset
for help on using the changeset viewer.