Files
NovaWoW/static/nw-themes/nw-ryu/nw-js-handlers/rename_guild_response.js
T

84 lines
3.2 KiB
JavaScript

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);
}
});
}
});
});