From 9451637484aa4f95f7bf4a88d6025b8abbdd203a Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 14 May 2016 12:16:11 +0200 Subject: [PATCH] Enhancements in the fronted_book_success.js comments. --- src/assets/js/frontend_book_success.js | 80 +++++++++++++------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/assets/js/frontend_book_success.js b/src/assets/js/frontend_book_success.js index 1024a019..6d0b0b2d 100644 --- a/src/assets/js/frontend_book_success.js +++ b/src/assets/js/frontend_book_success.js @@ -13,25 +13,26 @@ $(document).ready(function() { /** * Event: Add Appointment to Google Calendar "Click" * - * This event handler adds the appointment to the users Google - * Calendar Account. The event is going to be added to the "primary" - * calendar. In order to use the API the javascript client library - * provided by Google is necessary. + * This event handler adds the appointment to the users Google Calendar Account. The event is going to + * be added to the "primary" calendar. In order to use the API the javascript client library provided by + * Google is necessary. */ $('#add-to-google-calendar').click(function() { gapi.client.setApiKey(GlobalVariables.googleApiKey); gapi.auth.authorize({ - 'client_id' : GlobalVariables.googleClientId, - 'scope' : GlobalVariables.googleApiScope, - 'immediate' : false + client_id: GlobalVariables.googleClientId, + scope: GlobalVariables.googleApiScope, + immediate: false }, handleAuthResult); }); /** - * 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. + * Handle Authorization Result * - * @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) { try { @@ -53,53 +54,52 @@ $(document).ready(function() { // Create a valid Google Calendar API resource for the new event. var resource = { - 'summary' : GlobalVariables.serviceData['name'], - 'location' : GlobalVariables.companyName, - 'start' : { - 'dateTime': appointmentData['start_datetime'] + summary: GlobalVariables.serviceData['name'], + location: GlobalVariables.companyName, + start: { + dateTime: appointmentData['start_datetime'] }, - 'end' : { - 'dateTime': appointmentData['end_datetime'] + end: { + dateTime: appointmentData['end_datetime'] }, - 'attendees' : [ + attendees: [ { - 'email' : GlobalVariables.providerData['email'], - 'displayName' : GlobalVariables.providerData['first_name'] + ' ' - + GlobalVariables.providerData['last_name'] + email: GlobalVariables.providerData['email'], + displayName: GlobalVariables.providerData['first_name'] + ' ' + + GlobalVariables.providerData['last_name'] } ] }; gapi.client.load('calendar', 'v3', function() { var request = gapi.client.calendar.events.insert({ - 'calendarId' : 'primary', - 'resource' : resource + calendarId: 'primary', + resource: resource }); request.execute(function(response) { - if (!response.error) { - $('#success-frame').append( - '

' + - '
' + - '

' + EALang['success'] + '

' + - '

' + - EALang['appointment_added_to_google_calendar'] + - '
' + - '' + - EALang['view_appointment_in_google_calendar'] + - '' + - '

' + - '
' - ); - $('#add-to-google-calendar').hide(); - } else { + if (response.error) { throw 'Could not add the event to Google Calendar.'; } + + $('#success-frame').append( + '

' + + '
' + + '

' + EALang['success'] + '

' + + '

' + + EALang['appointment_added_to_google_calendar'] + + '
' + + '' + + EALang['view_appointment_in_google_calendar'] + + '' + + '

' + + '
' + ); + $('#add-to-google-calendar').hide(); }); }); } catch(exc) { - // The user denied access or something else happened, display - // corresponding message on the screen. + // The user denied access or something else happened, display corresponding message on the screen. $('#success-frame').append( '
' + '

' + EALang['oops_something_went_wrong'] + '

' +