2022-04-05 16:04:26 +00:00
|
|
|
$(document).ready(function() {
|
2022-04-07 16:18:23 +00:00
|
|
|
|
|
|
|
$('#add-email-helper').click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
email = prompt("Destination email");
|
|
|
|
if(email) {
|
2022-04-22 08:51:52 +00:00
|
|
|
var n = $(".notification-urls");
|
2022-04-07 16:18:23 +00:00
|
|
|
var p=email_notification_prefix;
|
|
|
|
$(n).val( $.trim( $(n).val() )+"\n"+email_notification_prefix+email );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-04-05 16:04:26 +00:00
|
|
|
$('#send-test-notification').click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
// this can be global
|
|
|
|
var csrftoken = $('input[name=csrf_token]').val();
|
|
|
|
$.ajaxSetup({
|
|
|
|
beforeSend: function(xhr, settings) {
|
|
|
|
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
data = {
|
|
|
|
window_url : window.location.href,
|
2022-04-21 19:36:10 +00:00
|
|
|
notification_urls : $('.notification-urls').val(),
|
|
|
|
notification_title : $('.notification-title').val(),
|
|
|
|
notification_body : $('.notification-body').val(),
|
|
|
|
notification_format : $('.notification-format').val(),
|
2022-04-05 16:04:26 +00:00
|
|
|
}
|
|
|
|
for (key in data) {
|
|
|
|
if (!data[key].length) {
|
|
|
|
alert(key+" is empty, cannot send test.")
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: notification_base_url,
|
|
|
|
data : data
|
|
|
|
}).done(function(data){
|
|
|
|
console.log(data);
|
|
|
|
alert('Sent');
|
|
|
|
}).fail(function(data){
|
|
|
|
console.log(data);
|
|
|
|
alert('Error: '+data.responseJSON.error);
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|