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.

38 lines
1.3 KiB

  1. $(function() {
  2. function updateForm() {
  3. var mType = $('input[name=mtype]:checked').val();
  4. if (mType == "stream") {
  5. $("#z-to-label").text("Stream Name");
  6. $("#z-to-help").text('Example: "general"');
  7. }
  8. if (mType == "private") {
  9. $("#z-to-label").text("User's Email");
  10. $("#z-to-help").text('Example: "[email protected]"');
  11. }
  12. }
  13. // Update form labels when user clicks on radio buttons
  14. $('input[type=radio][name=mtype]').change(updateForm);
  15. $("#zuliprc").change(function() {
  16. this.files[0].text().then(function(contents) {
  17. var keyMatch = contents.match(/key=(.*)/);
  18. var emailMatch = contents.match(/email=(.*@.*)/);
  19. var siteMatch = contents.match(/site=(.*)/);
  20. if (!keyMatch || !emailMatch || !siteMatch) {
  21. $("#zuliprc-help").text("Invalid file format.");
  22. $("#save-integration").prop("disabled", true);
  23. return
  24. }
  25. $("#zulip-api-key").val(keyMatch[1]);
  26. $("#zulip-bot-email").val(emailMatch[1]);
  27. $("#zulip-site").val(siteMatch[1]);
  28. $("#zuliprc-help").text("");
  29. $("#save-integration").prop("disabled", false);
  30. });
  31. })
  32. });