mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-22 16:02:54 +03:00
Refactored the installation.js file.
This commit is contained in:
parent
c85d89c5ee
commit
edc97e771e
1 changed files with 28 additions and 25 deletions
|
@ -10,9 +10,11 @@
|
||||||
* ---------------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var MIN_PASSWORD_LENGTH = 7;
|
'use strict';
|
||||||
var AJAX_SUCCESS = 'SUCCESS';
|
|
||||||
var AJAX_FAILURE = 'FAILURE';
|
var MIN_PASSWORD_LENGTH = 7,
|
||||||
|
AJAX_SUCCESS = 'SUCCESS',
|
||||||
|
AJAX_FAILURE = 'FAILURE';
|
||||||
|
|
||||||
$(document).ajaxStart(function() {
|
$(document).ajaxStart(function() {
|
||||||
$('#loading').show();
|
$('#loading').show();
|
||||||
|
@ -26,13 +28,15 @@ $(document).ready(function() {
|
||||||
* Event: Install Easy!Appointments Button "Click"
|
* Event: Install Easy!Appointments Button "Click"
|
||||||
*/
|
*/
|
||||||
$('#install').click(function() {
|
$('#install').click(function() {
|
||||||
if (!validate()) return;
|
if (!validate()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var postUrl = GlobalVariables.baseUrl + '/index.php/installation/ajax_install';
|
var postUrl = GlobalVariables.baseUrl + '/index.php/installation/ajax_install',
|
||||||
var postData = {
|
postData = {
|
||||||
'csrfToken': GlobalVariables.csrfToken,
|
csrfToken: GlobalVariables.csrfToken,
|
||||||
'admin': JSON.stringify(getAdminData()),
|
admin: JSON.stringify(getAdminData()),
|
||||||
'company': JSON.stringify(getCompanyData())
|
company: JSON.stringify(getCompanyData())
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -41,11 +45,9 @@ $(document).ready(function() {
|
||||||
data: postData,
|
data: postData,
|
||||||
datatype: 'json',
|
datatype: 'json',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
//////////////////////////////////////////////////////
|
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||||
console.log('Ajax Install E!A Response:', response);
|
return;
|
||||||
//////////////////////////////////////////////////////
|
}
|
||||||
|
|
||||||
if (!GeneralFunctions.handleAjaxExceptions(response)) return;
|
|
||||||
|
|
||||||
$('.alert').text('Easy!Appointments has been successfully installed!');
|
$('.alert').text('Easy!Appointments has been successfully installed!');
|
||||||
$('.alert').addClass('alert-success');
|
$('.alert').addClass('alert-success');
|
||||||
|
@ -90,8 +92,9 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (missingRequired)
|
if (missingRequired) {
|
||||||
throw 'All the page fields are required.';
|
throw 'All the page fields are required.';
|
||||||
|
}
|
||||||
|
|
||||||
// Validate Passwords
|
// Validate Passwords
|
||||||
if ($('#password').val() != $('#retype-password').val()) {
|
if ($('#password').val() != $('#retype-password').val()) {
|
||||||
|
@ -132,12 +135,12 @@ $(document).ready(function() {
|
||||||
*/
|
*/
|
||||||
function getAdminData() {
|
function getAdminData() {
|
||||||
var admin = {
|
var admin = {
|
||||||
'first_name': $('#first-name').val(),
|
first_name: $('#first-name').val(),
|
||||||
'last_name': $('#last-name').val(),
|
last_name: $('#last-name').val(),
|
||||||
'email': $('#email').val(),
|
email: $('#email').val(),
|
||||||
'phone_number': $('#phone-number').val(),
|
phone_number: $('#phone-number').val(),
|
||||||
'username': $('#username').val(),
|
username: $('#username').val(),
|
||||||
'password': $('#password').val()
|
password: $('#password').val()
|
||||||
};
|
};
|
||||||
|
|
||||||
return admin;
|
return admin;
|
||||||
|
@ -150,9 +153,9 @@ $(document).ready(function() {
|
||||||
*/
|
*/
|
||||||
function getCompanyData() {
|
function getCompanyData() {
|
||||||
var company = {
|
var company = {
|
||||||
'company_name': $('#company-name').val(),
|
company_name: $('#company-name').val(),
|
||||||
'company_email': $('#company-email').val(),
|
company_email: $('#company-email').val(),
|
||||||
'company_link': $('#company-link').val()
|
company_link: $('#company-link').val()
|
||||||
};
|
};
|
||||||
|
|
||||||
return company;
|
return company;
|
||||||
|
|
Loading…
Reference in a new issue