$(document).ready(function() { $("#updateAbout").click(function() { if ($("#updateAbout").is(":disabled") == false) { $("#updateAbout").prop("disabled", true); $("#aboutValue").prop("disabled", true); var aboutContent = $("#aboutValue").val(); var csrf_token = $('meta[name="csrf-token"]').attr('content'); $.post('/core/func/api/settings/post/updateAbout.php', { aboutContent: aboutContent, csrf: csrf_token }) .done(function(response) { $("#updateAbout").prop("disabled", false); $("#aboutValue").prop("disabled", false); if (response == "filtered") { $("#sStatus").html("
Your about text contains bad words! Please remove them
"); $("#aboutValue").val(""); }else{ $("#sStatus").html("
About text changed!
"); } }) .fail(function() { $("#sStatus").html("
Network error. Try again later.
"); }); } }) $("#enableRegular").click(function() { if ($("#enableRegular").is(":disabled") == false) { $("#enableRegular").prop("disabled", true); var csrf_token = $('meta[name="csrf-token"]').attr('content'); $.post('/core/func/api/settings/post/updateTheme.php', { theme: 0, csrf: csrf_token }) .done(function(response) { $("#enableRegular").prop("disabled", false); $("#aboutValue").prop("disabled", false); if (response == "success") { window.location.reload(); }else{ $("#sStatus").html("
Network error. Try again later.
"); } }) .fail(function() { $("#sStatus").html("
Network error. Try again later.
"); }); } }) $("#enableDark").click(function() { if ($("#enableRegular").is(":disabled") == false) { $("#enableDark").prop("disabled", true); var csrf_token = $('meta[name="csrf-token"]').attr('content'); $.post('/core/func/api/settings/post/updateTheme.php', { theme: 1, csrf: csrf_token }) .done(function(response) { $("#enableDark").prop("disabled", false); $("#aboutValue").prop("disabled", false); if (response == "success") { window.location.reload(); }else{ $("#sStatus").html("
Network error. Try again later.
"); } }) .fail(function() { $("#sStatus").html("
Network error. Try again later.
"); }); } }) $("#changePassword").click(function() { if ($("#changePassword").is(":disabled") == false) { $("#changePassword").prop("disabled", true); $("#nPassword1").prop("disabled", true); $("#nPassword2").prop("disabled", true); $("#curPassword").prop("disabled", true); var npass1 = $("#nPassword1").val(); var npass2 = $("#nPassword2").val(); var currentPassword = $("#curPassword").val(); var csrf_token = $('meta[name="csrf-token"]').attr('content'); $.post('/core/func/api/settings/post/changePassword.php', { newPassword1: npass1, newPassword2: npass2, currentPassword: currentPassword, csrf: csrf_token }) .done(function(response) { $("#changePassword").prop("disabled", false); $("#nPassword1").prop("disabled", false); $("#nPassword2").prop("disabled", false); $("#curPassword").prop("disabled", false); if (response == "error") { $("#cPassStatus").html("
Network error. Try again later.
"); }else if (response == "missing-info") { $("#cPassStatus").html("
Please fill in everything
"); }else if (response == "confirm-failed") { $("#cPassStatus").html("
Password confirmation has failed
"); }else if (response == "password-too-short") { $("#cPassStatus").html("
Your new password is too short
"); }else if (response == "password-too-long") { $("#cPassStatus").html("
Your new password is too long
"); }else if (response == "wrong-password") { $("#cPassStatus").html("
Your current password is incorrect
"); }else if (response == "success") { window.location = "/"; } }) .fail(function() { $("#cPassStatus").html("
Network error. Try again later.
"); }); } }) $("#changeEmail").click(function() { if ($("#changeEmail").is(":disabled") == false) { $("#changeEmail").prop("disabled", true); $("#email").prop("disabled", true); $("#password").prop("disabled", true); var newEmail = $("#email").val(); var currentPassword = $("#password").val(); var csrf_token = $('meta[name="csrf-token"]').attr('content'); $.post('/core/func/api/settings/post/changeEmail.php', { newEmail: newEmail, currentPassword: currentPassword, csrf: csrf_token }) .done(function(response) { $("#changeEmail").prop("disabled", false); $("#email").prop("disabled", false); $("#password").prop("disabled", false); if (response == "error") { $("#cEmailStatus").html("
Network error. Try again later.
"); }else if (response == "missing-info") { $("#cEmailStatus").html("
Please fill in everything
"); }else if (response == "success") { window.location = "/"; }else if (response == "wrong-password") { $("#cEmailStatus").html("
Your current password is incorrect
"); }else if (response == "rate-limit") { $("#cEmailStatus").html("
You have recently verified your current email, please wait at least 5 minutes before doing this
"); }else if (response == "unknown-email") { $("#cEmailStatus").html("
You are using an unknown email provider. Use a more known one such as hotmail or gmail
"); }else if (response == "email-in-use") { $("#cEmailStatus").html("
That email is already in use by another user.
"); } }) .fail(function() { $("#cEmailStatus").html("
Network error. Try again later.
"); }); } }) $("#enableTwo").click(function() { if ($("#enableTwo").is(":disabled") == false) { $("#enableTwo").prop("disabled", true); var csrf_token = $('meta[name="csrf-token"]').attr('content'); $.post('/core/func/api/settings/post/enableTwo.php', { csrf: csrf_token }) .done(function(response) { $("#updateAbout").prop("disabled", false); $("#aboutValue").prop("disabled", false); if (response == "success") { $("#twocontainer").load("/core/func/api/settings/get/twoStep.php"); }else{ $("#sStatus").html("
Network error. Try again later.
"); } }) .fail(function() { $("#sStatus").html("
Network error. Try again later.
"); }); } }) }); function enableTwoFinal() { if ($("#enableTwoFinal").is(":disabled") == false) { $("#enableTwoFinal").prop("disabled", true); $("#finalCode").prop("disabled", true); var finalCode = $("#finalCode").val(); var csrf_token = $('meta[name="csrf-token"]').attr('content'); $.post('/core/func/api/settings/post/enableTwoFinal.php', { finalCode: finalCode, csrf: csrf_token }) .done(function(response) { $("#enableTwoFinal").prop("disabled", false); $("#finalCode").prop("disabled", false); if (response == "success") { $("#sStatus").html("
Two Step Authentication has been enabled! You will be asked to use it the next time you login.
"); $("#twocontainer").load("/core/func/api/settings/get/twoStep.php"); }else if(response == "missing-info") { $("#sStatus").html("
Please enter your authentication code.
"); }else if(response == "wrong-code") { $("#sStatus").html("
Your authentication code is incorrect. Did you use the Authy or Google authentication mobile app?
"); }else{ $("#sStatus").html("
Network error. Try again later.
"); } }) .fail(function() { $("#sStatus").html("
Network error. Try again later.
"); }); } } function disableFactor() { if ($("#disableTwo").is(":disabled") == false) { $("#disableTwo").prop("disabled", true); var finalCode = $("#finalCode").val(); var csrf_token = $('meta[name="csrf-token"]').attr('content'); $.post('/core/func/api/settings/post/disableTwo.php', { csrf: csrf_token }) .done(function(response) { $("#disableTwo").prop("disabled", false); if (response == "success") { $("#twocontainer").load("/core/func/api/settings/get/twoStep.php"); }else if (response == "staff-block") { $("#sStatus").html("
Staff members may not disable this feature.
"); }else{ $("#sStatus").html("
Network error. Try again later.
") } }) .fail(function() { $("#sStatus").html("
Network error. Try again later.
"); }); } }