Arreglado VotePoints, y Implementado el Cambio de Correo
This commit is contained in:
@@ -1,70 +1,42 @@
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
};
|
||||
|
||||
$(function(){
|
||||
$(".toggle-password").click(function() {
|
||||
$(this).toggleClass("fa-eye fa-eye-slash");
|
||||
var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
|
||||
$("#password").attr("type", type);
|
||||
});
|
||||
});
|
||||
|
||||
$(function(){
|
||||
$(".toggle-token").click(function() {
|
||||
$(this).toggleClass("fa-eye fa-eye-slash");
|
||||
var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
|
||||
$("#security-token").attr("type", type);
|
||||
});
|
||||
});
|
||||
|
||||
$(function(){
|
||||
$('#conf-new-email').on("cut copy paste",function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
$(function(){
|
||||
$('.change-email-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$(document).ready(function() {
|
||||
$('#nw-change-email-form').on('submit', function(e) {
|
||||
e.preventDefault(); // Evitar el envío por defecto del formulario
|
||||
$("#change-email-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var buttonoriginal = button.html();
|
||||
var bValue = button.data('id');
|
||||
var data = {changeemail: bValue};
|
||||
data = $("#uw-change-email-form").serialize() + '&' + $.param(data);
|
||||
var form = $(this);
|
||||
var button = $('.change-email-button');
|
||||
var originalText = button.html();
|
||||
|
||||
changeButton(button, 'Cambiando correo');
|
||||
button.html("Cambiando correo...");
|
||||
button.prop("disabled", true);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
url: form.attr('action'),
|
||||
data: form.serialize(), // Serializar los datos correctamente
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
$("#change-email-response").append(data.message).hide().slideDown();
|
||||
success: function(response) {
|
||||
$("#change-email-response").html(response.message).hide().slideDown();
|
||||
|
||||
if (data.success === true) {
|
||||
if (response.success) {
|
||||
button.html("Correo cambiado");
|
||||
button.css("color","#d79602");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
$("#change-email-response").slideUp( function() {
|
||||
$("#change-email-response").empty();
|
||||
restoreButton(button, buttonoriginal);
|
||||
$("#change-email-response").slideUp(function() {
|
||||
$("#change-email-response").empty();
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
setTimeout(function() {
|
||||
alert("Algo ha salido mal. Por favor intente más tarde");
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
error: function(xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
console.error("Detalles:", xhr.responseText);
|
||||
$("#change-email-response").html('<span class="red-form-response">Algo ha salido mal. Inténtelo de nuevo.</span>');
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
$(document).ready(function() {
|
||||
$('.vote-button').each(function() {
|
||||
var button = $(this);
|
||||
var remainingTime = button.data('remaining-time');
|
||||
|
||||
if (remainingTime) {
|
||||
startCooldownTimer(button, remainingTime);
|
||||
}
|
||||
});
|
||||
|
||||
$('.vote-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#voteResponse").empty();
|
||||
|
||||
var button = $(this);
|
||||
var voteUrl = button.data('url').trim();
|
||||
var data = { vote: voteUrl };
|
||||
|
||||
button.html("Votando...");
|
||||
button.prop("disabled", true);
|
||||
|
||||
var otherWindow = window.open(voteUrl, "_blank");
|
||||
otherWindow.opener = null;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
$("#voteResponse").html(response.message).hide().slideDown();
|
||||
|
||||
if (response.success) {
|
||||
button.html("Votado");
|
||||
button.prop("disabled", true);
|
||||
} else {
|
||||
button.html("Votar");
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
|
||||
// Ocultar el mensaje después de 5 segundos
|
||||
setTimeout(function() {
|
||||
$("#voteResponse").slideUp(function() {
|
||||
$("#voteResponse").empty();
|
||||
});
|
||||
}, 5000);
|
||||
},
|
||||
error: function() {
|
||||
$("#voteResponse").html('<span class="red-form-response">Algo ha salido mal. Por favor, inténtalo más tarde.</span>');
|
||||
|
||||
// Ocultar el mensaje después de 5 segundos en caso de error
|
||||
setTimeout(function() {
|
||||
$("#voteResponse").slideUp(function() {
|
||||
$("#voteResponse").empty();
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function startCooldownTimer(button, remainingTime) {
|
||||
var interval = setInterval(function() {
|
||||
if (remainingTime <= 0) {
|
||||
clearInterval(interval);
|
||||
button.html("Votar");
|
||||
button.prop("disabled", false);
|
||||
} else {
|
||||
var hours = Math.floor(remainingTime / 3600);
|
||||
var minutes = Math.floor((remainingTime % 3600) / 60);
|
||||
button.html(`Espera ${hours}h ${minutes}m`);
|
||||
remainingTime--;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
Reference in New Issue
Block a user