90 lines
2.9 KiB
JavaScript
90 lines
2.9 KiB
JavaScript
(function () {
|
|
"use strict";
|
|
|
|
var messageBanner;
|
|
|
|
// La funzione di inizializzazione di Office deve essere eseguita ogni volta che viene caricata una nuova pagina.
|
|
Office.initialize = function (reason) {
|
|
$(document).ready(function () {
|
|
var element = document.querySelector('.MessageBanner');
|
|
messageBanner = new components.MessageBanner(element);
|
|
messageBanner.hideBanner();
|
|
loadProps();
|
|
});
|
|
};
|
|
|
|
// Accetta una matrice di oggetti AttachmentDetails e crea un elenco di nomi di allegato separati da un'interruzione di riga.
|
|
function buildAttachmentsString(attachments) {
|
|
if (attachments && attachments.length > 0) {
|
|
var returnString = "";
|
|
|
|
for (var i = 0; i < attachments.length; i++) {
|
|
if (i > 0) {
|
|
returnString = returnString + "<br/>";
|
|
}
|
|
returnString = returnString + attachments[i].name;
|
|
}
|
|
|
|
return returnString;
|
|
}
|
|
|
|
return "None";
|
|
}
|
|
|
|
// Consente di formattare un oggetto EmailAddressDetails come
|
|
// Nome Cognome <indirizzo di posta elettronica>
|
|
function buildEmailAddressString(address) {
|
|
return address.displayName + " <" + address.emailAddress + ">";
|
|
}
|
|
|
|
// Accetta una matrice di oggetti EmailAddressDetails e
|
|
// crea un elenco di stringhe formattate separate da un'interruzione di riga
|
|
function buildEmailAddressesString(addresses) {
|
|
if (addresses && addresses.length > 0) {
|
|
var returnString = "";
|
|
|
|
for (var i = 0; i < addresses.length; i++) {
|
|
if (i > 0) {
|
|
returnString = returnString + "<br/>";
|
|
}
|
|
returnString = returnString + buildEmailAddressString(addresses[i]);
|
|
}
|
|
|
|
return returnString;
|
|
}
|
|
|
|
return "None";
|
|
}
|
|
|
|
// Carica prima le proprietà dall'oggetto di base Item e quindi
|
|
// le proprietà specifiche del messaggio.
|
|
function loadProps() {
|
|
var item = Office.context.mailbox.item;
|
|
|
|
$('#dateTimeCreated').text(item.dateTimeCreated.toLocaleString());
|
|
$('#dateTimeModified').text(item.dateTimeModified.toLocaleString());
|
|
$('#itemClass').text(item.itemClass);
|
|
$('#itemId').text(item.itemId);
|
|
$('#itemType').text(item.itemType);
|
|
|
|
$('#message-props').show();
|
|
|
|
$('#attachments').html(buildAttachmentsString(item.attachments));
|
|
$('#cc').html(buildEmailAddressesString(item.cc));
|
|
$('#conversationId').text(item.conversationId);
|
|
$('#from').html(buildEmailAddressString(item.from));
|
|
$('#internetMessageId').text(item.internetMessageId);
|
|
$('#normalizedSubject').text(item.normalizedSubject);
|
|
$('#sender').html(buildEmailAddressString(item.sender));
|
|
$('#subject').text(item.subject);
|
|
$('#to').html(buildEmailAddressesString(item.to));
|
|
}
|
|
|
|
// Funzione helper per la visualizzazione delle notifiche
|
|
function showNotification(header, content) {
|
|
$("#notificationHeader").text(header);
|
|
$("#notificationBody").text(content);
|
|
messageBanner.showBanner();
|
|
messageBanner.toggleExpansion();
|
|
}
|
|
})(); |