in site/js/notifications.js [48:116]
function renderNotifications(json) {
var now = new Date().getTime() / 1000
var deep = true
// Do we have notifications to show?
if (json.notifications && json.notifications.length > 0) {
current_flat_json = json.notifications
// Make an unordered list, dirty innerHTML style for now.
var nest = "<ul style='text-align: left;'>"
for (var i in current_flat_json) {
var notif = current_flat_json[i]
if (!notif.epoch) {
continue;
}
var eml = notif
current_thread_json[i] = eml
if (eml.subject.length > 90) {
eml.subject = eml.subject.substr(0, 90) + "..."
}
var pmid = eml.nid
eml.mid = eml.id
// Have we read this notification already? if not, bold it.
var bold = eml.seen == 0 ? 'bold' : 'normal'
var ld = 'default'
var ti = ''
if (eml.epoch > (now - 86400)) {
ld = 'warning'
ti = "Has activity in the past 24 hours"
}
// This sets the list the notif is from and shortens the subject line
if (deep && typeof eml.list != undefined && eml.list != null) {
var elist = (eml.list ? eml.list : "").replace(/[<>]/g, "").replace(/^([^.]+)\./, "$1@")
var elist2 = eml.list.replace(/[<>]/g, "").replace(/^([^.]+)\./, "$1@")
if (pm_config.shortLists) {
elist = elist.replace(/\.[^.]+\.[^.]+$/, "")
}
d = "<a href='list.html?" + elist2 + "' style='float: left; margin-right: 4px;'><label class='label label-warning'>" + elist + "</label></a> "
if (eml.subject.length > 75) {
eml.subject = eml.subject.substr(0, 75) + "..."
}
}
// Convert email date into locale format, firefox or ecma style.
mdate = new Date(eml.epoch * 1000)
mdate = mdate.toLocaleFormat ? mdate.toLocaleFormat('%Y-%m-%d %T') : mdate.toLocaleString('en-GB', {
hour12: false
})
// Escape HTML and make the From header have just the sender name
var subject = eml.subject.replace(/</mg, "<")
var from = eml.from.replace(/<.*>/, "").length > 0 ? eml.from.replace(/<.*>/, "") : eml.from.replace(/[<>]+/g, "")
from = from.replace(/\"/g, "")
// If not viewed, add a hasSeen callback inside it when clicked
var extras = ""
if (eml.seen == 0 ) {
extras = "hasSeen(\"" + pmid + "\", " + i + "); "
}
// Add notif to list
nest += "<li class='list-group-item' style='font-weight: " + bold + ";' id='notif_" + i + "'> <a href='javascript:void(0);' onclick='" + extras + "toggleEmails_threaded(" + i + "); timeTravelList("+i+", "+ eml.epoch + ");'>" + subject + "</a> " + d + " <label style='float: left; width: 140px;' class='label label-info'>" + from + "</label><label style='float: right; width: 140px;' class='label label-" + ld + "' title='" + ti + "'>(" + mdate + ")</label><div id='thread_" + i + "' style='display:none';></div></li>"
}
nest += "</ul>"
document.getElementById('notifications').innerHTML = nest
} else {
document.getElementById('notifications').innerHTML = "There don't seem to be any notifications for you yet."
}
}