@@ -121,22 +119,20 @@
diff --git a/src/js/profind.js b/src/js/profind.js
index cd822d1..fcadade 100644
--- a/src/js/profind.js
+++ b/src/js/profind.js
@@ -13,7 +13,7 @@ profind_login = {
var form = $("#entrarForm");
form.find(":submit").attr("disabled", true);
form.find(":submit").addClass('btn-striped');
- $('#entrarForm .resultado').children().remove();
+
$.ajax({
url: form.attr('action'),
dataType: 'json',
@@ -27,20 +27,18 @@ profind_login = {
}
else {
if (data != null && typeof data == 'object') {
+ var resultado = '';
$.each(data, function(key, value){
- jQuery('
', {
- text: value
- }).addClass('error').appendTo('#entrarForm .resultado');
- });
+ resultado = resultado + value;
+ });
+ mostrar_mensaje('Error', resultado);
}
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
form.find(":submit").removeClass('btn-striped');
form.find(":submit").attr("disabled", false);
- jQuery('
', {
- text: 'Error de comunicación con el servidor'
- }).addClass('error').appendTo('#entrarForm .resultado');
+ mostrar_mensaje('Error', 'Error de comunicación con el servidor');
}
});
return false;
@@ -88,7 +86,7 @@ profind_registro = {
var form = $("#registroForm");
form.find(":submit").attr("disabled", true);
form.find(":submit").addClass('btn-striped');
- $('#registroForm .resultado').children().remove();
+
$.ajax({
url: form.attr('action'),
dataType: 'json',
@@ -99,26 +97,22 @@ profind_registro = {
form.find(":submit").attr("disabled", false);
if (data.status == '200') {
form.clearForm();
- $('#msj_info .modal-header h3').text(data.titulo);
- $('#msj_info .modal-body p').text(data.texto);
- $('#msj_info').modal('show');
+ mostrar_mensaje(data.titulo, data.texto);
}
else {
if (data != null && typeof data == 'object') {
+ var resultado = '';
$.each(data, function(key, value){
- jQuery('
', {
- text: value
- }).addClass('error').appendTo('#registroForm .resultado');
+ resultado = resultado + value;
});
+ mostrar_mensaje('Error', resultado);
}
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
form.find(":submit").removeClass('btn-striped');
form.find(":submit").attr("disabled", false);
- jQuery('
', {
- text: 'Error de comunicación con el servidor'
- }).addClass('error').appendTo('#registroForm .resultado');
+ mostrar_mensaje('Error', 'Error de comunicación con el servidor');
}
});
return false;
@@ -189,8 +183,8 @@ profind_recuperar_password = {
var recuperar_password = function() {
var form = $("#recuperarForm");
$('#msj_recuperar .btn-primary').addClass('btn-striped');
- $('#msj_recuperar .btn-primary').attr("disabled", true);
- $('#msj_recuperar .resultado').children().remove();
+ $('#msj_recuperar .btn-primary').attr("disabled", true);
+
$.ajax({
url: form.attr('action'),
dataType: 'json',
@@ -198,31 +192,28 @@ profind_recuperar_password = {
data : form.serialize()+'&ajax=recuperar-form',
success: function(data, textStatus, XMLHttpRequest) {
$('#msj_recuperar .btn-primary').removeClass('btn-striped');
- $('#msj_recuperar .btn-primary').attr("disabled", false);
+ $('#msj_recuperar .btn-primary').attr("disabled", false);
if (data.status == '200') {
form.clearForm();
$('#msj_recuperar').modal('hide');
-
- $('#msj_info .modal-header h3').text(data.titulo);
- $('#msj_info .modal-body p').text(data.texto);
- $('#msj_info').modal('show');
+ mostrar_mensaje(data.titulo, data.texto);
}
else {
if (data != null && typeof data == 'object') {
+ var resultado = '';
$.each(data, function(key, value){
- jQuery('
', {
- text: value
- }).addClass('error').appendTo('#msj_recuperar .resultado');
+ resultado = resultado + value;
});
+ $('#msj_recuperar').modal('hide');
+ mostrar_mensaje('Error', resultado);
}
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#msj_recuperar .btn-primary').removeClass('btn-striped');
- $('#msj_recuperar .btn-primary').attr("disabled", false);
- jQuery('
', {
- text: 'Error de comunicación con el servidor'
- }).addClass('error').appendTo('#msj_recuperar .resultado');
+ $('#msj_recuperar .btn-primary').attr("disabled", false);
+ $('#msj_recuperar').modal('hide');
+ mostrar_mensaje('Error', 'Error de comunicación con el servidor');
}
});
return false;
@@ -266,8 +257,8 @@ profind_cambiar_password = {
var cambiar_password = function() {
var form = $("#cambiarPasswordForm");
$('#msj_cambiarpassword .btn-primary').addClass('btn-striped');
- $('#msj_cambiarpassword .btn-primary').attr("disabled", true);
- $('#msj_cambiarpassword .resultado').children().remove();
+ $('#msj_cambiarpassword .btn-primary').attr("disabled", true);
+
$.ajax({
url: form.attr('action'),
dataType: 'json',
@@ -275,31 +266,26 @@ profind_cambiar_password = {
data : form.serialize()+'&ajax=cambiar-password-form-ext',
success: function(data, textStatus, XMLHttpRequest) {
$('#msj_cambiarpassword .btn-primary').removeClass('btn-striped');
- $('#msj_cambiarpassword .btn-primary').attr("disabled", false);
+ $('#msj_cambiarpassword .btn-primary').attr("disabled", false);
if (data.status == '200') {
form.clearForm();
$('#msj_cambiarpassword').modal('hide');
-
- $('#msj_info .modal-header h3').text(data.titulo);
- $('#msj_info .modal-body p').text(data.texto);
- $('#msj_info').modal('show');
+ mostrar_mensaje(data.titulo, data.texto);
}
else {
if (data != null && typeof data == 'object') {
+ var resultado = '';
$.each(data, function(key, value){
- jQuery('
', {
- text: value
- }).addClass('error').appendTo('#msj_cambiarpassword .resultado');
+ resultado = resultado + value;
});
+ mostrar_mensaje('Error', resultado);
}
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#msj_cambiarpassword .btn-primary').removeClass('btn-striped');
- $('#msj_cambiarpassword .btn-primary').attr("disabled", false);
- jQuery('
', {
- text: 'Error de comunicación con el servidor'
- }).addClass('error').appendTo('#msj_cambiarpassword .resultado');
+ $('#msj_cambiarpassword .btn-primary').attr("disabled", false);
+ mostrar_mensaje('Error', 'Error de comunicación con el servidor');
}
});
return false;
@@ -365,28 +351,23 @@ profind_registro_agente = {
$('#msj_activaragente .btn-primary').attr("disabled", false);
if (data.status == '200') {
form.clearForm();
- $('#msj_activaragente').modal('hide');
-
- $('#msj_info .modal-header h3').text(data.titulo);
- $('#msj_info .modal-body p').text(data.texto);
- $('#msj_info').modal('show');
+ $('#msj_activaragente').modal('hide');
+ mostrar_mensaje(data.titulo, data.texto);
}
else {
if (data != null && typeof data == 'object') {
+ var resultado = '';
$.each(data, function(key, value){
- jQuery('
', {
- text: value
- }).addClass('error').appendTo('#msj_activaragente .resultado');
+ resultado = resultado + value;
});
+ mostrar_mensaje('Error', resultado);
}
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#msj_activaragente .btn-primary').removeClass('btn-striped');
$('#msj_activaragente .btn-primary').attr("disabled", false);
- jQuery('
', {
- text: 'Error de comunicación con el servidor'
- }).addClass('error').appendTo('#msj_activaragente .resultado');
+ mostrar_mensaje('Error', 'Error de comunicación con el servidor');
}
});
return false;
@@ -449,3 +430,8 @@ $.fn.clearForm = function() {
});
};
+function mostrar_mensaje(titulo, mensaje) {
+ $('#msj_info .modal-header h3').text(titulo);
+ $('#msj_info .modal-body p').text(mensaje);
+ $('#msj_info').modal('show');
+}
\ No newline at end of file
diff --git a/src/que-es-profind.html b/src/que-es-profind.html
index 4f07e55..00ccef3 100644
--- a/src/que-es-profind.html
+++ b/src/que-es-profind.html
@@ -43,28 +43,41 @@