0
0
Fork 0
mirror of https://github.com/healthchecks/healthchecks.git synced 2025-04-17 18:22:33 +00:00
healthchecks_healthchecks/static/js/add_credential.js
2022-06-19 10:10:57 +03:00

35 lines
1.1 KiB
JavaScript

$(function() {
var form = document.getElementById("add-credential-form");
function requestCredentials() {
// Hide error & success messages, show the "waiting" message
$("#name-next").addClass("hide");
$("#waiting").removeClass("hide");
$("#error").addClass("hide");
$("#success").addClass("hide");
var options = JSON.parse($("#options").text());
webauthnJSON.create(options).then(function(response) {
$("#response").val(JSON.stringify(response));
// Show the success message and save button
$("#waiting").addClass("hide");
$("#success").removeClass("hide");
}).catch(function(err) {
// Show the error message
$("#waiting").addClass("hide");
$("#error-text").text(err);
$("#error").removeClass("hide");
});
}
$("#name").on('keypress',function(e) {
if (e.which == 13) {
e.preventDefault();
requestCredentials();
}
});
$("#name-next").click(requestCredentials);
$("#retry").click(requestCredentials);
});