// Call this from the developer console and you can control both instances var clndr = {}; $(document).ready( function() { //Version française moment.locale('fr', { months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'), monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'), monthsParseExact : true, weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'), weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'), weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'), weekdaysParseExact : true, longDateFormat : { LT : 'HH:mm', LTS : 'HH:mm:ss', L : 'DD/MM/YYYY', LL : 'D MMMM YYYY', LLL : 'D MMMM YYYY HH:mm', LLLL : 'dddd D MMMM YYYY HH:mm' }, calendar : { sameDay : '[Aujourd’hui à] LT', nextDay : '[Demain à] LT', nextWeek : 'dddd [à] LT', lastDay : '[Hier à] LT', lastWeek : 'dddd [dernier à] LT', sameElse : 'L' }, relativeTime : { future : 'dans %s', past : 'il y a %s', s : 'quelques secondes', m : 'une minute', mm : '%d minutes', h : 'une heure', hh : '%d heures', d : 'un jour', dd : '%d jours', M : 'un mois', MM : '%d mois', y : 'un an', yy : '%d ans' }, dayOfMonthOrdinalParse : /\d{1,2}(er|e)/, ordinal : function (number) { return number + (number === 1 ? 'er' : 'e'); }, meridiemParse : /PD|MD/, isPM : function (input) { return input.charAt(0) === 'M'; }, // In case the meridiem units are not separated around 12, then implement // this function (look at locale/id.js for an example). // meridiemHour : function (hour, meridiem) { // return /* 0-23 hour, given meridiem token and hour 1-12 */ ; // }, meridiem : function (hours, minutes, isLower) { return hours < 12 ? 'PD' : 'MD'; }, week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. } }); // PARDON ME while I do a little magic to keep these events relevant for the rest of time... var currentMonth = moment().format('YYYY-MM'); var nextMonth = moment().add('month', 1).format('YYYY-MM'); var events = [ { date: '2024-04-03', url: 'https://grand-rond.org/programmation/2024-04-03' },{ date: '2024-04-04', url: 'https://grand-rond.org/programmation/2024-04-04' },{ date: '2024-04-05', url: 'https://grand-rond.org/programmation/2024-04-05' },{ date: '2024-04-06', url: 'https://grand-rond.org/programmation/2024-04-06' },{ date: '2024-04-10', url: 'https://grand-rond.org/programmation/2024-04-10' },{ date: '2024-04-11', url: 'https://grand-rond.org/programmation/2024-04-11' },{ date: '2024-04-12', url: 'https://grand-rond.org/programmation/2024-04-12' },{ date: '2024-04-13', url: 'https://grand-rond.org/programmation/2024-04-13' },{ date: '2024-04-17', url: 'https://grand-rond.org/programmation/2024-04-17' },{ date: '2024-04-18', url: 'https://grand-rond.org/programmation/2024-04-18' },{ date: '2024-04-19', url: 'https://grand-rond.org/programmation/2024-04-19' },{ date: '2024-04-20', url: 'https://grand-rond.org/programmation/2024-04-20' },{ date: '2024-04-24', url: 'https://grand-rond.org/programmation/2024-04-24' },{ date: '2024-04-25', url: 'https://grand-rond.org/programmation/2024-04-25' },{ date: '2024-04-26', url: 'https://grand-rond.org/programmation/2024-04-26' },{ date: '2024-04-27', url: 'https://grand-rond.org/programmation/2024-04-27' },{ date: '2024-04-29', url: 'https://grand-rond.org/programmation/2024-04-29' } ]; $('#mini-clndr').clndr({ template: $('#mini-clndr-template').html(), startWithMonth: '2024-04-27', today: moment('2017-09-15'), selectedDate: '2024-04-27', weekOffset: 0, weekdaysMin: 1, events: events, clickEvents: { click: function(target) { $('.'+target.element.classList[3]).attr('href', target.events[0].url); }, onMonthChange: function(month) { // go get some new data $.ajax({ dataType: 'json', url: 'https://grand-rond.org/events', data: { month: month.format('MM'), year: month.format('YYYY') }, success: function(response, statut) { console.log('OK'); // add the new events to clndr. // this will call `render` for us. console.log(response); $('#mini-clndr').clndr().addEvents(response); }, error: function(response, statut) { console.log('ERROR'); } }); } }, adjacentDaysChangeMonth: true, forceSixRows: true }); });