You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
1.5 KiB
1 line
1.5 KiB
$(document).ready(function(){function e(e){try{if(e.error)throw new Error("Could not authorize user.");var a=GlobalVariables.providerData,t=GlobalVariables.appointmentData,o={summary:GlobalVariables.serviceData.name,location:GlobalVariables.companyName,start:{dateTime:moment.tz(t.start_datetime,a.timezone).format()},end:{dateTime:moment.tz(t.end_datetime,a.timezone).format()},attendees:[{email:GlobalVariables.providerData.email,displayName:GlobalVariables.providerData.first_name+" "+GlobalVariables.providerData.last_name}]};gapi.client.load("calendar","v3",function(){gapi.client.calendar.events.insert({calendarId:"primary",resource:o}).execute(function(e){if(e.error)throw new Error("Could not add the event to Google Calendar.");$("#success-frame").append($("<br/>"),$("<div/>",{class:"alert alert-success col-xs-12",html:[$("<h4/>",{text:EALang.success}),$("<p/>",{text:EALang.appointment_added_to_google_calendar}),$("<a/>",{href:e.htmlLink,text:EALang.view_appointment_in_google_calendar})]})),$("#add-to-google-calendar").hide()})})}catch(e){$("#success-frame").append($("<br/>"),$("<div/>",{class:"alert alert-danger col-xs-12",html:[$("<h4/>",{text:EALang.oops_something_went_wrong}),$("<p/>",{text:EALang.could_not_add_to_google_calendar}),$("<pre/>",{text:e.message})]}))}}$("#add-to-google-calendar").on("click",function(){gapi.client.setApiKey(GlobalVariables.googleApiKey),gapi.auth.authorize({client_id:GlobalVariables.googleClientId,scope:GlobalVariables.googleApiScope,immediate:!1},e)})}); |