From a54bf7aa23944e8007ecbc2f8b8300dccd329f9f Mon Sep 17 00:00:00 2001 From: Leonie Zorzi Date: Fri, 13 Sep 2019 14:13:18 +0100 Subject: [PATCH] Adds google calendar link --- public/js/finalPage.js | 32 +++++++++++++++++++------------- src/views/final.hbs | 5 +++-- src/views/layouts/main.hbs | 2 -- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/public/js/finalPage.js b/public/js/finalPage.js index 76641b6..6891ed8 100644 --- a/public/js/finalPage.js +++ b/public/js/finalPage.js @@ -1,22 +1,19 @@ -// const friend = "Bryan"; +friend = "Bryan"; -// Google Calendar +// Calendar +const linkGoogleCalendar = document.querySelector(".link-calendar-google"); +const linkOutlookCalendar = document.querySelector(".link-calendar-outlook"); -const linkCalendar = document.querySelector(".link-calendar"); - -let calendarTitle = `Meeting ${friend}`; +// url encoded name of the event: +let calendarTitle = `Meeting+${friend}`; +//dates in IOS format let startTime = "20190913T193000Z"; let endTime = "20190913T223000Z"; -let venue = "North%20Pole"; - -linkCalendar.href = `http://www.google.com/calendar/render? -action=TEMPLATE -&text=${calendarTitle} -&dates=${startTime}/${endTime} -&location=${venue}`; +//url encoded location of the event: +let venue = "North+Pole"; +let GoogleCalendarHref = `https://calendar.google.com/calendar/r/eventedit?text=${calendarTitle}&dates=${startTime}/${endTime}&location=${venue}`; // Citymapper Route - const linkCitymapper = document.querySelector(".link-citymapper"); let startLat = "51.41828"; @@ -25,5 +22,14 @@ let endLat = "51.537060"; let endLon = "0.079179"; let endName = "The%20Proud%20Archivist"; let arrivalTime = "2016-08-06T21%3A00%2B01%3A00"; +let cityMapperHref = `https://citymapper.com/directions?startcoord=${startLat}%2C${startLon}&endcoord=${endLat}%2C${endLon}&endname=${endName}&arrival_time=${arrivalTime}`; linkCitymapper.href = `https://citymapper.com/directions?startcoord=${startLat}%2C${startLon}&endcoord=${endLat}%2C${endLon}&endname=${endName}&arrival_time=${arrivalTime}`; + +const setURL = (domElement, url) => { + domElement.href = url; +}; + +console.log(linkCitymapper); +setURL(linkCitymapper, cityMapperHref); +setURL(linkGoogleCalendar, GoogleCalendarHref); diff --git a/src/views/final.hbs b/src/views/final.hbs index 929a1fd..def6fc5 100644 --- a/src/views/final.hbs +++ b/src/views/final.hbs @@ -10,8 +10,9 @@

- Add to my calendar - Add to my Google calendar + + Get directions with Citymapper \ No newline at end of file diff --git a/src/views/layouts/main.hbs b/src/views/layouts/main.hbs index c650ec5..3e0b801 100644 --- a/src/views/layouts/main.hbs +++ b/src/views/layouts/main.hbs @@ -10,8 +10,6 @@ {{!-- jsPath is provided as context when page is rendered --}} - -