73 lines
2.0 KiB
JavaScript
73 lines
2.0 KiB
JavaScript
// Generated by CoffeeScript 1.12.7
|
|
|
|
/*
|
|
LemonLDAP::NG Notifications script
|
|
*/
|
|
|
|
(function() {
|
|
var displayError, setMsg, viewNotif;
|
|
|
|
setMsg = function(msg, level) {
|
|
$('#msg').html(window.translate(msg));
|
|
$('#color').removeClass('message-positive message-warning alert-success alert-warning');
|
|
$('#color').addClass("message-" + level);
|
|
if (level === 'positive') {
|
|
level = 'success';
|
|
}
|
|
return $('#color').addClass("alert-" + level);
|
|
};
|
|
|
|
displayError = function(j, status, err) {
|
|
var res;
|
|
console.log('Error', err);
|
|
res = JSON.parse(j.responseText);
|
|
if (res && res.error) {
|
|
console.log('Returned error', res);
|
|
return setMsg(res, 'warning');
|
|
}
|
|
};
|
|
|
|
viewNotif = function(notif, epoch) {
|
|
console.log('Ref:', notif, 'epoch:', epoch);
|
|
if (notif && epoch) {
|
|
console.log('Send AJAX request');
|
|
return $.ajax({
|
|
type: "GET",
|
|
url: portal + "mynotifs/" + notif,
|
|
data: {
|
|
epoch: epoch
|
|
},
|
|
dataType: 'json',
|
|
success: function(resp) {
|
|
var myDate;
|
|
if (resp.result) {
|
|
console.log('Notification:', resp.notification);
|
|
$('#displayNotif').html(resp.notification);
|
|
$("#myNotification").removeAttr('hidden');
|
|
$('#notifRef').text(notif);
|
|
myDate = new Date(epoch * 1000);
|
|
return $('#notifEpoch').text(myDate.toLocaleString());
|
|
} else {
|
|
return setMsg('notificationNotFound', 'warning');
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
return setMsg('notificationRetreiveFailed', 'warning');
|
|
}
|
|
};
|
|
|
|
$(document).ready(function() {
|
|
$('body').on('click', '.btn-success', function() {
|
|
return viewNotif($(this).attr('notif'), $(this).attr('epoch'));
|
|
});
|
|
$('#goback').attr('href', portal);
|
|
return $(".data-epoch").each(function() {
|
|
var myDate;
|
|
myDate = new Date($(this).text() * 1000);
|
|
return $(this).text(myDate.toLocaleString());
|
|
});
|
|
});
|
|
|
|
}).call(this);
|