var baseURL = window.location.protocol + '//' + window.location.host; var navBarOffset = 75; var mediumDeviceWidth = 980; var messageListMargin = 275; var clipboard = null; var messageListScroll = false; var messageListData = null; var seenDelay = null; // clearMessageSearch resets the message list search function clearMessageSearch() { $('#message-search').val(''); updateMessageSearch(); } // deleteMessage sends a delete request for a message function deleteMessage(id) { $('#message-content').empty(); $.ajax({ type: 'DELETE', url: '/api/v1/mailbox/' + mailbox + '/' + id, success: loadList }) } // deleteMailbox clears the mailbox function deleteMailbox() { if (confirm("Are you sure you want delete this mailbox?")) { $.ajax({ type: 'DELETE', url: '/api/v1/mailbox/' + mailbox, success: loadList }) } } // flashTooltip temporarily changes the text of a tooltip function flashTooltip(el, text) { var prevText = $(el).attr('data-original-title'); $(el).attr('data-original-title', text).tooltip('show'); $(el).attr('data-original-title', prevText); } // htmlView pops open another window for viewing message as HTML function htmlView(id) { window.open('/mailbox/' + mailbox + '/' + id + "/html", '_blank', 'width=800,height=600,' + 'menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes'); } // loadList loads the message list for this mailbox via AJAX function loadList() { $('#message-list').hide().empty(); $.ajax({ dataType: "json", url: '/api/v1/mailbox/' + mailbox, success: function(data) { messageListData = data.reverse(); for (i=0; i mediumDeviceWidth) { var content_height = $(window).height() - messageListMargin; var messageListWrapper = $('#message-list-wrapper'); messageListWrapper.height(content_height); if (!messageListScroll) { messageListScroll = true; messageListWrapper.addClass("message-list-scroll"); } } else { if (messageListScroll) { messageListScroll = false; $('#message-list-wrapper').height('auto').removeClass("message-list-scroll"); } } } // updateMessageSearch compares the message list subjects and senders against // the search string and hides entries that don't match function updateMessageSearch() { var criteria = $('#message-search').val(); if (criteria.length < 2) { $('.message-list-entry').show(); return; } criteria = criteria.toLowerCase(); for (i=0; i -1) || (entry.from.toLowerCase().indexOf(criteria) > -1)) { // Match $('#' + entry.id).show(); } else { $('#' + entry.id).hide(); } } } // markSeen notifies the server that this message has been seen by the user. function markSeen(id) { for (i=0; i