diff --git a/src/ajax.js b/src/ajax.js index 60e6451..76193b0 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -1,19 +1,16 @@ -$(document).ready(function() -{ - $("#provincia").change(function() - { +$(document).ready(function() { + $("#provincia").change(function() { var id_provincia = $(this).val(); - var post_id = 'id='+ id_provincia; + var post_id = 'id=' + id_provincia; $.ajax({ type: "POST", url: "ajax.php", data: post_id, cache: false, - success: function(response) - { + success: function(response) { $("#localidad").html(response); } }); }); -}); +}); \ No newline at end of file diff --git a/src/calendar.js b/src/calendar.js index bf443b6..59857f2 100644 --- a/src/calendar.js +++ b/src/calendar.js @@ -1,65 +1,71 @@ $(document).ready(function() { - var queryString = window.location.search; - var calendar = $('#calendar').fullCalendar({ - selectable: true, - editable: false, + var queryString = window.location.search; + var calendar = $('#calendar').fullCalendar({ + selectable: true, + editable: false, - header: { - left: 'prev,next,today', - center: 'title', - right: 'month,agendaWeek,agendaDay' - }, + header: { + left: 'prev,next,today', + center: 'title', + right: 'month,agendaWeek,agendaDay' + }, - eventSources: [ - "appointment_feed.php" + queryString, - "holiday_feed.php" + queryString - ], + eventSources: [ + "appointment_feed.php" + queryString, + "holiday_feed.php" + queryString + ], - select: function(start, end) { - $("#dialog-form").dialog({ modal: true, width:450}); - var date = $.fullCalendar.formatDate(start, 'YYYY-MM-DD'); - $("#fecha").val(date); - }, + select: function(start, end) { + $("#dialog-form").dialog({ + modal: true, + width: 450 + }); + var date = $.fullCalendar.formatDate(start, 'YYYY-MM-DD'); + $("#fecha").val(date); + }, - selectAllow: function(selectInfo){ - var daysOff = null; - var holidays = null; - $.ajax({ - url: 'holiday_feed.php' + queryString, - async: false, - dataType: 'json', - success: function (json) { - holidays = json; - } - }); - $.ajax({ - url: 'calendar_settings_feed.php' + queryString, - async: false, - dataType: 'json', - success: function (json) { - daysOff = json; - } - }); - var date = selectInfo.start._d; - var formatted_date = date.toISOString().substr(0, 10); - var foundHoliday = holidays.find(el => el.start === formatted_date); - var foundDayOff = daysOff.find(el => el === date.getDay()); - if(foundDayOff == null && foundHoliday == null){ - return true; - } - return false; - }, + selectAllow: function(selectInfo) { + var daysOff = null; + var holidays = null; + $.ajax({ + url: 'holiday_feed.php' + queryString, + async: false, + dataType: 'json', + success: function(json) { + holidays = json; + } + }); + $.ajax({ + url: 'calendar_settings_feed.php' + queryString, + async: false, + dataType: 'json', + success: function(json) { + daysOff = json; + } + }); + var date = selectInfo.start._d; + var formatted_date = date.toISOString().substr(0, 10); + var foundHoliday = holidays.find(el => el.start === formatted_date); + var foundDayOff = daysOff.find(el => el === date.getDay()); + if (foundDayOff == null && foundHoliday == null) { + return true; + } + return false; + }, - eventClick: function(event) { - var start = $.fullCalendar.formatDate(event.start, 'HH:mm'); - var end = $.fullCalendar.formatDate(event.end, 'HH:mm'); - $("#event_id").val(event.id); - $("#event-patient").html("DNI/NIE: " + event.patient); - $("#event-description").html("Observaciones: " + event.description); - $("#event-start").html("Comienzo: " + start); - $("#event-end").html("Fin: " + end); - $("#event-info").dialog({title: event.title, width:450}); - } + eventClick: function(event) { + var start = $.fullCalendar.formatDate(event.start, 'HH:mm'); + var end = $.fullCalendar.formatDate(event.end, 'HH:mm'); + $("#event_id").val(event.id); + $("#event-patient").html("DNI/NIE: " + event.patient); + $("#event-description").html("Observaciones: " + event.description); + $("#event-start").html("Comienzo: " + start); + $("#event-end").html("Fin: " + end); + $("#event-info").dialog({ + title: event.title, + width: 450 + }); + } - }); -}); + }); + }); \ No newline at end of file diff --git a/src/change_input_type.js b/src/change_input_type.js index ef7f071..72aad06 100644 --- a/src/change_input_type.js +++ b/src/change_input_type.js @@ -1,9 +1,9 @@ -function changeInputType(){ +function changeInputType() { country = document.getElementById("pais").value; region = document.getElementById("provincia"); city = document.getElementById("localidad"); - if(country == 73){ + if (country == 73) { region.hidden = false; city.hidden = false; } else { @@ -14,4 +14,4 @@ function changeInputType(){ region_input.type = "text"; city_input.type = "text"; } -} +} \ No newline at end of file diff --git a/src/print_page.js b/src/print_page.js index ef92234..b9c9ef5 100644 --- a/src/print_page.js +++ b/src/print_page.js @@ -4,7 +4,7 @@ function printExternalHTML(url) { printWindow.addEventListener('load', function() { if (Boolean(printWindow.chrome)) { printWindow.print(); - setTimeout(function(){ + setTimeout(function() { printWindow.close(); }, 500); } else { @@ -14,12 +14,12 @@ function printExternalHTML(url) { }, true); } -function getHTML(url){ +function getHTML(url) { html = null; $.ajax({ url: url, async: false, - success: function (data) { + success: function(data) { console.log(data); html = data; } @@ -38,11 +38,11 @@ function printExternalPDF(url) { width: 522 }; pdf.fromHTML( - html, - margins.left, - margins.top, { - 'width': margins.width - } - ), - pdf.save(); -} + html, + margins.left, + margins.top, { + 'width': margins.width + } + ), + pdf.save(); +} \ No newline at end of file diff --git a/src/validate_patient.js b/src/validate_patient.js index f7cf560..c47dd76 100644 --- a/src/validate_patient.js +++ b/src/validate_patient.js @@ -1,66 +1,68 @@ function checkDNI(dni) { - var number, let, letter; + var number, + let, letter; var regex = /^[XYZ]?\d{5,8}[A-Z]$/; dni = dni.toUpperCase(); - if(regex.test(dni) === true){ - number = dni.substr(0,dni.length-1); + if (regex.test(dni) === true) { + number = dni.substr(0, dni.length - 1); number = number.replace('X', 0); number = number.replace('Y', 1); number = number.replace('Z', 2); - let = dni.substr(dni.length-1, 1); + let = dni.substr(dni.length - 1, 1); number = number % 23; letter = 'TRWAGMYFPDXBNJZSQVHLCKET'; - letter = letter.substring(number, number+1); - if (letter != let) { + letter = letter.substring(number, number + 1); + if (letter != + let) { return false; - }else{ + } else { return true; } return false; } } -function validateString(input){ - if(input == ""){ +function validateString(input) { + if (input == "") { return false; } return true; } -function validatePatient(){ +function validatePatient() { var name = document.forms["create_form"]["nombre"]; var last_name = document.forms["create_form"]["apellido"]; var dni = document.forms["create_form"]["documento_identificativo"]; var address = document.forms["create_form"]["direccion"]; var country = document.forms["create_form"]["pais"]; - if(!checkDNI(dni.value)){ + if (!checkDNI(dni.value)) { alert("El DNI/NIE no es correcto"); return false; } - if(!validateString(name.value)){ + if (!validateString(name.value)) { alert("Introduce el nombre"); return false; } - if(!validateString(last_name.value)){ + if (!validateString(last_name.value)) { alert("Introduce el apellido"); return false; } - if(!validateString(address.value)){ + if (!validateString(address.value)) { alert("Introduce la dirección"); return false; } - if(!validateString(country.value)){ + if (!validateString(country.value)) { alert("Introduce el país"); return false; } - + return true; -} +} \ No newline at end of file diff --git a/src/validate_report.js b/src/validate_report.js index ea307fe..cf706b4 100644 --- a/src/validate_report.js +++ b/src/validate_report.js @@ -1,22 +1,22 @@ -function validateString(input){ - if(input == ""){ +function validateString(input) { + if (input == "") { return false; } return true; } -function validateReport(){ +function validateReport() { var title = document.forms["create_form"]["titulo"]; var content = document.forms["create_form"]["contenido"]; - if(!validateString(title.value)){ + if (!validateString(title.value)) { alert("Introduce el título"); return false; } - if(!validateString(content.value)){ + if (!validateString(content.value)) { alert("Introduce el contenido"); return false; } return true; -} +} \ No newline at end of file diff --git a/src/validate_user.js b/src/validate_user.js index b98c64b..ff6b57e 100644 --- a/src/validate_user.js +++ b/src/validate_user.js @@ -1,63 +1,63 @@ -function validateString(input){ - if(input == ""){ +function validateString(input) { + if (input == "") { return false; } return true; } -function validateEmail(input){ +function validateEmail(input) { var emailID = input; atpos = emailID.indexOf("@"); dotpos = emailID.lastIndexOf("."); - if (atpos < 1 || ( dotpos - atpos < 2 )) { + if (atpos < 1 || (dotpos - atpos < 2)) { return false; } return true; } -function validateUser(){ +function validateUser() { var name = document.forms["create_form"]["nombre"]; var user = document.forms["create_form"]["usuario"]; var password = document.forms["create_form"]["contraseña"]; var email = document.forms["create_form"]["correo"]; - if(!validateString(name.value)){ + if (!validateString(name.value)) { alert("Introduce el nombre"); return false; } - if(!validateString(user.value)){ + if (!validateString(user.value)) { alert("Introduce el usuario"); return false; } - if(!validateString(password.value)){ + if (!validateString(password.value)) { alert("Introduce la contraseña"); return false; } - if(!validateEmail(email.value)){ + if (!validateEmail(email.value)) { alert("El correo proporcionado es incorrecto"); return false; } - + return true; } -function validateLogin(){ +function validateLogin() { var user = document.forms["login_form"]["usuario"]; var password = document.forms["login_form"]["contraseña"]; - if(!validateString(user.value)){ + if (!validateString(user.value)) { alert("Introduce el usuario"); return false; } - if(!validateString(password.value)){ + if (!validateString(password.value)) { alert("Introduce la contraseña"); return false; } return true; -} +} \ No newline at end of file