in site/js/ponymail.js [3141:3267]
function buildTreeview(nesting, list, obj, pbigger) {
var now = new Date().getTime() / 1000
for (var i in list) {
var nvi = ""
// We'll nest to a max depth of 20, to not explode everything
for (var z = 1; z <= Math.min(nesting, 20); z++) {
if (z == nesting) {
if (i == (list.length -1)) {
nvi += "<img src='images/treeview_lastchild.png' style='height: 40px; width: 16px; overflow: hidden; margin-top: -5px;'/>"
} else {
nvi += "<img src='images/treeview_child.png' style='height: 40px; width: 16px; overflow: hidden; margin-top: -5px;'/>"
}
} else if (pbigger[z+1]) {
nvi += "<img src='images/treeview_parent.png' style='height: 40px; width: 16px; overflow: hidden;margin-top: -5px;'/>"
} else {
nvi += "<img src='images/treeview_none.png' style='height: 40px; width: 16px; overflow: hidden;margin-top: -5px;'/>"
}
}
var el = list[i]
var friendly_id = (el.tid ? el.tid : el.mid).toString().replace(/@<.+>/, "")
var node = document.createElement('div')
node.setAttribute("id", "thread_parent_" + friendly_id)
var nest = ""
var eml = findEml(el.tid)
if (eml && eml.subject.length > 90) {
eml.subject = eml.subject.substr(0, 90) + "..."
}
var subs = countSubs(el)
var people = countParts(el)
var latest = countNewest(el)
var ls = 'default'
if (subs > 0) {
ls = 'primary'
}
var lp = 'success'
if (people > 1) {
lp = 'success'
}
var ld = 'default'
var ti = ''
if (latest > (now - 86400)) {
ld = 'warning'
ti = "Has activity in the past 24 hours"
}
var d = ''
var estyle = ""
var qdeep = document.getElementById('checkall') ? document.getElementById('checkall').checked : false
if ((qdeep || global_deep) && current_query.length > 0) {
eml.list = eml.list ? eml.list : eml.list_raw // Sometimes, .list isn't available
var elist = eml.list.replace(/[<>]/g, "").replace(/^([^.]+)\./, "$1@")
var elist2 = elist
if (pm_config.shortLists) {
elist = elist.replace(/\.[^.]+\.[^.]+$/, "")
}
d = "<a href='list.html?" + elist2 + "'><label class='label label-warning' style='width: 150px;'>" + elist + "</label></a> "
if (eml.subject.length > 75) {
eml.subject = eml.subject.substr(0, 75) + "..."
}
}
var subject = eml.subject.replace(/</mg, "<")
var mdate = formatEpochUTC(latest)
var pds = people > 1 ? "visible" : "hidden"
ld = 'default'
var ti = ''
if (eml.epoch > (now - 86400)) {
ld = 'warning'
ti = "Has activity in the past 24 hours"
}
var d = ""
var qdeep = document.getElementById('checkall') ? document.getElementById('checkall').checked : false
if (qdeep || global_deep && typeof eml.list != undefined && eml.list != null) {
var elist = (eml.list ? eml.list : "").replace(/[<>]/g, "").replace(/^([^.]+)\./, "$1@")
var elist2 = elist
if (pm_config.shortLists) {
elist = elist.replace(/\.[^.]+\.[^.]+$/, "")
}
var d = "<a href='list.html?" + elist2 + "'><label class='label label-warning' style='width: 150px;'>" + elist + "</label></a> "
if (eml.subject.length > 75) {
eml.subject = eml.subject.substr(0, 75) + "..."
}
}
mdate = formatEpochUTC(eml.epoch)
var subject = eml.subject.replace(/</mg, "<")
var from = eml.from.replace(/<.*>/, "").length > 0 ? eml.from.replace(/<.*>/, "") : eml.from.replace(/[<>]+/g, "")
from = from.replace(/\"/g, "")
// style based on view before or not??
var estyle = ""
if (localStorageAvailable) {
if (! window.localStorage.getItem("viewed_" + eml.id) ){
estyle = "font-weight: bold;"
}
}
var at = ""
if (eml.attachments && eml.attachments > 0) {
at = "<img src='images/attachment.png' title='" + eml.attachments + " file(s) attached' style='title='This email has attachments'/> "
}
var nw = (16*Math.min(nesting, 20)) + 130
nest += "<li class='list-group-item' style='min-height: 38px !important; border: none; padding: 0px; margin: 0px; padding-top: 5px; padding-bottom: -5px;'><div style='float: left; margin-top: -8px;'>" +
nvi + "</div>" + "<div style='width: calc(99% - "+nw+"px); page-break: avoid; white-space: nowrap; overflow: hidden; float:left;'>" + at + "<span style='padding-top: 4px;'><a style='" + estyle + "' href='thread.html/" +
(pm_config.shortLinks ? shortenID(eml.id) : encodeURIComponent(eml.id)) + "' onclick='this.style=\"padding-top: 4px; padding-bottom: -4px;\"; loadEmails_flat(\"" +
el.tid + "\", false, \""+friendly_id+"\"); return false;'>" + subject + "</a></span> "+
"<label style='width: 140px;' class='label label-info'>" + from + "</label></div>" +
"<label style='float: right; position:absolute;right:4px;top:10px;width: 110px; margin-top: 6px;' class='label label-" + ld + "' title='" + ti + "'>" + mdate +
"</label><div id='thread_" + friendly_id + "' style='display: none;'></div></li>"
node.innerHTML = nest
// Guard against double post errors from time travel
if (!treeview_guard[friendly_id]) {
obj.appendChild(node)
}
treeview_guard[friendly_id] = true
if (el.children && el.children.length > 0) {
var npbigger = pbigger.slice()
npbigger.push(i < (list.length-1))
buildTreeview(nesting+1, el.children, obj, npbigger)
}
}
}