Loading...
 Start Page
  • Ελληνικά
  • English
PATRAS WEATHER

MEDALS SCORE RANKINGS >>

GOLD SPONSORS

OFFICIAL SUPPORTERS

                  

  

MEDIA SPONSORS

      

SUPPORTERS

          

91-93 Patron Claus
Patras, P.C. 26335, Greece

 

               

© Copyright 2019 - 2021 Mediterranean Beach Games, Patras 2019
'); $.scrollTo('.c_mbgsports h1'); if (hash.sportid == '') showRankings(); else { showPre(); if (hash.startlist) showStartList(hash.sportid); else if (hash.medals) showMedals(hash.sportid); else showResults(hash.sportid, hash.matchid, hash.datein); } } nav(); window.onhashchange = nav; function getDiv(classname, content) {return '
'+content+'
';} function showRankings() { let shtml=''; $.getJSON(apibase+'/api/medals', function(medals) { medals.sort(function (a, b) { if (parseInt(a.total_gold) > parseInt(b.total_gold)) return -1; else if (parseInt(a.total_gold) == parseInt(b.total_gold)) { if (parseInt(a.total_silver) > parseInt(b.total_silver)) return -1; else if (parseInt(a.total_silver) == parseInt(b.total_silver)) { if (parseInt(a.total_bronze) >= parseInt(b.total_bronze)) return -1; } } return 1; }); shtml += '
'; let rank = 1; let ranklimit = 5; for (acountry of medals) { shtml += '
'; shtml += ''+rank+''; shtml += ''+getCountryFlagImage(acountry.country_name, acountry.country_image)+' '+acountry.country_name+''; shtml += ''; shtml += ''+getMedal('G')+' '+acountry.total_gold+''; shtml += ''+getMedal('S')+' '+acountry.total_silver+''; shtml += ''+getMedal('B')+' '+acountry.total_bronze+''; shtml += ''; // mbgmedals shtml += '
'; shtml += '
'; // mbgastage rank++; if (rank > ranklimit) break; } shtml += '
'; // mbgstages $base.html(shtml); }); } function showStartList(sportid) { var results = {}; var sevents; $.getJSON(apibase+'/api/event/'+sportid, function(events) { sevents = events; }).done(function() { let promises = []; for (let anevent of sevents) { promises.push($.getJSON(apibase+'/api/startList/events/'+anevent.id, function(eventstartlist) { //console.log(anevent.id); results[anevent.name] = eventstartlist; })); } $.when.apply($, promises) // $.when() .then(function() { showStartListForSport(results, sportid); }); }); } function showStartListForSport(results, sportid) { let shtml = ''; shtml += '
'; for (eventname in results) { let theid = 'mbgeventstartlist'+eventname.replace(/[' ()]/g, ''); shtml += '
'; shtml += ''; shtml += ''+eventname+''; shtml += ''; let extraclass = ''; if (results[eventname].some(el => el.hasOwnProperty('team_members'))) extraclass = 'mbgteamlist'; shtml += '
'; for (aresult of results[eventname]) { if (aresult.hasOwnProperty('athlete')) { let theathlete = aresult.athlete; shtml += '
'; shtml += '
'; shtml += ''+theathlete.first_name+' '+theathlete.last_name+''; shtml += '
'; // mbgname shtml += '
'; shtml += getCountryFlagImage(theathlete.country.name, theathlete.country.image)+' '+theathlete.country.name+''; shtml += '
'; // mbgflag shtml += '
'; // mbgathleterow } else { let theid = 'mbgeventstartlist'+(eventname + aresult.name).replace(/[' ()]/g, ''); shtml += '
'; shtml += ''; shtml += ''+getCountryFlagImage(aresult.country.name, aresult.country.image)+' '+aresult.name+''; // Country name shtml += ''; shtml += '
'; for (let amember of aresult.team_members) { let theathlete = amember.athlete; shtml += '
'; shtml += '
'; shtml += ''+theathlete.first_name+' '+theathlete.last_name+''; shtml += '
'; // mbgname shtml += '
'; shtml += ''+theathlete.country.name+''; shtml += '
'; // mbgflag shtml += '
'; // mbgathleterow } shtml += '
'; // mbgeventstartlist shtml += '
'; // mbgastage } } shtml += '
'; // mbgeventstartlist shtml += '
'; // mbgastage } shtml += '
'; // mbgstages $base.html(shtml); } function showMedals(sportid) { var results = {}; var sevents; $.getJSON(apibase+'/api/event/'+sportid, function(events) { sevents = events; }).done(function() { let promises = []; for (let anevent of sevents) { promises.push($.getJSON(apibase+'/api/medals/'+anevent.id, function(medalslist) { //console.log(anevent.id); results[anevent.name] = medalslist; })); } $.when.apply($, promises) // $.when() .then(function() { showMedalsForSport(results, sportid); }); }); } function showMedalsForSport(results, sportid) { let shtml = ''; shtml += '
'; for (eventname in results) { let theid = 'mbgeventstartlist'+eventname.replace(/[' ()]/g, ''); shtml += '
'; shtml += ''; shtml += ''+eventname+''; shtml += ''; shtml += '
'; for (aresult of results[eventname]) { let participant = aresult.participant; let name=''; if (participant.hasOwnProperty('team_members') && participant.team_members.length > 0) { let names = []; for (let a of participant.team_members) names.push(a.athlete.first_name+' '+a.athlete.last_name); name = names.join(', '); } else name = participant.first_name+' '+participant.last_name; shtml += '
'; shtml += '
'; shtml += getMedal(aresult.type)+' '+name+''; shtml += '
'; // mbgname shtml += '
'; shtml += getCountryFlagImage(participant.country.name, participant.country.image)+' '+participant.country.name+''; shtml += '
'; // mbgflag shtml += '
'; // mbgathleterow } shtml += '
'; // mbgeventstartlist shtml += '
'; // mbgastage } shtml += '
'; // mbgstages $base.html(shtml); } function showPre() { $.getJSON(apibase+'/api/sports', function(data) { let hash = getHash(); let prehtml = ''; let currentsport = {}; //globalstartdate = data.map(el => el.start_date).reduce((acc, cur) => (acc '+asport.name+''; prehtml += '
'; prehtml += getDiv((selectdate)?'mbgmenuitem active':'mbgmenuitem', 'Schedule'); prehtml += getDiv((hash.startlist)?'mbgmenuitem active':'mbgmenuitem', 'Start List'); prehtml += getDiv((hash.medals)?'mbgmenuitem active':'mbgmenuitem', 'Medals'); prehtml += getDiv('mbgmenuitem', 'Report'); prehtml += '
'; prehtml += '
'; prehtml += ' '; prehtml += ''; prehtml += '
'; if (selectdate) { prehtml += '
'; prehtml += ' '; prehtml += ''; prehtml += '
'; } $basepre.html(prehtml); $('#mbgsportselect').on('change', function () { const sportid = $(this).val(); if (sportid == '') $basepre.html(''); window.location.hash =getSportHREF($(this).val()); }); $('#mbgdateselect').on('change', function () { const datein = $(this).val(); window.location.hash =getDateHREF($(this).val()); }).datepicker({dateFormat: "yy-mm-dd", minDate: new Date(currentsport.start_date), maxDate: new Date(currentsport.end_date)}); }); } function showResults(sportid, matchid, datein) { var results = {}; var sevents; $.getJSON(apibase+'/api/event/'+sportid, function(events) { sevents = events; }).done(function() { let promises = []; let urlappend = ''; if (datein != null && datein != '') urlappend = '?date='+datein; for (let anevent of sevents) { promises.push($.getJSON(apibase+'/api/results/event/'+anevent.id+urlappend, function(eventresults) { results[eventresults.id] = eventresults; })); } $.when.apply($, promises) // $.when() .then(function() { //console.log(results); if (typeof matchid === "undefined" || matchid == '') showStagesForSport(results); else showMatch(results, matchid); }); }); } function showMatch(results, matchid) { var shtml = ''; for (let aneventid in results) { let foundmatch = false; let anevent = results[aneventid]; for (let astage of anevent.event_stages) { if (astage.results.length == 0) continue; for (let aresult of astage.results) { if (aresult.id != matchid) continue; shtml += showMatchResult(aresult, anevent, astage); foundmatch = true; break; } if (foundmatch) break; if (astage.id == matchid) { shtml += showMatchResult(astage.results, anevent, astage); foundmatch = true; break; } } if (foundmatch) break; } $base.html(shtml); } function showMatchResult(aresult, anevent, astage) { let result_kind = anevent.result_kind.split('_')[0]; if (typeof window["showMatch"+result_kind] === "function") return window["showMatch"+result_kind](aresult, anevent, astage); else return 'Not ready yet!'; } function getAthleteTime(timestamp) { if (typeof timestamp == "undefined") return '-'; const wholeseconds = Math.floor(timestamp/1000); const miliseconds = ("0" + timestamp).slice(-3); const hours = Math.floor(wholeseconds/3600); const minutes = Math.floor((wholeseconds - 3600 * hours)/60); const seconds = Math.floor(wholeseconds - 3600 * hours - 60 * minutes); return ("0" + hours).slice(-2)+':'+("0" + minutes).slice(-2)+':'+("0" + seconds).slice(-2)+'.'+miliseconds; } function getAthleteName(participant, team_members_first) { let name=''; let foo = false; if (typeof team_members_first !== "undefined") foo = team_members_first; if (!foo && participant.hasOwnProperty('name')) name = participant.name; else if (participant.hasOwnProperty('team_members') && participant.team_members.length > 0) { let names = []; for (let a of participant.team_members) names.push(a.athlete.first_name+' '+a.athlete.last_name); name = names.join(', '); }else if (foo && participant.hasOwnProperty('name')) name = participant.name; else if (participant.hasOwnProperty('first_name')) name = participant.first_name+' '+participant.last_name; return name; } function showMatchCR(aresult, anevent, astage) { return showMatchAQ(aresult, anevent, astage); } function showMatchFS(aresult, anevent, astage) { return showMatchAQ(aresult, anevent, astage); } function showMatchOS(aresult, anevent, astage) { return showMatchAQ(aresult, anevent, astage); } function showMatchBS(aresult, anevent, astage) { return showMatchBH(aresult, anevent, astage); } function showMatchBT(aresult, anevent, astage) { return showMatchBH(aresult, anevent, astage); } function showMatchBV(aresult, anevent, astage) { return showMatchBH(aresult, anevent, astage); } function showMatchWS(aresult, anevent, astage) { return showMatchAQ(aresult, anevent, astage); } function showMatchBW(aresult, anevent, astage) { return showMatchBH(aresult, anevent, astage); } function showMatchAQ(aresult, anevent, astage) { let result_kind = anevent.result_kind.split('_')[0]; aresult.sort(function(a,b) { if (a.status != "OK" && b.status != "OK") return 0; if (a.status != "OK" && b.status == "OK") return 1; if (a.status == "OK" && b.status != "OK") return -1; if (result_kind == 'WS') return (a.overall > b.overall) ? -1 : 1; if (!a.hasOwnProperty('result_time') || a.result_time == '') return 1; return (a.result_time > b.result_time) ? 1 : -1; }); // Keep oldest when const when = aresult.map(el => el.when).reduce(function (acc, cur) { if (cur el.venue)[0]; // If any athlete has OK status, race is finished and final const hasfinal = aresult.some(function(el) { if (el.status == "OK" && (el.hasOwnProperty('result_time') || el.hasOwnProperty('overall'))) return true; }); const thedate = new Date(when); const thetime = thedate.getHours()+':'+('0'+thedate.getMinutes()).slice(-2); let ret = ''; ret += '
'; ret += '
'+anevent.name+' '+astage.name+'
'; ret += '
'+getWeekDayName(thedate)+', '+thedate.getDate()+' '+getMonthName(thedate)+', '+thetime+'
'; ret += '
'+venue.name+'
'; ret += '
'; if (hasfinal) ret += 'Results'; else ret += 'Athlete List'; ret += '
'; // mbgdetailheader ret += '
'; let i = 1; const sportswithdetail = new Set(['AQ', 'WS']); for (anathlete of aresult) { let theathlete; let athletename; let athlete_type = anathlete.type.split('_')[0]; if (anathlete.hasOwnProperty('athlete')) theathlete = anathlete.athlete; else if (anathlete.hasOwnProperty('participant')) theathlete = anathlete.participant; else continue; if (result_kind == "FS") athletename = getAthleteName(theathlete, true); else athletename = getAthleteName(theathlete); if (sportswithdetail.has(athlete_type)) ret += ''; else ret += '
'; ret += '
'; if (hasfinal && anathlete.status == "OK") ret += i; else if (anathlete.status != "OK") ret += anathlete.status; else ret += '-'; ret += '
'; // mbgdetailtablerank ret += '
'; ret += ''+getVal(anathlete.bib, '-')+''; ret += '
'; // mbgdetailtablebib ret += '
'; ret += getCountryFlagImage(theathlete.country.name, theathlete.country.image); ret += '
'; // mbgdetailtableflag ret += '
'; ret += getAthleteImg(theathlete.image); ret += ''+getVal(athletename)+' '+theathlete.country.name+''; ret += '
'; // mbgdetailtablename ret += '
'; if (result_kind == 'WS') ret += anathlete.overall; else ret += getAthleteTime(anathlete.result_time); ret += '
'; // mbgdetailtableresult ret += '
'; if (sportswithdetail.has(athlete_type)) ret += ''; // mbgdetailtablerow else ret += '
'; ret += '
'; if (athlete_type == 'AQ') { ret += '
'; ret += 'First Run Time: '+getAthleteTime(anathlete.first_run_time)+''; ret += '
'; // mbgdetailathleteinfoline ret += '
'; ret += 'Swim Time: '+getAthleteTime(anathlete.swim_time)+''; ret += '
'; // mbgdetailathleteinfoline ret += '
'; ret += 'Second Run Time: '+getAthleteTime(anathlete.second_run_time)+''; ret += '
'; // mbgdetailathleteinfoline ret += '
'; ret += 'Final Result Time: '+getAthleteTime(anathlete.result_time)+''; ret += '
'; // mbgdetailathleteinfoline } else if (athlete_type == 'WS') { if (anathlete.type == 'WS_WK') { ret += '
'; ret += 'Composition: '+anathlete.composition+''; ret += '
'; // mbgdetailathleteinfoline ret += '
'; ret += 'Execution: '+anathlete.execution+''; ret += '
'; // mbgdetailathleteinfoline ret += '
'; ret += 'Intensity: '+anathlete.intensity+''; ret += '
'; // mbgdetailathleteinfoline ret += '
'; ret += 'Score: '+anathlete.overall+''; ret += '
'; // mbgdetailathleteinfoline } else { ret += '
'; ret += 'Round 1: '+anathlete.round1+''; ret += '
'; // mbgdetailathleteinfoline ret += '
'; ret += 'Round 2: '+anathlete.round2+''; ret += '
'; // mbgdetailathleteinfoline ret += '
'; ret += 'Final: '+anathlete.final+''; ret += '
'; // mbgdetailathleteinfoline ret += '
'; ret += 'Overall: '+anathlete.overall+''; ret += '
'; // mbgdetailathleteinfoline } } ret += '
'; // mbgdetailathlete i++; } ret += '
'; // mbgdetailtable ret += getMatchReports(astage.id, aresult.id); ret += '
'; // mbgdetail // console.log(aresult); return ret; } function showMatchBH(aresult, anevent, astage) { const when = new Date(aresult.when); const thetime = when.getHours()+':'+('0'+when.getMinutes()).slice(-2); if (!aresult.hasOwnProperty('team1') && !aresult.hasOwnProperty('athlete1')) { aresult.team1 = {country: {}, team_members: []}; } if (!aresult.hasOwnProperty('team2') && !aresult.hasOwnProperty('athlete2')) { aresult.team2 = {country: {}, team_members: []}; } if (!aresult.hasOwnProperty('venue')) { aresult.venue = {}; } let ret = ''; let appendtoname = ''; if (aresult.hasOwnProperty('match_id')) appendtoname = ', '+aresult.match_id; let team1 = {}; let team2 = {}; if (aresult.hasOwnProperty('team1')) team1 = aresult.team1; else if (aresult.hasOwnProperty('athlete1')) team1 = aresult.athlete1; if (aresult.hasOwnProperty('team2')) team2 = aresult.team2; else if (aresult.hasOwnProperty('athlete2')) team2 = aresult.athlete2; //ret += aresult.team1.country.name+' - '+aresult.team2.country.name; ret += '
'; ret += '
'+anevent.name+' '+astage.name+appendtoname+'
'; ret += '
'+getWeekDayName(when)+', '+when.getDate()+' '+getMonthName(when)+', '+thetime+'
'; ret += '
'+aresult.venue.name+'
'; ret += '
'; let team1name = getAthleteName(team1); let team2name = getAthleteName(team2); ret += '
'; ret += getCountryFlagImage(team1.country.name, team1.country.image); ret += '
'+getVal(team1name, '')+'
'; ret += '
'; // mbgmatchteam1 ret += '
'; if (aresult.team1_status == "WO" || aresult.team2_status == "WO") ret += aresult.team1_status+' / '+aresult.team2_status; else if (aresult.type == 'BT' || aresult.type == 'BV') { ret += getVal(aresult.team1_sets)+' - '+getVal(aresult.team2_sets); } else if (aresult.type == 'BS') { let team1score, team2score; if (typeof aresult.team1_period1_goals !== "undefined") { team1score = +getVal(aresult.team1_period1_goals) + +getVal(aresult.team1_period2_goals) + +getVal(aresult.team1_period3_goals) + +getVal(aresult.team1_extra_time_goals); team2score = +getVal(aresult.team2_period1_goals) + +getVal(aresult.team2_period2_goals) + +getVal(aresult.team2_period3_goals) + +getVal(aresult.team2_extra_time_goals); } else { team1score = ''; team2score = ''; } ret += getVal(team1score, '')+' - '+getVal(team2score, ''); } else if (aresult.type == 'BW') { ret += getVal(aresult.athlete1_points, '')+' - '+getVal(aresult.athlete2_points, ''); } else ret += getVal(aresult.team1_total_score, '')+' - '+getVal(aresult.team2_total_score, ''); ret += '
'; // mbgmatchresult ret += '
'; ret += getCountryFlagImage(team2.country.name, team2.country.image); ret += '
'+getVal(team2name, '')+'
'; ret += '
'; // mbgmatchteam2 ret += '
'; // mbgmatchscore ret += '
'; if (aresult.type == 'BS') { ret += '
Period 1 score: '+getVal(aresult.team1_period1_goals, '')+' - '+getVal(aresult.team2_period1_goals, '')+'
'; ret += '
Period 2 score: '+getVal(aresult.team1_period2_goals, '')+' - '+getVal(aresult.team2_period2_goals, '')+'
'; ret += '
Period 3 score: '+getVal(aresult.team1_period3_goals, '')+' - '+getVal(aresult.team2_period3_goals, '')+'
'; ret += '
Extra time goals: '+getVal(aresult.team1_extra_time_goals, '')+' - '+getVal(aresult.team2_extra_time_goals, '')+'
'; ret += '
Penalty goals: '+getVal(aresult.team1_penalty_goals, '')+' - '+getVal(aresult.team2_penalty_goals, '')+'
'; } else if (aresult.type == 'BH') { ret += '
Set 1 score: '+getVal(aresult.team1_period1_score, '')+' - '+getVal(aresult.team2_period1_score, '')+'
'; ret += '
Set 2 score: '+getVal(aresult.team1_period2_score, '')+' - '+getVal(aresult.team2_period2_score, '')+'
'; } else if (aresult.type == 'BV') { if (typeof aresult.team1_set1_points != "undefined") ret += '
Set 1 points: '+getVal(aresult.team1_set1_points)+' - '+getVal(aresult.team2_set1_points)+'
'; if (typeof aresult.team1_set2_points != "undefined") ret += '
Set 2 points: '+getVal(aresult.team1_set2_points)+' - '+getVal(aresult.team2_set2_points)+'
'; if (typeof aresult.team1_set3_points != "undefined") ret += '
Set 3 points: '+getVal(aresult.team1_set3_points)+' - '+getVal(aresult.team2_set3_points)+'
'; } ret += '
'; // mbgmatchsetscore if (aresult.type != 'BW') { ret += '
Startlist
'; let teams = [team1, team2]; for (ateam of teams) { ret += '
'+getCountryFlagImage(ateam.country.name, ateam.country.image)+getVal(ateam.name)+'
'; ret += ''; // mbgdetailtable } } ret += getMatchReports(astage.id, aresult.id, aresult.type); ret += '
'; // mbgdetail //console.log(aresult); return ret; } function getAthleteImg(image) { if (typeof image === "undefined") return ''; return 'athlete image'; } function getMatchReports(stageid, matchid, type) { let ret = ''; ret += '
Match Reports
'; ret += ''; // mbgdetailtable return ret; } function showMatchBR(aresult, anevent, astage) { const when = new Date(aresult.when); const thetime = when.getHours()+':'+('0'+when.getMinutes()).slice(-2); let ret = ''; let appendtoname = ''; if (aresult.hasOwnProperty('match_id')) appendtoname = ', '+aresult.match_id; ret += '
'; ret += '
'+anevent.name+' '+astage.name+appendtoname+'
'; ret += '
'+getWeekDayName(when)+', '+when.getDate()+' '+getMonthName(when)+', '+thetime+'
'; ret += '
'+aresult.venue.name+'
'; ret += '
'; let team1 = {country: {}}; let team2 = {country: {}}; let hasfirstteam = true; let hassecondteam = true; let team1name = ''; let team2name = ''; if (aresult.hasOwnProperty('participant1')) team1 = aresult.participant1; else hasfirstteam = false; if (aresult.hasOwnProperty('participant2')) team2 = aresult.participant2; else hassecondteam = false; if (team1.hasOwnProperty('first_name')) team1name = team1.first_name+' '+team1.last_name; else team1name = team1.name; if (hassecondteam) { if (team1.hasOwnProperty('first_name')) team2name = team2.first_name+' '+team2.last_name; else team2name = team2.name; } ret += '
'; ret += getCountryFlagImage(team1.country.name, team1.country.image); ret += '
'+getVal(team1name)+'
'; ret += '
'+getAthleteTime(aresult.result_time1)+'
'; ret += '
'; // mbgmatchteam1 ret += '
'; if (hassecondteam) { ret += getCountryFlagImage(team2.country.name, team2.country.image); ret += '
'+getVal(team2name)+'
'; ret += '
'+getAthleteTime(aresult.result_time2)+'
'; } ret += '
'; // mbgmatchteam2 ret += '
'; // mbgmatchscore if (hasfirstteam) { ret += '
Startlist
'; let teams = [team1, team2]; for (ateam of teams) { ret += '
'+getCountryFlagImage(ateam.country.name, ateam.country.image)+ateam.country.name+'
'; ret += ''; // mbgdetailtable } } ret += getMatchReports(astage.id, aresult.id); ret += '
'; // mbgdetail //console.log(aresult); return ret; } // Give direct link to match details for some sports function getStageLinkAQ(astage) { return getStageLinkDirect(astage); } function getStageLinkCR(astage) { return getStageLinkDirect(astage); } function getStageLinkFS(astage) { return getStageLinkDirect(astage); } function getStageLinkOS(astage) { return getStageLinkDirect(astage); } function getStageLinkWS(astage) { return getStageLinkDirect(astage); } function getStageLinkDirect(astage) { return ''; } function showStagesForSport(results) { let shtml = ''; shtml += ''; // mbgstages $base.html(shtml); } function previewListBS(astage) { return previewListBH(astage); } function previewListBT(astage) { return previewListBH(astage); } function previewListBV(astage) { return previewListBH(astage); } function previewListBW(astage) { return previewListBH(astage); } function previewListBR(astage) { let ret=''; for (let aresult of astage.results) { if (!aresult.hasOwnProperty('participant1')) { aresult.participant1 = {country: {}}; } if (!aresult.hasOwnProperty('venue')) { aresult.venue = {}; } let when = new Date(aresult.when); if (aresult.hasOwnProperty('id')) ret += ''; else ret += '
'; ret += '
'; ret += '
'; ret += getWeekDayName(when)+', '+when.getDate(); ret += '
'; // mbgmatchdatedate ret += '
'; ret += when.getHours()+':'+('0'+when.getMinutes()).slice(-2); ret += '
'; // mbgmatchdatetime ret += '
'; // mbgmatchdate ret += '
'; let team1 = {}; let team2 = {}; let hassecondteam = true; let team1name = ''; let team2name = ''; if (aresult.hasOwnProperty('participant1')) team1 = aresult.participant1; if (aresult.hasOwnProperty('participant2')) team2 = aresult.participant2; else hassecondteam = false; if (team1.hasOwnProperty('first_name')) team1name = team1.first_name+' '+team1.last_name; else team1name = getVal(team1.name, ''); if (hassecondteam) { if (team1.hasOwnProperty('first_name')) team2name = team2.first_name+' '+team2.last_name; else team2name = team2.name; } ret += '
'; ret += aresult.venue.name; ret += '
'; // mbgmatchvenue ret += '
'; ret += getCountryFlagImage(team1.country.name, team1.country.image); ret += '
'+team1name+'
'; ret += '
'+getAthleteTime(aresult.result_time1)+'
'; ret += '
'; // mbgmatchteam1 ret += '
'; if (hassecondteam) { ret += getCountryFlagImage(team2.country.name, team2.country.image); ret += '
'+team2name+'
'; ret += '
'+getAthleteTime(aresult.result_time2)+'
'; } ret += '
'; // mbgmatchteam2 ret += '
'; // mbgmatchscore ret += '
'; if (aresult.hasOwnProperty('id')) ret += ''; // mbgmatch else ret += '
'; // mbgmatch } return ret; } function previewListBH(astage) { let ret=''; for (let aresult of astage.results) { if (!aresult.hasOwnProperty('team1') && !aresult.hasOwnProperty('athlete1')) { aresult.team1 = {country: {}}; } if (!aresult.hasOwnProperty('team2') && !aresult.hasOwnProperty('athlete2')) { aresult.team2 = {country: {}}; } if (!aresult.hasOwnProperty('venue')) { aresult.venue = {}; } let when = new Date(aresult.when); ret += '
'; ret += '
'; ret += '
'; ret += getWeekDayName(when)+', '+when.getDate(); ret += '
'; // mbgmatchdatedate ret += '
'; ret += when.getHours()+':'+('0'+when.getMinutes()).slice(-2); ret += '
'; // mbgmatchdatetime ret += '
'; // mbgmatchdate ret += '
'; let team1 = {}; let team2 = {}; let team1name = ''; let team2name = ''; if (aresult.hasOwnProperty('team1')) team1 = aresult.team1; else team1 = aresult.athlete1; if (aresult.hasOwnProperty('team2')) team2 = aresult.team2; else team2 = aresult.athlete2; if (team1.hasOwnProperty('first_name')) team1name = team1.first_name+' '+team1.last_name; else team1name = getVal(team1.name, ''); if (team2.hasOwnProperty('first_name')) team2name = team2.first_name+' '+team2.last_name; else team2name = getVal(team2.name, ''); ret += '
'; ret += aresult.venue.name; ret += '
'; // mbgmatchvenue ret += '
'; ret += getCountryFlagImage(team1.country.name, team1.country.image); ret += '
'+team1name+'
'; ret += '
'; // mbgmatchteam1 ret += '
'; if (aresult.team1_status == "WO" || aresult.team2_status == "WO") ret += aresult.team1_status+' / '+aresult.team2_status; else if (aresult.type == 'BT' || aresult.type == 'BV') ret += getVal(aresult.team1_sets)+' - '+getVal(aresult.team2_sets); else if (aresult.type == 'BW') ret += getVal(aresult.athlete1_points)+' - '+getVal(aresult.athlete2_points); else if (aresult.type == 'BS') { let team1score, team2score; if (typeof aresult.team1_period1_goals !== "undefined") { team1score = +getVal(aresult.team1_period1_goals) + +getVal(aresult.team1_period2_goals) + +getVal(aresult.team1_period3_goals) + +getVal(aresult.team1_extra_time_goals); team2score = +getVal(aresult.team2_period1_goals) + +getVal(aresult.team2_period2_goals) + +getVal(aresult.team2_period3_goals) + +getVal(aresult.team2_extra_time_goals); } else { team1score = ''; team2score = ''; } ret += getVal(team1score)+' - '+getVal(team2score); } else ret += getVal(aresult.team1_total_score, '')+' - '+getVal(aresult.team2_total_score, ''); ret += '
'; // mbgmatchresult ret += '
'; ret += getCountryFlagImage(team2.country.name, team2.country.image); ret += '
'+team2name+'
'; ret += '
'; // mbgmatchteam2 ret += '
'; // mbgmatchscore ret += '
'; ret += '
'; // mbgmatch } return ret; } function showSchedule() { $basepre.html('

