Ignorar la carpeta venv en Git

This commit is contained in:
root
2024-12-29 03:11:45 +05:30
parent a77cdf96b9
commit e9de3248c0
413 changed files with 32683 additions and 41 deletions
@@ -0,0 +1,53 @@
$(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);
}
});
});
});
@@ -0,0 +1,45 @@
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);
}
});
}
});
});
@@ -0,0 +1,43 @@
$(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();
}
});
});
});
@@ -0,0 +1,73 @@
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('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);
}
});
}
});
});
@@ -0,0 +1,52 @@
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);
}
});
}
});
});
@@ -0,0 +1,35 @@
$(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);
}
});
});
});
@@ -0,0 +1,47 @@
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);
}
});
}
});
});
@@ -0,0 +1,119 @@
// 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": ""
});
}
@@ -0,0 +1 @@
$(document).ready(function(){$("#account-settings").click(function(){$("#account-settings-panel").slideToggle("slow");$(".fa-arrow-down-account").toggleClass('rotate');$(".fa-arrow-down-account").toggleClass('rotate2');});$("#character-settings").click(function(){$("#character-settings-panel").slideToggle("slow");$(".fa-arrow-down-character").toggleClass('rotate');$(".fa-arrow-down-character").toggleClass('rotate2');});$("#account-history").click(function(){$("#account-history-panel").slideToggle("slow");$(".fa-arrow-down-history").toggleClass('rotate');$(".fa-arrow-down-history").toggleClass('rotate2');});});
@@ -0,0 +1,62 @@
$(function() {
if (window.history.replaceState) {
window.history.replaceState(null, null, window.location.href);
}
$('.reward-form').on('submit', function(e) {
e.preventDefault();
const form = $(this);
const button = form.find('button[type="submit"]');
const originalButtonText = button.html();
const recruitResponse = $("#recruit-response");
const rewardRow = form.closest('tr');
const rewardsCounter = $("#claimed-rewards-counter");
// Serializar datos del formulario
const data = form.serialize();
changeButton(button, 'Reclamando...');
$.ajax({
type: 'POST',
url: '',
data: data,
dataType: 'json',
success: function(response) {
recruitResponse.hide().empty();
if (response.success) {
recruitResponse.html(`<span class="ok-form-response">${response.message}</span>`).slideDown();
// Actualizar la fila y deshabilitar el formulario
rewardRow.find('.reward-action').html(`<span class="ok-form-response">${response.message}</span>`);
// Actualizar el contador de recompensas
if (response.claimed_count !== undefined) {
rewardsCounter.text(`${response.claimed_count}/6`);
}
} else {
recruitResponse.html(`<span class="red-form-response">${response.message}</span>`).slideDown();
}
setTimeout(function() {
restoreButton(button, originalButtonText);
}, 3000);
},
error: function() {
recruitResponse.html('<span class="red-form-response">Error en el servidor. Inténtalo de nuevo más tarde.</span>').slideDown();
restoreButton(button, originalButtonText);
}
});
});
});
function changeButton(button, text) {
button.html(text);
button.prop("disabled", true);
}
function restoreButton(button, originalText) {
button.html(originalText);
button.prop("disabled", false);
}
@@ -0,0 +1,38 @@
$(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;
}
@@ -0,0 +1,79 @@
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('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, 'Renombrando hermandad');
$.ajax({
type: 'POST',
url: '',
data: data,
dataType: 'json',
success: function(data) {
$("#rename-guild-response").append(data.message).hide().slideDown();
if (data.success === true) {
button.html("Hermandad renombrada");
button.css("color","#d79602");
setTimeout(function() {
$("#nw-rename-guild-form")[0].reset();
restoreButton(button, buttonoriginal);
doRefresh();
}, 5000);
}
else {
setTimeout(function() {
$("#rename-guild-response").slideUp( function() {
$("#rename-guild-response").empty();
restoreButton(button, buttonoriginal);
});
}, 5000);
}
},
error: function() {
setTimeout(function() {
alert("Algo ha salido mal. Por favor intente más tarde");
window.location.reload();
}, 2000);
}
});
};
});
});
@@ -0,0 +1,75 @@
if (window.history.replaceState) {
window.history.replaceState(null, null, window.location.href);
}
$(document).ready(function () {
// Mostrar mensaje de cancelación si está presente en el backend
const cancelMessage = $("#rename-response").data("cancel-message");
if (cancelMessage) {
$("#rename-response").html(cancelMessage).hide().slideDown();
}
// Manejar clics en el botón de renombrar
$('.rename-button').on('click', function (e) {
e.preventDefault();
$("#rename-response").empty();
const button = $(this);
const originalText = button.html();
const data = $("#nw-rename-form").serialize();
// Confirmar antes de proceder con el pago
const conf = confirm("¿Estás seguro de renombrar al personaje seleccionado?");
if (!conf) return;
// Cambiar texto del botón mientras procesa
changeButton(button, 'Procesando pago...');
$.ajax({
type: 'POST',
url: '', // URL para manejar el POST
data: data,
dataType: 'json',
success: function (response) {
if (response.success) {
// Verificar que Stripe está cargado
if (typeof Stripe === 'undefined') {
console.error("Stripe.js no está cargado.");
$("#rename-response").append('<span class="red-form-response">Error al cargar Stripe. Intente nuevamente más tarde.</span>').hide().slideDown();
restoreButton(button, originalText);
return;
}
// Redirigir a Stripe Checkout
const stripe = Stripe(response.stripe_public_key);
stripe.redirectToCheckout({ sessionId: response.session_id }).then(function (result) {
if (result.error) {
$("#rename-response").append('<span class="red-form-response">' + result.error.message + '</span>').hide().slideDown();
restoreButton(button, originalText);
}
});
} else {
// Mostrar mensaje de error del backend
$("#rename-response").append(response.message).hide().slideDown();
restoreButton(button, originalText);
}
},
error: function () {
$("#rename-response").append('<span class="red-form-response">Error inesperado. Por favor, intente más tarde.</span>').hide().slideDown();
restoreButton(button, originalText);
}
});
});
});
// Función para cambiar el texto del botón y desactivarlo
function changeButton(button, text) {
button.html(text);
button.prop("disabled", true);
}
// Función para restaurar el texto y habilitar el botón
function restoreButton(button, originalText) {
button.html(originalText);
button.prop("disabled", false);
}
@@ -0,0 +1,37 @@
$(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);
}
});
});
});
@@ -0,0 +1,60 @@
$(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", "");
}
@@ -0,0 +1,28 @@
$(document).ready(function() {
$('.add-to-cart').on('click', function() {
var itemId = $(this).data('item-id');
$.post('/store/add_to_cart/', {item_id: itemId}, function(response) {
alert(response.message);
location.reload();
});
});
$('.remove-from-cart').on('click', function() {
var cartId = $(this).data('cart-id');
$.post('/store/remove_from_cart/', {cart_id: cartId}, function(response) {
alert(response.message);
location.reload();
});
});
$('#checkout-button').on('click', function() {
$.post('/store/checkout/', {}, function(response) {
if (response.success) {
var stripe = Stripe(response.stripe_public_key);
stripe.redirectToCheckout({ sessionId: response.session_id });
} else {
alert(response.message);
}
});
});
});
@@ -0,0 +1,4 @@
if(window.history.replaceState){window.history.replaceState(null,null,window.location.href);};$(function(){$('select').on('change',function(){var select=$(this);select.css('color',select.children('option:selected').css('color'));});});$(function(){$('#trade-sell-a').on('click',function(){$('#trade-sell-div').fadeIn('slow');$('#trade-buy-div').hide();});$('#trade-buy-a').on('click',function(){$('#trade-buy-div').fadeIn('slow');$('#trade-sell-div').hide();});});$(function(){$(".toggle-password").click(function(){$(this).toggleClass("fa-eye fa-eye-slash");var type=$(this).hasClass("fa-eye-slash")?"text":"password";$("#password-sell").attr("type",type);});});$(function(){$(".toggle-password").click(function(){$(this).toggleClass("fa-eye fa-eye-slash");var type=$(this).hasClass("fa-eye-slash")?"text":"password";$("#password-buy").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-sell").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-buy").attr("type",type);});});$(function(){$('.trade-points-sell-button').on('click',function(e){e.preventDefault();e.stopPropagation();$("#trade-points-sell-response").empty();var button=$(this);var buttonoriginal=button.html();var data={tradepointssell:button.data('id')};data=$("#nw-trade-points-sell-form").serialize()+'&'+$.param(data);changeButton(button,'CREANDO CÓDIGO');$.ajax({type:'POST',url:'',data:data,dataType:'json',success:function(data){$("#trade-points-sell-response").append(data.message).hide().slideDown();if(data.success===true){button.html("CÓDIGO CREADO");button.css("color","#d79602");setTimeout(function(){$("#nw-trade-points-sell-form")[0].reset();restoreButton(button,buttonoriginal);grecaptcha.reset(0);},5000);}
else{setTimeout(function(){$("#trade-points-sell-response").slideUp(function(){$("#trade-points-sell-response").empty();restoreButton(button,buttonoriginal);grecaptcha.reset(0);});},5000);}},error:function(){setTimeout(function(){alert("Algo ha salido mal. Por favor intente más tarde");window.location.reload();},2000);}});});});$(function(){$('.trade-points-buy-button').on('click',function(e){e.preventDefault();e.stopPropagation();$("#trade-points-buy-response").empty();$(".trade-points-check-button").prop('disabled',true);var button=$(this);var buttonoriginal=button.html();var data={tradepointsbuy:button.data('id')};data=$("#nw-trade-points-buy-form").serialize()+'&'+$.param(data);changeButton(button,'CANJEANDO CÓDIGO');$.ajax({type:'POST',url:'',data:data,dataType:'json',success:function(data){$("#trade-points-buy-response").append(data.message).hide().slideDown();if(data.success===true){button.html("CÓDIGO CANJEADO");button.css("color","#d79602");setTimeout(function(){$("#nw-trade-points-buy-form")[0].reset();$(".trade-points-check-button").prop('disabled',false);restoreButton(button,buttonoriginal);grecaptcha.reset(1);},5000);}
else{setTimeout(function(){$("#trade-points-buy-response").slideUp(function(){$("#trade-points-buy-response").empty();$(".trade-points-check-button").prop('disabled',false);restoreButton(button,buttonoriginal);grecaptcha.reset(1);});},5000);}},error:function(){setTimeout(function(){alert("Algo ha salido mal. Por favor intente más tarde");window.location.reload();},2000);}});});});$(function(){$('.trade-points-check-button').on('click',function(e){e.preventDefault();e.stopPropagation();$("#trade-points-buy-response").empty();$(".trade-points-buy-button").prop('disabled',true);var button=$(this);var buttonoriginal=button.html();var data={tradepointscheck:button.data('id')};data=$("#nw-trade-points-buy-form").serialize()+'&'+$.param(data);changeButton(button,'CHEQUEANDO CÓDIGO');$.ajax({type:'POST',url:'',data:data,dataType:'json',success:function(data){$("#trade-points-buy-response").append(data.message).hide().slideDown();if(data.success===true){button.html("INFO DEL CÓDIGO");button.css("color","#d79602");setTimeout(function(){$(".trade-points-buy-button").prop('disabled',false);restoreButton(button,buttonoriginal);grecaptcha.reset(1);},5000);}
else{setTimeout(function(){$("#trade-points-buy-response").slideUp(function(){$("#trade-points-buy-response").empty();$(".trade-points-buy-button").prop('disabled',false);restoreButton(button,buttonoriginal);grecaptcha.reset(1);});},5000);}},error:function(){setTimeout(function(){alert("Algo ha salido mal. Por favor intente más tarde");window.location.reload();},2000);}});});});
@@ -0,0 +1,37 @@
$(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);
}
});
});
});
@@ -0,0 +1,41 @@
$(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);
}
});
});
});
@@ -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);
}