Как отобразить все события из нескольких календарей Google - PullRequest
0 голосов
/ 09 апреля 2019

У меня есть два календаря с событиями, и я хочу получать оба события одновременно и отображать их в соответствии с отсортированной датой и временем (с указанием дня в словах)

Я уже использую этот метод JavaScript для отображенияодин календарь, и теперь у меня есть два календаря, поэтому я хочу объединить и отобразить:

calendar1= "https://www.googleapis.com/calendar/v3/calendars/<?php echo $cal_id1; ?>/events?key=<?php echo $apikey1; ?>";
calendar2= "https://www.googleapis.com/calendar/v3/calendars/<?php echo $cal_id2; ?>/events?key=<?php echo $apikey2; ?>";

formatGoogleCalendar.init({
        calendarUrl:calendar1,calendar2,
        past: false,
        upcoming: true,
        pastTopN: 5,
        upcomingTopN: 7,
        itemsTagName: 'li',
        upcomingSelector: '#events-upcoming',
        pastSelector: '#events-past',
        upcomingHeading: '<div id="myDIV" class="header"><font style="float:left;">&nbsp;&nbsp;'+digitdt+'&nbsp;&nbsp;&nbsp;&nbsp;</font><h2 style="margin:5px">Upcoming To Do List<font style="float:right; font-family:Digital-7; font-size:28pt;">&nbsp;&nbsp;&nbsp;&nbsp;Time&nbsp;'+digitxt+'</font></h2></div>',
        pastHeading: '',
        format: ['<font style="color:#f44336; font-weight: bold; font-size: 28pt;">☞</font>&nbsp;&nbsp;<strong>', '*date*', '</strong>:<br>&nbsp;&nbsp;&nbsp;&nbsp; ', '*summary*', ' &mdash; ', '*description*', ' in ', '*location*']
      }); 

Могу ли я передать 2 календарных URL-адреса и отобразить их так?calendarUrl: calendar1, calendar2, пожалуйста, помогите.Спасибо.

1 Ответ

0 голосов
/ 11 апреля 2019

Наконец, я нашел решение объединить несколько календарей простым способом и получить все события в одном представлении в соответствии с датой / временем.Ниже приведен код, который я использовал.

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="FormatGoogleCalendar-master/dist/format-google-calendar.js"></script>
<!-- FormatGoogleCalendar Javascript file -->
<script src="FormatGoogleCalendar-master/dist/format-google-calendar.min.js"></script>

<script>  

//declare calendar urls with calendar id and api key
var calender1 = "https://www.googleapis.com/calendar/v3/calendars/$cal_id/events?key=$apikey";


var calender2 = "https://www.googleapis.com/calendar/v3/calendars/$cal_id/events?key=$apikey";


//store the calendar urls in an array


var cals = [calender1,calender2];


var CAL_ID ="";

//loop through and get each calendar urls


for (j = 0; j < cals.length; j++) {  


    CAL_ID = cals[j];            


      formatGoogleCalendar.init({
        calendarUrl:CAL_ID,
        past: false,
        upcoming: true,
        pastTopN: 0,
        upcomingTopN: 10,
        itemsTagName: 'li',
        upcomingSelector: '#events-upcoming',
        pastSelector: '#events-past',
        upcomingHeading: 'Upcoming Events',
        pastHeading: '',
        format: ['<font style="color:#f44336; font-weight: bold; font-size: 28pt;">☞</font>&nbsp;&nbsp;<strong>', '*date*', '</strong>:<br>&nbsp;&nbsp;&nbsp;&nbsp; ', '*summary*', ' &mdash; ', '*description*', ' in ', '*location*']
      }); 
}
  </script>

Надеюсь, что это может помочь и другим.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...