healthchecks/static/js/webhook.js
2017-11-10 13:42:50 +02:00

25 lines
No EOL
762 B
JavaScript

$(function() {
function haveBlankHeaderForm() {
return $("#webhook-headers .webhook-header").filter(function() {
var key = $(".key", this).val();
var value = $(".value", this).val();
return !key && !value;
}).length;
}
function ensureBlankHeaderForm() {
if (!haveBlankHeaderForm()) {
var tmpl = $("#header-template").html();
$("#webhook-headers").append(tmpl);
}
}
$("#webhook-headers").on("click", "button", function(e) {
e.preventDefault();
$(this).closest(".webhook-header").remove();
ensureBlankHeaderForm();
})
$("#webhook-headers").on("keyup", "input", ensureBlankHeaderForm);
ensureBlankHeaderForm();
});