tracman-server/static/js/.settings.min.js

1 line
3.2 KiB
JavaScript

"use strict";function validateEmail(e){return/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)}function replaceFromEndpoint(e,i,t){$.get("/validate?"+e+"="+$(i).val()).done(function(e){$(i).val(e),t()})}$(function(){var e,i;function t(t){!function(t){var n=0;$("#slug-input").val()?(e||$("#slug-help").hide(),n>0?t():n++):($("#slug-help").show().text("A slug is required. "),$("#submit-group .main").prop("disabled",!0).prop("title","You need to enter a slug. "),n>0?t():n++);$("#email-input").val()?validateEmail($("#email-input").val())?(i||$("#email-help").hide(),n>0?t():n++):($("#email-help").show().text("You must enter a valid email address. "),$("#submit-group .main").prop("disabled",!0).prop("title","You need to enter a valid email address. "),n>0?t():n++):($("#email-help").show().text("An email is required. "),$("#submit-group .main").prop("disabled",!0).prop("title","You need to enter an email address. "),n>0?t():n++)}(function(){!function(t){function n(){$("#email-help").is(":visible")&&"Unable to confirm unique "!==$("#email-help").text().substring(0,25)?$("#submit-group .main").prop("disabled",!0).prop("title","You need to supply a different email address. "):$("#slug-help").is(":visible")&&"Unable to confirm unique "!==$("#slug-help").text().substring(0,25)?$("#submit-group .main").prop("disabled",!0).prop("title","You need to supply a different slug. "):"Unable to confirm unique "===$("#slug-help").text().substring(0,25)?$("#submit-group .main").prop("title","Unable to confirm unique slug with the server. This might not work... "):"Unable to confirm unique "===$("#email-help").text().substring(0,25)?$("#submit-group .main").prop("title","Unable to confirm unique email with the server. This might not work... "):$("#submit-group .main").prop("disabled",!1).prop("title","Click here to save your changes. ")}t&&$("#"+t+"-input").val()?("email"===!t||validateEmail($("#email-input").val()))&&$.ajax({url:"/validate?"+t+"="+$("#"+t+"-input").val(),type:"GET",statusCode:{200:function(){$("#"+t+"-help").hide(),"slug"===t?e=!1:"email"===t&&(i=!1),n()},400:function(){"slug"===t?e=!0:"email"===t&&(i=!0),$("#"+t+"-help").show().text("That "+t+" is already in use by another user. "),$("#submit-group .main").prop("disabled",!0).prop("title","You need to supply a different "+t+". ")}}}).error(function(){"slug"===t?e=void 0:"email"===t&&(i=void 0),$("#"+t+"-help").show().text("Unable to confirm unique "+t+". This might not work... "),n()}):n()}(t)})}$("#password").attr("href","/account/password?tz="+(new Date).getTimezoneOffset()),$("#delete").click(function(){confirm("Are you sure you want to delete your account? This CANNOT be undone! ")&&(window.location.href="/settings/delete")}),$("#slug-input").change(function(){$("#slug-input").val()?($("#slug-help").hide(),replaceFromEndpoint("slugify","#slug-input",function(){t("slug")})):($("#slug-help").show().text("A slug is required. "),$("#submit-group .main").prop("disabled",!0).prop("title","You need to enter a slug. "))}),$("#email-input").change(function(){t("email")}),$("#name-input").change(function(){replaceFromEndpoint("xss","#name-input",t)})});