From edc97e771e358d27ae3a84227e8afb9e124a2c2a Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 24 Apr 2016 19:13:39 +0200 Subject: [PATCH] Refactored the installation.js file. --- src/assets/js/installation.js | 53 ++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/assets/js/installation.js b/src/assets/js/installation.js index 9cafc370..473108b5 100644 --- a/src/assets/js/installation.js +++ b/src/assets/js/installation.js @@ -10,9 +10,11 @@ * ---------------------------------------------------------------------------- */ $(document).ready(function() { - var MIN_PASSWORD_LENGTH = 7; - var AJAX_SUCCESS = 'SUCCESS'; - var AJAX_FAILURE = 'FAILURE'; + 'use strict'; + + var MIN_PASSWORD_LENGTH = 7, + AJAX_SUCCESS = 'SUCCESS', + AJAX_FAILURE = 'FAILURE'; $(document).ajaxStart(function() { $('#loading').show(); @@ -26,14 +28,16 @@ $(document).ready(function() { * Event: Install Easy!Appointments Button "Click" */ $('#install').click(function() { - if (!validate()) return; + if (!validate()) { + return; + } - var postUrl = GlobalVariables.baseUrl + '/index.php/installation/ajax_install'; - var postData = { - 'csrfToken': GlobalVariables.csrfToken, - 'admin': JSON.stringify(getAdminData()), - 'company': JSON.stringify(getCompanyData()) - }; + var postUrl = GlobalVariables.baseUrl + '/index.php/installation/ajax_install', + postData = { + csrfToken: GlobalVariables.csrfToken, + admin: JSON.stringify(getAdminData()), + company: JSON.stringify(getCompanyData()) + }; $.ajax({ url: postUrl, @@ -41,11 +45,9 @@ $(document).ready(function() { data: postData, datatype: 'json', success: function(response) { - ////////////////////////////////////////////////////// - console.log('Ajax Install E!A Response:', response); - ////////////////////////////////////////////////////// - - if (!GeneralFunctions.handleAjaxExceptions(response)) return; + if (!GeneralFunctions.handleAjaxExceptions(response)) { + return; + } $('.alert').text('Easy!Appointments has been successfully installed!'); $('.alert').addClass('alert-success'); @@ -90,8 +92,9 @@ $(document).ready(function() { } }); - if (missingRequired) + if (missingRequired) { throw 'All the page fields are required.'; + } // Validate Passwords if ($('#password').val() != $('#retype-password').val()) { @@ -132,12 +135,12 @@ $(document).ready(function() { */ function getAdminData() { var admin = { - 'first_name': $('#first-name').val(), - 'last_name': $('#last-name').val(), - 'email': $('#email').val(), - 'phone_number': $('#phone-number').val(), - 'username': $('#username').val(), - 'password': $('#password').val() + first_name: $('#first-name').val(), + last_name: $('#last-name').val(), + email: $('#email').val(), + phone_number: $('#phone-number').val(), + username: $('#username').val(), + password: $('#password').val() }; return admin; @@ -150,9 +153,9 @@ $(document).ready(function() { */ function getCompanyData() { var company = { - 'company_name': $('#company-name').val(), - 'company_email': $('#company-email').val(), - 'company_link': $('#company-link').val() + company_name: $('#company-name').val(), + company_email: $('#company-email').val(), + company_link: $('#company-link').val() }; return company;