From 7bfff7bfe015ff51d1e008b136442dd3c179134e Mon Sep 17 00:00:00 2001 From: alext Date: Thu, 2 Nov 2017 14:19:54 +0100 Subject: [PATCH] Changed object properties reference style. --- src/assets/js/backend.js | 6 +-- src/assets/js/backend_calendar_api.js | 10 ++--- .../js/backend_calendar_appointments_modal.js | 24 +++++------ src/assets/js/backend_calendar_google_sync.js | 8 ++-- src/assets/js/backend_calendar_table_view.js | 36 ++++++++--------- src/assets/js/frontend_book.js | 40 +++++++++---------- src/assets/js/frontend_book_api.js | 8 ++-- src/assets/js/frontend_book_success.js | 20 +++++----- src/assets/js/general_functions.js | 2 +- 9 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/assets/js/backend.js b/src/assets/js/backend.js index 31ebfdfd..7da2acd8 100644 --- a/src/assets/js/backend.js +++ b/src/assets/js/backend.js @@ -117,12 +117,12 @@ window.Backend = window.Backend || {}; var customActionsHtml = ''; $.each(actions, function(index, action) { - var actionId = action['label'].toLowerCase().replace(' ', '-'); + var actionId = action.label.toLowerCase().replace(' ', '-'); customActionsHtml += ''; + + action.label + ''; $(document).off('click', '#' + actionId); - $(document).on('click', '#' + actionId, action['function']); + $(document).on('click', '#' + actionId, action.function); }); var notificationHtml = diff --git a/src/assets/js/backend_calendar_api.js b/src/assets/js/backend_calendar_api.js index 15adfcd6..be5a2c4b 100644 --- a/src/assets/js/backend_calendar_api.js +++ b/src/assets/js/backend_calendar_api.js @@ -34,20 +34,20 @@ window.BackendCalendarApi = window.BackendCalendarApi || {}; * @param {Function} errorCallback Optional, if defined, this function is going to be executed on post failure. */ exports.saveAppointment = function(appointment, customer, successCallback, errorCallback) { - var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment'; - var postData = { + var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment'; + var data = { csrfToken: GlobalVariables.csrfToken, appointment_data: JSON.stringify(appointment) }; if (customer !== undefined) { - postData['customer_data'] = JSON.stringify(customer); + data.customer_data = JSON.stringify(customer); } $.ajax({ - url: postUrl, + url: url, type: 'POST', - data: postData, + data: data, dataType: 'json' }) .done(function(response) { diff --git a/src/assets/js/backend_calendar_appointments_modal.js b/src/assets/js/backend_calendar_appointments_modal.js index 2da125f1..f6cca2ec 100644 --- a/src/assets/js/backend_calendar_appointments_modal.js +++ b/src/assets/js/backend_calendar_appointments_modal.js @@ -63,7 +63,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa if ($dialog.find('#appointment-id').val() !== '') { // Set the id value, only if we are editing an appointment. - appointment['id'] = $dialog.find('#appointment-id').val(); + appointment.id = $dialog.find('#appointment-id').val(); } var customer = { @@ -79,8 +79,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa if ($dialog.find('#customer-id').val() !== '') { // Set the id value, only if we are editing an appointment. - customer['id'] = $dialog.find('#customer-id').val(); - appointment['id_users_customer'] = customer['id']; + customer.id = $dialog.find('#customer-id').val(); + appointment.id_users_customer = customer.id; } // Define success callback. @@ -144,8 +144,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa var serviceDuration = 0; $.each(GlobalVariables.availableServices, function(index, service) { - if (service['id'] == $dialog.find('#select-service').val()) { - serviceDuration = service['duration']; + if (service.id == $dialog.find('#select-service').val()) { + serviceDuration = service.duration; return false; // exit loop } }); @@ -299,8 +299,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa $.each(provider.services, function(indexService, serviceId) { // If the current provider is able to provide the selected service, add him to the listbox. if (serviceId == sid) { - var optionHtml = ''; $('#select-provider').append(optionHtml); } @@ -340,7 +340,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa $.each(GlobalVariables.availableProviders, function(index, provider) { var canProvideService = false; - $.each(provider['services'], function(index, serviceId) { + $.each(provider.services, function(index, serviceId) { if (serviceId == $dialog.find('#select-service').val()) { canProvideService = true; return false; @@ -348,8 +348,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa }); if (canProvideService) { // Add the provider to the listbox. - var option = new Option(provider['first_name'] - + ' ' + provider['last_name'], provider['id']); + var option = new Option(provider.first_name + + ' ' + provider.last_name, provider.id); $dialog.find('#select-provider').append(option); } }); @@ -363,8 +363,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa // Get the selected service duration. It will be needed in order to calculate the appointment end datetime. var serviceDuration = 0; $.each(GlobalVariables.availableServices, function(index, service) { - if (service['id'] == $dialog.find('#select-service').val()) { - serviceDuration = service['duration']; + if (service.id == $dialog.find('#select-service').val()) { + serviceDuration = service.duration; return false; } }); diff --git a/src/assets/js/backend_calendar_google_sync.js b/src/assets/js/backend_calendar_google_sync.js index 4bcbd14f..f8a5ab9d 100644 --- a/src/assets/js/backend_calendar_google_sync.js +++ b/src/assets/js/backend_calendar_google_sync.js @@ -94,11 +94,11 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {}; // Update page elements and make an AJAX call to remove the google sync setting of the // selected provider. $.each(GlobalVariables.availableProviders, function(index, provider) { - if (provider['id'] == $('#select-filter-item').val()) { - provider['settings']['google_sync'] = '0'; - provider['settings']['google_token'] = null; + if (provider.id == $('#select-filter-item').val()) { + provider.settings.google_sync = '0'; + provider.settings.google_token = null; - _disableProviderSync(provider['id']); + _disableProviderSync(provider.id); $('#enable-sync').removeClass('btn-danger enabled'); $('#enable-sync span:eq(1)').text(EALang.enable_sync); diff --git a/src/assets/js/backend_calendar_table_view.js b/src/assets/js/backend_calendar_table_view.js index 0fc41783..ea1ed90c 100644 --- a/src/assets/js/backend_calendar_table_view.js +++ b/src/assets/js/backend_calendar_table_view.js @@ -261,30 +261,30 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; // Apply appointment data and show modal dialog. $dialog.find('.modal-header h3').text(EALang.edit_appointment_title); - $dialog.find('#appointment-id').val(appointment['id']); - $dialog.find('#select-service').val(appointment['id_services']).trigger('change'); - $dialog.find('#select-provider').val(appointment['id_users_provider']); + $dialog.find('#appointment-id').val(appointment.id); + $dialog.find('#select-service').val(appointment.id_services).trigger('change'); + $dialog.find('#select-provider').val(appointment.id_users_provider); // Set the start and end datetime of the appointment. - var startDatetime = Date.parseExact(appointment['start_datetime'], + var startDatetime = Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss'); $dialog.find('#start-datetime').datetimepicker('setDate', startDatetime); - var endDatetime = Date.parseExact(appointment['end_datetime'], + var endDatetime = Date.parseExact(appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss'); $dialog.find('#end-datetime').datetimepicker('setDate', endDatetime); - var customer = appointment['customer']; - $dialog.find('#customer-id').val(appointment['id_users_customer']); - $dialog.find('#first-name').val(customer['first_name']); - $dialog.find('#last-name').val(customer['last_name']); - $dialog.find('#email').val(customer['email']); - $dialog.find('#phone-number').val(customer['phone_number']); - $dialog.find('#address').val(customer['address']); - $dialog.find('#city').val(customer['city']); - $dialog.find('#zip-code').val(customer['zip_code']); - $dialog.find('#appointment-notes').val(appointment['notes']); - $dialog.find('#customer-notes').val(customer['notes']); + var customer = appointment.customer; + $dialog.find('#customer-id').val(appointment.id_users_customer); + $dialog.find('#first-name').val(customer.first_name); + $dialog.find('#last-name').val(customer.last_name); + $dialog.find('#email').val(customer.email); + $dialog.find('#phone-number').val(customer.phone_number); + $dialog.find('#address').val(customer.address); + $dialog.find('#city').val(customer.city); + $dialog.find('#zip-code').val(customer.zip_code); + $dialog.find('#appointment-notes').val(appointment.notes); + $dialog.find('#customer-notes').val(customer.notes); } else { var unavailable = lastFocusedEventData; @@ -311,7 +311,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; /** * Event: Popover Delete Button "Click" * - * Displays a prompt on whether the user wants the appoinmtent to be deleted. If he confirms the + * Displays a prompt on whether the user wants the appointment to be deleted. If he confirms the * deletion then an ajax call is made to the server and deletes the appointment from the database. */ $calendar.on('click', '.delete-popover', function() { @@ -325,7 +325,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_appointment'; var postData = { csrfToken: GlobalVariables.csrfToken, - appointment_id : lastFocusedEventData['id'], + appointment_id : lastFocusedEventData.id, delete_reason: $('#delete-reason').val() }; diff --git a/src/assets/js/frontend_book.js b/src/assets/js/frontend_book.js index 4003dbca..d940a44a 100644 --- a/src/assets/js/frontend_book.js +++ b/src/assets/js/frontend_book.js @@ -170,12 +170,12 @@ window.FrontendBook = window.FrontendBook || {}; $('#select-provider').empty(); $.each(GlobalVariables.availableProviders, function(indexProvider, provider) { - $.each(provider['services'], function(indexService, serviceId) { + $.each(provider.services'], function(indexService, serviceId) { // If the current provider is able to provide the selected service, // add him to the listbox. if (serviceId == currServiceId) { - var optionHtml = ''; $('#select-provider').append(optionHtml); } @@ -444,7 +444,7 @@ window.FrontendBook = window.FrontendBook || {}; // the appointment. var postData = {}; - postData['customer'] = { + postData.customer = { last_name: $('#last-name').val(), first_name: $('#first-name').val(), email: $('#email').val(), @@ -454,7 +454,7 @@ window.FrontendBook = window.FrontendBook || {}; zip_code: $('#zip-code').val() }; - postData['appointment'] = { + postData.appointment = { start_datetime: $('#select-date').datepicker('getDate').toString('yyyy-MM-dd') + ' ' + Date.parse($('.selected-hour').text()).toString('HH:mm') + ':00', end_datetime: _calcEndDatetime(), @@ -464,11 +464,11 @@ window.FrontendBook = window.FrontendBook || {}; id_services: $('#select-service').val() }; - postData['manage_mode'] = FrontendBook.manageMode; + postData.manage_mode = FrontendBook.manageMode; if (FrontendBook.manageMode) { - postData['appointment']['id'] = GlobalVariables.appointmentData['id']; - postData['customer']['id'] = GlobalVariables.customerData['id']; + postData.appointment.id = GlobalVariables.appointmentData.id; + postData.customer.id = GlobalVariables.customerData.id; } $('input[name="csrfToken"]').val(GlobalVariables.csrfToken); $('input[name="post_data"]').val(JSON.stringify(postData)); @@ -519,24 +519,24 @@ window.FrontendBook = window.FrontendBook || {}; function _applyAppointmentData(appointment, provider, customer) { try { // Select Service & Provider - $('#select-service').val(appointment['id_services']).trigger('change'); - $('#select-provider').val(appointment['id_users_provider']); + $('#select-service').val(appointment.id_services).trigger('change'); + $('#select-provider').val(appointment.id_users_provider); // Set Appointment Date $('#select-date').datepicker('setDate', - Date.parseExact(appointment['start_datetime'], 'yyyy-MM-dd HH:mm:ss')); + Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss')); FrontendBookApi.getAvailableHours($('#select-date').val()); // Apply Customer's Data - $('#last-name').val(customer['last_name']); - $('#first-name').val(customer['first_name']); - $('#email').val(customer['email']); - $('#phone-number').val(customer['phone_number']); - $('#address').val(customer['address']); - $('#city').val(customer['city']); - $('#zip-code').val(customer['zip_code']); - var appointmentNotes = (appointment['notes'] !== null) - ? appointment['notes'] : ''; + $('#last-name').val(customer.last_name); + $('#first-name').val(customer.first_name); + $('#email').val(customer.email); + $('#phone-number').val(customer.phone_number); + $('#address').val(customer.address); + $('#city').val(customer.city); + $('#zip-code').val(customer.zip_code); + var appointmentNotes = (appointment.notes !== null) + ? appointment.notes : ''; $('#notes').val(appointmentNotes); FrontendBook.updateConfirmFrame(); diff --git a/src/assets/js/frontend_book_api.js b/src/assets/js/frontend_book_api.js index 857c9461..227a70a9 100644 --- a/src/assets/js/frontend_book_api.js +++ b/src/assets/js/frontend_book_api.js @@ -40,13 +40,13 @@ window.FrontendBookApi = window.FrontendBookApi || {}; // Find the selected service duration (it is going to be send within the "postData" object). var selServiceDuration = 15; // Default value of duration (in minutes). $.each(GlobalVariables.availableServices, function(index, service) { - if (service['id'] == $('#select-service').val()) { - selServiceDuration = service['duration']; + if (service.id == $('#select-service').val()) { + selServiceDuration = service.duration; } }); // If the manage mode is true then the appointment's start date should return as available too. - var appointmentId = FrontendBook.manageMode ? GlobalVariables.appointmentData['id'] : undefined; + var appointmentId = FrontendBook.manageMode ? GlobalVariables.appointmentData.id : undefined; // Make ajax post request and get the available hours. var postUrl = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_available_hours'; @@ -86,7 +86,7 @@ window.FrontendBookApi = window.FrontendBookApi || {}; $('.available-hour').removeClass('selected-hour'); $('.available-hour').filter(function() { return $(this).text() === Date.parseExact( - GlobalVariables.appointmentData['start_datetime'], + GlobalVariables.appointmentData.start_datetime, 'yyyy-MM-dd HH:mm:ss').toString('h:mm tt'); }).addClass('selected-hour'); } else { diff --git a/src/assets/js/frontend_book_success.js b/src/assets/js/frontend_book_success.js index ded87585..1671efc4 100644 --- a/src/assets/js/frontend_book_success.js +++ b/src/assets/js/frontend_book_success.js @@ -45,28 +45,28 @@ $(document).ready(function() { // must be prepared. var appointmentData = GlobalVariables.appointmentData; - appointmentData['start_datetime'] = GeneralFunctions.ISODateString( - Date.parseExact(appointmentData['start_datetime'], + appointmentData.start_datetime = GeneralFunctions.ISODateString( + Date.parseExact(appointmentData.start_datetime, 'yyyy-MM-dd HH:mm:ss')); - appointmentData['end_datetime'] = GeneralFunctions.ISODateString( - Date.parseExact(appointmentData['end_datetime'], + appointmentData.end_datetime = GeneralFunctions.ISODateString( + Date.parseExact(appointmentData.end_datetime, 'yyyy-MM-dd HH:mm:ss')); // Create a valid Google Calendar API resource for the new event. var resource = { - summary: GlobalVariables.serviceData['name'], + summary: GlobalVariables.serviceData.name, location: GlobalVariables.companyName, start: { - dateTime: appointmentData['start_datetime'] + dateTime: appointmentData.start_datetime }, end: { - dateTime: appointmentData['end_datetime'] + dateTime: appointmentData.end_datetime }, 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 } ] }; diff --git a/src/assets/js/general_functions.js b/src/assets/js/general_functions.js index beef89ac..d57d1356 100644 --- a/src/assets/js/general_functions.js +++ b/src/assets/js/general_functions.js @@ -242,7 +242,7 @@ window.GeneralFunctions = window.GeneralFunctions || {}; html += '
' + '
' + - '
' + exception['message'] + '
' + + '
' + exception.message + '
' + '
' + '
'; });