Limpieza: elimina los 15 JS handlers jQuery reemplazados por las islas React
Borra los handlers de nw-js-handlers/ de los formularios ya migrados a TSX, que ninguna plantilla referencia: login, register, change_password, change_email, security_token, customize, change_race, change_faction, level_up, gold, transfer_character, revive, unstuck, rename_guild, vote_points. También quita el <script> inline de Stripe redundante en rename_guild (lo carga frontend/stripe.ts). Se conservan los aún referenciados por páginas NO migradas o stubs: my_account (paneles plegables), rename_response (rename_cancel), promo_code, trade_points, recruit, store (store_response, store_novawow_response, create_check). Verificado: check OK, la web sigue funcionando; los JS borrados dan 404 y los en uso 200. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<div class="main-page">
|
||||
<div class="middle-content">
|
||||
<div class="body-content">
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
<div class="title-content"><h1>Renombrar Hermandad</h1></div>
|
||||
<div class="box-content">
|
||||
<div class="title-box-content">
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
function handleResponse(response, button, originalText) {
|
||||
$("#change-email-response").html(response.message).hide().slideDown();
|
||||
|
||||
if (response.redirect_url) {
|
||||
setTimeout(function() {
|
||||
window.location.href = response.redirect_url;
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.success) {
|
||||
button.html("Proceso completado");
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
$("#change-email-response").slideUp(function() {
|
||||
$("#change-email-response").empty();
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
// Manejar los enlaces de confirmación
|
||||
$('.confirm-link').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#change-email-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var url = button.attr('href');
|
||||
var originalText = button.html();
|
||||
|
||||
button.html("Verificando...");
|
||||
button.prop("disabled", true);
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
handleResponse(response, button, originalText);
|
||||
},
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,45 +0,0 @@
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
};
|
||||
|
||||
$(function(){
|
||||
$('.change-faction-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#change-faction-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var buttonoriginal = button.html();
|
||||
var data = $("#nw-change-faction-form").serialize();
|
||||
|
||||
var conf = confirm("¿Estás seguro de cambiar de facción al personaje seleccionado?");
|
||||
|
||||
if (conf === true) {
|
||||
changeButton(button, 'Procesando pago...');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '', // URL actual
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
var stripe = Stripe(response.stripe_public_key);
|
||||
stripe.redirectToCheckout({ sessionId: response.session_id }).then(function(result) {
|
||||
if (result.error) {
|
||||
$("#change-faction-response").append('<span class="red-form-response">' + result.error.message + '</span>').hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#change-faction-response").append(response.message).hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$("#change-faction-response").append('<span class="red-form-response">Error inesperado. Por favor, intente más tarde.</span>').hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,43 +0,0 @@
|
||||
$(function(){
|
||||
$('.change-password-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$("#change-password-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var originalText = button.html();
|
||||
var data = $("#nw-change-password-form").serialize();
|
||||
|
||||
changeButton(button, 'Cambiando contraseña');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
$("#change-password-response").html(response.message).hide().slideDown();
|
||||
|
||||
if (response.success) {
|
||||
button.html("Contraseña cambiada").css("color", "#d79602");
|
||||
if (response.redirect) {
|
||||
setTimeout(function() {
|
||||
window.location.href = '/es/log-in';
|
||||
}, 3000);
|
||||
}
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
$("#change-password-response").slideUp(function() {
|
||||
$("#change-password-response").empty();
|
||||
restoreButton(button, originalText);
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert("Algo ha salido mal. Por favor, intenta más tarde.");
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,73 +0,0 @@
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
}
|
||||
|
||||
function doRefresh() {
|
||||
$("#nw-change-race-form").load(document.URL + " #nw-change-race-form>*", function () {
|
||||
$.getScript('/static/nw-themes/nw-ryu/nw-js-handlers/change_race_response.js');
|
||||
});
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('select').on('change', function () {
|
||||
var select = $(this);
|
||||
select.css('color', select.children('option:selected').css('color'));
|
||||
});
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$('.change-race-button').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$("#change-race-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var buttonoriginal = button.html();
|
||||
var data = $("#nw-change-race-form").serialize();
|
||||
|
||||
var conf = confirm("¿Estás seguro de cambiar de raza al personaje seleccionado?");
|
||||
if (conf === true) {
|
||||
changeButton(button, 'Procesando pago...');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '', // La URL para manejar la solicitud POST
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
// Verificar si Stripe.js está disponible
|
||||
if (typeof Stripe === 'undefined') {
|
||||
console.error("Stripe.js no está cargado.");
|
||||
$("#change-race-response").append('<span class="red-form-response">Error al cargar Stripe. Intente nuevamente más tarde.</span>').hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
return;
|
||||
}
|
||||
|
||||
// Inicializar Stripe con la clave pública
|
||||
var stripe = Stripe(response.stripe_public_key);
|
||||
|
||||
// Redirigir al checkout de Stripe
|
||||
stripe.redirectToCheckout({
|
||||
sessionId: response.session_id
|
||||
}).then(function (result) {
|
||||
if (result.error) {
|
||||
$("#change-race-response").append('<span class="red-form-response">' + result.error.message + '</span>').hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#change-race-response").append(response.message).hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
setTimeout(function () {
|
||||
alert("Algo ha salido mal. Por favor intente más tarde");
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,52 +0,0 @@
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
}
|
||||
|
||||
$(function(){
|
||||
$('.customize-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#customize-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var buttonoriginal = button.html();
|
||||
var data = $("#nw-customize-form").serialize();
|
||||
|
||||
var conf = confirm("¿Estás seguro de personalizar al personaje seleccionado?");
|
||||
|
||||
if (conf === true) {
|
||||
button.html("Procesando pago...");
|
||||
button.prop("disabled", true);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '', // Endpoint para manejar el POST
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
var stripe = Stripe(response.stripe_public_key);
|
||||
|
||||
stripe.redirectToCheckout({
|
||||
sessionId: response.session_id
|
||||
}).then(function(result) {
|
||||
if (result.error) {
|
||||
$("#customize-response").html('<span class="red-form-response">' + result.error.message + '</span>');
|
||||
button.html(buttonoriginal);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#customize-response").html(response.message);
|
||||
button.html(buttonoriginal);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$("#customize-response").html('<span class="red-form-response">Algo salió mal. Intenta de nuevo.</span>');
|
||||
button.html(buttonoriginal);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,35 +0,0 @@
|
||||
$(function(){
|
||||
$('.gold-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#gold-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var originalText = button.html();
|
||||
var data = $("#nw-gold-form").serialize();
|
||||
|
||||
button.html('Procesando pago...');
|
||||
button.prop('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
var stripe = Stripe(response.stripe_public_key);
|
||||
stripe.redirectToCheckout({ sessionId: response.session_id });
|
||||
} else {
|
||||
$("#gold-response").append(response.message).hide().slideDown();
|
||||
button.html(originalText);
|
||||
button.prop('disabled', false);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$("#gold-response").append('<span class="red-form-response">Error inesperado. Por favor, intente más tarde.</span>').hide().slideDown();
|
||||
button.html(originalText);
|
||||
button.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,47 +0,0 @@
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$('.level-up-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#levelup-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var buttonoriginal = button.html();
|
||||
var data = $("#nw-levelup-form").serialize();
|
||||
|
||||
var conf = confirm("¿Estás seguro de subir al nivel 80 al personaje seleccionado?");
|
||||
|
||||
if (conf === true) {
|
||||
changeButton(button, 'Procesando pago...');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
var stripe = Stripe(response.stripe_public_key);
|
||||
stripe.redirectToCheckout({
|
||||
sessionId: response.session_id
|
||||
}).then(function(result) {
|
||||
if (result.error) {
|
||||
$("#levelup-response").append('<span class="red-form-response">' + result.error.message + '</span>').hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#levelup-response").append(response.message).hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$("#levelup-response").append('<span class="red-form-response">Error inesperado. Por favor intente más tarde.</span>').hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,119 +0,0 @@
|
||||
// Evitar el reenvío del formulario si la página se recarga
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
}
|
||||
|
||||
// Mostrar/ocultar la contraseña
|
||||
$(function() {
|
||||
$(".toggle-password").click(function() {
|
||||
$(this).toggleClass("fa-eye fa-eye-slash");
|
||||
const type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
|
||||
$("#password").attr("type", type);
|
||||
});
|
||||
});
|
||||
|
||||
// Manejar el envío del formulario de inicio de sesión
|
||||
$(function() {
|
||||
$('.login-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const button = $(this);
|
||||
const buttonOriginal = button.html();
|
||||
const username = $("#username").val().trim();
|
||||
const password = $("#password").val().trim();
|
||||
const loginResponse = $("#login-response");
|
||||
|
||||
// Cambiar el texto del botón a "Conectando..."
|
||||
changeButton(button, 'Conectando');
|
||||
|
||||
// Validar si los campos están vacíos
|
||||
if (username === "" || password === "") {
|
||||
loginResponse.html('<span class="red-form-response">Por favor rellene todos los campos.</span>');
|
||||
loginResponse.hide().slideDown();
|
||||
|
||||
// Limpiar el mensaje y restaurar el botón después de 5 segundos
|
||||
setTimeout(function() {
|
||||
loginResponse.slideUp(function() {
|
||||
loginResponse.empty();
|
||||
restoreButton(button, buttonOriginal);
|
||||
});
|
||||
}, 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
// Serializar datos para el envío
|
||||
const bValue = button.data('id');
|
||||
let data = { login: bValue };
|
||||
data = $("#nw-login-form").serialize() + '&' + $.param(data);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
loginResponse.hide().empty();
|
||||
|
||||
if (response.success === true) {
|
||||
// Si el inicio de sesión es exitoso
|
||||
button.html("Conectado");
|
||||
button.css("color", "#d79602");
|
||||
|
||||
// Mostrar mensaje de conexión exitosa
|
||||
loginResponse.html('<span class="ok-form-response">Conexión exitosa.<br />Redirigiendo...</span>');
|
||||
loginResponse.hide().slideDown();
|
||||
|
||||
// Redirigir después de 3 segundos
|
||||
setTimeout(function() {
|
||||
window.location = "my-account";
|
||||
}, 3000);
|
||||
} else if (response.alert === true) {
|
||||
button.html("Sancionado");
|
||||
} else if (response.locked === true) {
|
||||
button.html("Seguridad");
|
||||
} else {
|
||||
// Mostrar mensaje para credenciales incorrectas
|
||||
loginResponse.html('<span class="red-form-response">Nombre de usuario / Contraseña incorrectos.</span>');
|
||||
loginResponse.hide().slideDown();
|
||||
|
||||
// Restaurar el botón y ocultar el mensaje después de 5 segundos
|
||||
setTimeout(function() {
|
||||
loginResponse.slideUp(function() {
|
||||
loginResponse.empty();
|
||||
restoreButton(button, buttonOriginal);
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
setTimeout(function() {
|
||||
alert("Algo ha salido mal. Por favor intente más tarde");
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Función para cambiar el estado del botón a "Conectando"
|
||||
function changeButton(button, text) {
|
||||
button.html(text);
|
||||
button.prop("disabled", true);
|
||||
button.css({
|
||||
"color": "rgb(177, 153, 127)",
|
||||
"background-color": "rgba(255, 255, 255, 0.1)",
|
||||
"cursor": "default"
|
||||
});
|
||||
}
|
||||
|
||||
// Función para restaurar el estado original del botón
|
||||
function restoreButton(button, originalText) {
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
button.css({
|
||||
"color": "",
|
||||
"background-color": "",
|
||||
"cursor": ""
|
||||
});
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
$(function() {
|
||||
// Manejar el envío del formulario de creación de cuenta
|
||||
$('#nw-create-form').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const data = $(this).serialize();
|
||||
const createResponse = $("#create-response");
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
createResponse.hide().empty();
|
||||
if (response.success) {
|
||||
createResponse.html(`<span class="ok-form-response">${response.message}</span>`).slideDown();
|
||||
} else {
|
||||
createResponse.html(`<span class="red-form-response">${response.message}</span>`).slideDown();
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
createResponse.html('<span class="red-form-response">Error en el servidor. Inténtalo de nuevo más tarde.</span>').slideDown();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Manejar el estado del botón según el checkbox
|
||||
$('#accept-terms-cookies').on('change', function() {
|
||||
$('#create-account-btn').prop('disabled', !this.checked);
|
||||
});
|
||||
});
|
||||
|
||||
// Función para habilitar/deshabilitar el botón según el estado del checkbox (alternativa sin jQuery)
|
||||
function click_checkbox() {
|
||||
const checkbox = document.getElementById('accept-terms-cookies');
|
||||
const createButton = document.getElementById('create-account-btn');
|
||||
createButton.disabled = !checkbox.checked;
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
};
|
||||
|
||||
$(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 doRefresh() {
|
||||
$("#nw-rename-guild-form").load(document.URL + " #nw-rename-guild-form>*", function(){
|
||||
$.getScript('/static/nw-themes/nw-ryu/nw-js-handlers/rename_guild_response.js');
|
||||
});
|
||||
}
|
||||
|
||||
$(function(){
|
||||
$('select').on('change', function(){
|
||||
var select = $(this);
|
||||
|
||||
select.css('color', select.children('option:selected').css('color'));
|
||||
});
|
||||
});
|
||||
|
||||
$(function(){
|
||||
$('.rename-guild-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$("#rename-guild-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var buttonoriginal = button.html();
|
||||
var bValue = button.data('id');
|
||||
var data = {renameguild : bValue};
|
||||
data = $("#nw-rename-guild-form").serialize() + '&' + $.param(data);
|
||||
|
||||
var conf = confirm("¿Estás seguro de renombrar la hermandad seleccionada?");
|
||||
|
||||
if (conf === true) {
|
||||
changeButton(button, 'Procesando pago...');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '', // Asegúrate de que la URL es la correcta
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data.success) { // ✅ Verificamos correctamente
|
||||
if (typeof Stripe === 'undefined') {
|
||||
console.error("Stripe.js no está cargado.");
|
||||
$("#rename-guild-response").append('<span class="red-form-response">Error al cargar Stripe. Intente nuevamente más tarde.</span>').hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
return;
|
||||
}
|
||||
|
||||
var stripe = Stripe(data.stripe_public_key); // ✅ Usamos correctamente el public key
|
||||
|
||||
stripe.redirectToCheckout({
|
||||
sessionId: data.session_id // ✅ Ahora usamos data.session_id correctamente
|
||||
}).then(function (result) {
|
||||
if (result.error) {
|
||||
$("#rename-guild-response").append('<span class="red-form-response">' + result.error.message + '</span>').hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
$("#rename-guild-response").append(data.message).hide().slideDown();
|
||||
restoreButton(button, buttonoriginal);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
setTimeout(function () {
|
||||
alert("Algo ha salido mal. Por favor intente más tarde");
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,37 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
$('.revive-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#revive-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var originalText = button.html();
|
||||
var data = $("#nw-revive-form").serialize();
|
||||
|
||||
button.html("Reviviendo...");
|
||||
button.prop("disabled", true);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
$("#revive-response").html(response.message).hide().slideDown();
|
||||
if (response.success) {
|
||||
button.html("Revivido");
|
||||
setTimeout(function() {
|
||||
location.reload(); // Refrescar para actualizar el formulario
|
||||
}, 5000);
|
||||
} else {
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$("#revive-response").html('<span class="red-form-response">Algo salió mal. Intente nuevamente.</span>');
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,60 +0,0 @@
|
||||
$(function() {
|
||||
$('.sec-token-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
var originalText = button.html();
|
||||
var data = $("#nw-sec-token-form").serialize();
|
||||
|
||||
// Cambiar el texto del botón a "Solicitando token"
|
||||
changeButton(button, 'Solicitando token');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
$("#sec-token-response").html(response.message).hide().slideDown();
|
||||
|
||||
if (response.success) {
|
||||
// Actualizar la fecha del token en la página si se ha generado correctamente
|
||||
if (response.token_date) {
|
||||
$("#token-date").text(response.token_date);
|
||||
}
|
||||
|
||||
// Cambiar el texto del botón a "Token enviado"
|
||||
button.html("Token enviado").css("color", "#d79602");
|
||||
|
||||
// Restablecer el botón después de 5 segundos
|
||||
setTimeout(function() {
|
||||
restoreButton(button, originalText);
|
||||
$("#sec-token-response").slideUp(function() {
|
||||
$("#sec-token-response").empty();
|
||||
});
|
||||
}, 5000);
|
||||
} else {
|
||||
// Restablecer el botón y ocultar el mensaje en caso de error
|
||||
setTimeout(function() {
|
||||
$("#sec-token-response").slideUp(function() {
|
||||
$("#sec-token-response").empty();
|
||||
restoreButton(button, originalText);
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert("Algo ha salido mal. Por favor, intenta más tarde.");
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function changeButton(button, text) {
|
||||
button.prop('disabled', true).html(text);
|
||||
}
|
||||
|
||||
function restoreButton(button, originalText) {
|
||||
button.prop('disabled', false).html(originalText).css("color", "");
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
$(function(){
|
||||
$('.transfer-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#transfer-character-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var originalText = button.text();
|
||||
var data = $("#nw-transfer-character-form").serialize();
|
||||
|
||||
button.text("Procesando pago...");
|
||||
button.prop("disabled", true);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '', // URL de transferencia
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
var stripe = Stripe(response.stripe_public_key);
|
||||
stripe.redirectToCheckout({
|
||||
sessionId: response.session_id
|
||||
});
|
||||
} else {
|
||||
$("#transfer-character-response").append(response.message).hide().slideDown();
|
||||
button.text(originalText);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$("#transfer-character-response").append('<span class="red-form-response">Error inesperado. Intente más tarde.</span>').hide().slideDown();
|
||||
button.text(originalText);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,41 +0,0 @@
|
||||
$(function() {
|
||||
$('.unstuck-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$("#unstuck-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var originalText = button.html();
|
||||
var data = $("#nw-unstuck-form").serialize();
|
||||
|
||||
button.html("Desbloqueando...");
|
||||
button.prop("disabled", true);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
$("#unstuck-response").html(data.message).hide().slideDown();
|
||||
|
||||
if (data.success) {
|
||||
button.html("Desbloqueado");
|
||||
setTimeout(function() {
|
||||
$("#nw-unstuck-form")[0].reset();
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
}, 5000);
|
||||
} else {
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$("#unstuck-response").html('<span class="red-form-response">Algo ha salido mal. Inténtelo más tarde.</span>');
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,83 +0,0 @@
|
||||
function doRefresh() {
|
||||
$("#vote-panel").load(document.URL + " #vote-panel>*", function(){
|
||||
$.getScript('/static/nw-themes/nw-ryu/nw-js-handlers/vote_points_response.js');
|
||||
});
|
||||
}
|
||||
|
||||
$(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