You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
762 B

  1. $(function() {
  2. function haveBlankHeaderForm() {
  3. return $("#webhook-headers .webhook-header").filter(function() {
  4. var key = $(".key", this).val();
  5. var value = $(".value", this).val();
  6. return !key && !value;
  7. }).length;
  8. }
  9. function ensureBlankHeaderForm() {
  10. if (!haveBlankHeaderForm()) {
  11. var tmpl = $("#header-template").html();
  12. $("#webhook-headers").append(tmpl);
  13. }
  14. }
  15. $("#webhook-headers").on("click", "button", function(e) {
  16. e.preventDefault();
  17. $(this).closest(".webhook-header").remove();
  18. ensureBlankHeaderForm();
  19. })
  20. $("#webhook-headers").on("keyup", "input", ensureBlankHeaderForm);
  21. ensureBlankHeaderForm();
  22. });