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

$(function() {
function updateForm() {
var mType = $('input[name=mtype]:checked').val();
if (mType == "stream") {
$("#z-to-label").text("Stream Name");
$("#z-to-help").text('Example: "general"');
}
if (mType == "private") {
$("#z-to-label").text("User's Email");
$("#z-to-help").text('Example: "[email protected]"');
}
}
// Update form labels when user clicks on radio buttons
$('input[type=radio][name=mtype]').change(updateForm);
$("#zuliprc").change(function() {
this.files[0].text().then(function(contents) {
var keyMatch = contents.match(/key=(.*)/);
var emailMatch = contents.match(/email=(.*@.*)/);
var siteMatch = contents.match(/site=(.*)/);
if (!keyMatch || !emailMatch || !siteMatch) {
$("#zuliprc-help").text("Invalid file format.");
$("#save-integration").prop("disabled", true);
return
}
$("#zulip-api-key").val(keyMatch[1]);
$("#zulip-bot-email").val(emailMatch[1]);
$("#zulip-site").val(siteMatch[1]);
$("#zuliprc-help").text("");
$("#save-integration").prop("disabled", false);
});
})
});