Schedule

'); $.getJSON(apibase+'/api/sports', function(data) { let sports = {}; let globaldates = {}; let currentyear; let medaldatesbysport = { 1: {7: {31: 6}}, 2: {7: {28: 3}}, 3: {7: {26: 1, 27: 2, 28: 3}}, 4: {7: {28: 3}}, 5: {7: {29: 4}}, 6: {7: {27: 2}}, 7: {7: {31: 6}}, 8: {7: {27: 2}}, 9: {7: {30: 5}}, 10: {7: {30: 5, 31: 6}}, 11: {7: {31: 6}} }; $.each(data, function (index, asport) { let venues = []; /* $.each(asport.venues, function (venue){ venues.push(venue.name); }); asport.venues.forEach(function(avenue, i) { venues.push(avenue.name); }); */ for (let i in asport.venues) venues.push(getVenueLink(asport.venues[i].id, asport.venues[i].name)); asport.venuenames = venues; let start_date = new Date(asport.start_date); let end_date = new Date(asport.end_date); currentyear = start_date.getFullYear(); let dates = {}; // month: {date: weekday} for (let i = start_date.getMonth(); i i) lastday = new Date(start_date.getFullYear(), i + 1, 0).getDate(); else lastday = end_date.getDate(); if (start_date.getMonth() '; shtml += '
'; shtml += '
EVENT
'; for (let month in globaldates) for (let monthdate in globaldates[month]) { shtml += '
'; shtml += '
'+monthdate+'
'+globaldates[month][monthdate]+'
'; shtml += '
'; } shtml += '
'; // mbgfirstrow shtml += '
'; for (let sportnum in sports) { shtml += '
'; shtml += '
'; // Icon shtml += '
'+getSportIcon(sports[sportnum].code)+'
'; // Sport name FIXME: needs link to event shtml += '
'+getSportLink(sports[sportnum].id, sports[sportnum].name)+'
'; // Venue shtml += '
'+sports[sportnum].venuenames.join(', ')+'
'; shtml += '
'; // mbgsport shtml += '
'; for (let month in globaldates) for (let monthdate in globaldates[month]) { let monthforlink = ('0' + (parseInt(month)+1)).slice(-2); let monthdateforlink = ('0' + monthdate).slice(-2); let dateforlink = currentyear+'-'+monthforlink+'-'+monthdateforlink; let inside = ''; let sdates = sports[sportnum].dates; if (sdates.hasOwnProperty(month) && sdates[month].hasOwnProperty(monthdate)) inside = ' '; let extraclass = ''; let smedaldates = sports[sportnum].medaldates; if (smedaldates.hasOwnProperty(month) && smedaldates[month].hasOwnProperty(monthdate)) extraclass = ' hasmedal'; shtml += '
'+inside+'
'; } shtml += '
'; // mbgsportdates shtml += '
'; shtml += '
'; // mbgrow } shtml += '
'; // mbgbody shtml += ''; // mbgschedule $base.html(shtml); }); } } $('.am_2530 .theitems').slick({autoplay: false, autoplaySpeed: 5000, speed: 1000, pauseOnHover: true, dots: true, arrows: true, slidesToShow: 5.2, slidesToScroll: 5, infinite: false, rows: 1, slide: 'div.item', responsive: [{breakpoint: 768, settings: {slidesToShow: 1.1, slidesToScroll: 1, arrows: false}}]}); $('.am_2530 .theitems').imagesLoaded().progress(function () {$('.am_2530 .theitems').slick('setPosition');}); $('.am_2867 .theitems').slick({autoplay: false, autoplaySpeed: 5000, speed: 1000, pauseOnHover: true, dots: true, arrows: true, slidesToShow: 5.2, slidesToScroll: 5, infinite: false, rows: 1, slide: 'div.item', responsive: [{breakpoint: 768, settings: {slidesToShow: 1.1, slidesToScroll: 1, arrows: false}}]}); $('.am_2867 .theitems').imagesLoaded().progress(function () {$('.am_2867 .theitems').slick('setPosition');}); $('.am_1552 .theitems').slick({autoplay: false, autoplaySpeed: 5000, speed: 1000, pauseOnHover: true, dots: false, arrows: true, slidesToShow: 4.2, slidesToScroll: 4, infinite: false, rows: 1, slide: 'div.item', responsive: [{breakpoint: 768, settings: {slidesToShow: 1.1, slidesToScroll: 1, arrows: false}}]}); $('.am_1552 .theitems').imagesLoaded().progress(function () {$('.am_1552 .theitems').slick('setPosition');}); $('.am_2515 .theitems').slick({autoplay: false, autoplaySpeed: 5000, speed: 1000, pauseOnHover: true, dots: false, arrows: true, slidesToShow: 4.2, slidesToScroll: 1, infinite: false, rows: 1, slide: 'div.item', responsive: [{breakpoint: 768, settings: {slidesToShow: 1.1, slidesToScroll: 1, arrows: false}}]}); $('.am_2515 .theitems').imagesLoaded().progress(function () {$('.am_2515 .theitems').slick('setPosition');}); $('.am_2401 .theitems').slick({autoplay: false, autoplaySpeed: 5000, speed: 1000, pauseOnHover: true, dots: false, arrows: true, slidesToShow: 1.2, slidesToScroll: 1, infinite: false, rows: 1, slide: 'div.theitemsgroup', responsive: [{breakpoint: 768, settings: {slidesToShow: 1.1, slidesToScroll: 1, arrows: false}}]}); $('.am_2401 .theitems').imagesLoaded().progress(function () {$('.am_2401 .theitems').slick('setPosition');}); var grid = $('.am_2401 .theitemsgroup').masonry({itemSelector: '.item', columnWidth: '.itemsizer', percentPosition: true});grid.imagesLoaded().progress(function(){grid.masonry('layout');});$('.am_2588 .theitems').slick({autoplay: false, autoplaySpeed: 5000, speed: 1000, pauseOnHover: true, dots: false, arrows: true, slidesToShow: 5.2, slidesToScroll: 5, infinite: false, rows: 1, slide: 'div.item', responsive: [{breakpoint: 768, settings: {slidesToShow: 1.1, slidesToScroll: 1, arrows: false}}]}); $('.am_2588 .theitems').imagesLoaded().progress(function () {$('.am_2588 .theitems').slick('setPosition');}); function getTimeRemaining(endtime) { var t = Date.parse(endtime) - Date.parse(new Date()); var seconds = Math.floor((t / 1000) % 60); var minutes = Math.floor((t / 1000 / 60) % 60); var hours = Math.floor((t / (1000 * 60 * 60)) % 24); var days = Math.floor(t / (1000 * 60 * 60 * 24)); return { 'total': t, 'days': days, 'hours': hours, 'minutes': minutes, 'seconds': seconds }; } function initializeClock(id, endtime) { var clock = document.getElementById(id); if (!clock) return; var daysSpan = clock.querySelector('.days'); var hoursSpan = clock.querySelector('.hours'); var minutesSpan = clock.querySelector('.minutes'); var secondsSpan = clock.querySelector('.seconds'); function updateClock() { var t = getTimeRemaining("Aug 25, 2019 20:30:00"); daysSpan.innerHTML = t.days; hoursSpan.innerHTML = ('0' + t.hours).slice(-2); minutesSpan.innerHTML = ('0' + t.minutes).slice(-2); secondsSpan.innerHTML = ('0' + t.seconds).slice(-2); if (t.total 0) $(elm).css({'margin-left': -(w - docW + l)}); else $(this).addClass('edgeright'); } if (!isVertVisible) $(this).addClass('edgebottom'); }); $(".am_121 li").on('mouseenter', function (e) {var elm = $('ul:first', this); if (elm.length === 0) return; var off = elm.offset(); var l = off.left; var t = off.top; var w = elm.outerWidth(); var h = elm.height(); var docW = $("body").width(); var docH = $(window).height(); var siteW = $("#thewhole").outerWidth(); var isHorizVisible = (l + w 0) $(elm).css({'margin-left': -(w - docW + l)}); else $(this).addClass('edgeright'); } if (!isVertVisible) $(this).addClass('edgebottom'); }); $(".am_1912 li").on('mouseenter', function (e) {var elm = $('ul:first', this); if (elm.length === 0) return; var off = elm.offset(); var l = off.left; var t = off.top; var w = elm.outerWidth(); var h = elm.height(); var docW = $("body").width(); var docH = $(window).height(); var siteW = $("#thewhole").outerWidth(); var isHorizVisible = (l + w 0) $(elm).css({'margin-left': -(w - docW + l)}); else $(this).addClass('edgeright'); } if (!isVertVisible) $(this).addClass('edgebottom'); }); $(".am_1930 li").on('mouseenter', function (e) {var elm = $('ul:first', this); if (elm.length === 0) return; var off = elm.offset(); var l = off.left; var t = off.top; var w = elm.outerWidth(); var h = elm.height(); var docW = $("body").width(); var docH = $(window).height(); var siteW = $("#thewhole").outerWidth(); var isHorizVisible = (l + w 0) $(elm).css({'margin-left': -(w - docW + l)}); else $(this).addClass('edgeright'); } if (!isVertVisible) $(this).addClass('edgebottom'); }); $(".am_1545 li").on('mouseenter', function (e) {var elm = $('ul:first', this); if (elm.length === 0) return; var off = elm.offset(); var l = off.left; var t = off.top; var w = elm.outerWidth(); var h = elm.height(); var docW = $("body").width(); var docH = $(window).height(); var siteW = $("#thewhole").outerWidth(); var isHorizVisible = (l + w 0) $(elm).css({'margin-left': -(w - docW + l)}); else $(this).addClass('edgeright'); } if (!isVertVisible) $(this).addClass('edgebottom'); });