Last active
August 28, 2018 19:12
-
-
Save martindrapeau/09128bab2bb6edcfea030e2a18e23f15 to your computer and use it in GitHub Desktop.
Code HTML pour afficher les cours à la carte aujourd'hui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
jQuery(document).ready(function() { | |
$.get('https://www.amilia.com/PublicApi/sports-montreal/fr/Events') | |
.done(function(data) { | |
var $tbody = $('#amilia-events-calendar table tbody'); | |
$tbody.empty(); | |
if (typeof data != 'object') return; | |
if (data.length == 0) { | |
$tbody.append("<tr><td>Acune activité aujourd'hui</td></tr>"); | |
return; | |
} | |
var programIds = []; | |
var programs = []; | |
data.forEach(function(event) { | |
if (event.Price !== null && event.ProgramId != 29617) { | |
var location = (event.Location || '').split('|')[0].trim(); | |
var time = event.start.match('T([0-9][0-9]:[0-9][0-9])')[1]; | |
$tbody.append('<tr><td><a href="' + event.url + '">' + event.title + '</a><br/>' + location + ' | ' + time + '</td></tr>'); | |
if (programIds.indexOf(event.ProgramId) === -1) { | |
programIds.push(event.ProgramId); | |
programs.push({ | |
name: event.ProgramName, | |
url: 'https://www.amilia.com/store/fr/sports-montreal/shop/programs/calendar/' + event.ProgramId + '?view=basicWeek&scrollToCalendar=true' | |
}); | |
} | |
} | |
}); | |
if (programs.length) { | |
$tbody.append('<tr><td>Voire tous les cours de la semaine.</td></tr>'); | |
programs.forEach(function(program) { | |
$tbody.append('<tr><td>' + svg + '<a href="' + program.url + '">' + program.name + '</a></td></tr>'); | |
}); | |
} | |
}); | |
var svg = '<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="svg-inline--fa fa-calendar-alt fa-w-14"><path fill="currentColor" d="M148 288h-40c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12zm108-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm-96 96v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm-96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm192 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96-260v352c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V112c0-26.5 21.5-48 48-48h48V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h128V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h48c26.5 0 48 21.5 48 48zm-48 346V160H48v298c0 3.3 2.7 6 6 6h340c3.3 0 6-2.7 6-6z" class=""></path></svg>'; | |
}); | |
</script> | |
<style> | |
#amilia-events-calendar td { | |
padding: 5px 0; | |
} | |
#amilia-events-calendar td svg { | |
height: 14px; | |
padding: 0 5px; | |
color: #333; | |
} | |
#amilia-events-calendar td a { | |
vertical-align: top; | |
} | |
</style> | |
<div id="amilia-events-calendar"> | |
<h2>Cours à la carte aujourd'hui</h2> | |
<table> | |
<tbody> | |
<tr> | |
<td>Activité</td> | |
</tr> | |
</tbody> | |
</table> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rendu visuel:
