mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-26 01:43:06 +03:00
Enhancements in the fronted_book_success.js comments.
This commit is contained in:
parent
94a66cffad
commit
9451637484
1 changed files with 40 additions and 40 deletions
|
@ -13,25 +13,26 @@ $(document).ready(function() {
|
||||||
/**
|
/**
|
||||||
* Event: Add Appointment to Google Calendar "Click"
|
* Event: Add Appointment to Google Calendar "Click"
|
||||||
*
|
*
|
||||||
* This event handler adds the appointment to the users Google
|
* This event handler adds the appointment to the users Google Calendar Account. The event is going to
|
||||||
* Calendar Account. The event is going to be added to the "primary"
|
* be added to the "primary" calendar. In order to use the API the javascript client library provided by
|
||||||
* calendar. In order to use the API the javascript client library
|
* Google is necessary.
|
||||||
* provided by Google is necessary.
|
|
||||||
*/
|
*/
|
||||||
$('#add-to-google-calendar').click(function() {
|
$('#add-to-google-calendar').click(function() {
|
||||||
gapi.client.setApiKey(GlobalVariables.googleApiKey);
|
gapi.client.setApiKey(GlobalVariables.googleApiKey);
|
||||||
gapi.auth.authorize({
|
gapi.auth.authorize({
|
||||||
'client_id' : GlobalVariables.googleClientId,
|
client_id: GlobalVariables.googleClientId,
|
||||||
'scope' : GlobalVariables.googleApiScope,
|
scope: GlobalVariables.googleApiScope,
|
||||||
'immediate' : false
|
immediate: false
|
||||||
}, handleAuthResult);
|
}, handleAuthResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method handles the authorization result. If the user granted access
|
* Handle Authorization Result
|
||||||
* to his data, then the appointment is going to be added to his calendar.
|
|
||||||
*
|
*
|
||||||
* @param {bool} authResult The user's auth result.
|
* This method handles the authorization result. If the user granted access to his data, then the
|
||||||
|
* appointment is going to be added to his calendar.
|
||||||
|
*
|
||||||
|
* @param {Boolean} authResult The user's authorization result.
|
||||||
*/
|
*/
|
||||||
function handleAuthResult(authResult) {
|
function handleAuthResult(authResult) {
|
||||||
try {
|
try {
|
||||||
|
@ -53,18 +54,18 @@ $(document).ready(function() {
|
||||||
|
|
||||||
// Create a valid Google Calendar API resource for the new event.
|
// Create a valid Google Calendar API resource for the new event.
|
||||||
var resource = {
|
var resource = {
|
||||||
'summary' : GlobalVariables.serviceData['name'],
|
summary: GlobalVariables.serviceData['name'],
|
||||||
'location' : GlobalVariables.companyName,
|
location: GlobalVariables.companyName,
|
||||||
'start' : {
|
start: {
|
||||||
'dateTime': appointmentData['start_datetime']
|
dateTime: appointmentData['start_datetime']
|
||||||
},
|
},
|
||||||
'end' : {
|
end: {
|
||||||
'dateTime': appointmentData['end_datetime']
|
dateTime: appointmentData['end_datetime']
|
||||||
},
|
},
|
||||||
'attendees' : [
|
attendees: [
|
||||||
{
|
{
|
||||||
'email' : GlobalVariables.providerData['email'],
|
email: GlobalVariables.providerData['email'],
|
||||||
'displayName' : GlobalVariables.providerData['first_name'] + ' '
|
displayName: GlobalVariables.providerData['first_name'] + ' '
|
||||||
+ GlobalVariables.providerData['last_name']
|
+ GlobalVariables.providerData['last_name']
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -72,12 +73,15 @@ $(document).ready(function() {
|
||||||
|
|
||||||
gapi.client.load('calendar', 'v3', function() {
|
gapi.client.load('calendar', 'v3', function() {
|
||||||
var request = gapi.client.calendar.events.insert({
|
var request = gapi.client.calendar.events.insert({
|
||||||
'calendarId' : 'primary',
|
calendarId: 'primary',
|
||||||
'resource' : resource
|
resource: resource
|
||||||
});
|
});
|
||||||
|
|
||||||
request.execute(function(response) {
|
request.execute(function(response) {
|
||||||
if (!response.error) {
|
if (response.error) {
|
||||||
|
throw 'Could not add the event to Google Calendar.';
|
||||||
|
}
|
||||||
|
|
||||||
$('#success-frame').append(
|
$('#success-frame').append(
|
||||||
'<br><br>' +
|
'<br><br>' +
|
||||||
'<div class="alert alert-success col-xs-12">' +
|
'<div class="alert alert-success col-xs-12">' +
|
||||||
|
@ -92,14 +96,10 @@ $(document).ready(function() {
|
||||||
'</div>'
|
'</div>'
|
||||||
);
|
);
|
||||||
$('#add-to-google-calendar').hide();
|
$('#add-to-google-calendar').hide();
|
||||||
} else {
|
|
||||||
throw 'Could not add the event to Google Calendar.';
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch(exc) {
|
} catch(exc) {
|
||||||
// The user denied access or something else happened, display
|
// The user denied access or something else happened, display corresponding message on the screen.
|
||||||
// corresponding message on the screen.
|
|
||||||
$('#success-frame').append(
|
$('#success-frame').append(
|
||||||
'<div class="alert alert-danger col-xs-12">' +
|
'<div class="alert alert-danger col-xs-12">' +
|
||||||
'<h4>' + EALang['oops_something_went_wrong'] + '</h4>' +
|
'<h4>' + EALang['oops_something_went_wrong'] + '</h4>' +
|
||||||
|
|
Loading…
Reference in a new issue