in site/js/dev/ponymail_listview_tree.js [417:502]
function toggleEmails_treeview(id, close, toverride) {
current_thread_mids = {}
current_email_msgs = []
var thread = document.getElementById('thread_treeview_' + id.toString().replace(/@<.+>/, ""))
if (thread) {
current_thread = id
if (!current_thread_json[id].children || typeof current_thread_json[id].children.length == 'undefined' || current_thread_json[id].children.length == 0) {
toggleEmails_threaded(id, close, toverride, thread)
return
}
var epoch = null
if (localStorageAvailable) {
epoch = latestEmailInThread + "!"
var xx = window.localStorage.getItem("viewed_" + current_thread_json[id].tid)
if (xx) {
var yy = parseInt(xx)
if (yy >= parseInt(latestEmailInThread)) {
epoch = yy
}
}
}
thread.style.display = (thread.style.display == 'none') ? 'block' : 'none';
var helper = document.getElementById('helper_' + id)
if (!helper) {
helper = document.createElement('div')
helper.setAttribute("id", "helper_" + id)
helper.style.padding = "10px"
thread.parentNode.insertBefore(helper, thread)
}
// time travel magic!
helper.innerHTML = ""
thread.innerHTML = ""
var ml = findEml(current_thread_json[id].tid)
if (!current_thread_json[id].magic && ml.irt && ml.irt.length > 0) {
helper.innerHTML += "<p id='magic_"+id+"'><i><b>Note:</b> You are viewing a search result/aggregation in threaded mode. Only results matching your keywords or dates are shown, which may distort the thread. For the best result, go to the specific list and view the full thread there, or view your search results in flat mode. Or we can <a href='javascript:void(0);' onclick='timeTravelList("+id+")'>do some magic for you</a>.</i></p>"
var btn = document.createElement('a')
btn.setAttribute("href", "javascript:void(0);")
btn.setAttribute("class", "btn btn-success")
btn.setAttribute("onclick", "prefs.displayMode='flat'; buildPage();")
btn.style.marginRight = "10px"
btn.innerHTML = "View results in flat mode instead"
helper.appendChild(btn)
} else if (!current_thread_json[id].magic) {
helper.innerHTML += "<p id='magic_"+id+"'></p>"
}
if (close == true) {
thread.style.display = 'none'
}
if (thread.style.display == 'none') {
helper.style.display = 'none'
prefs.groupBy = 'treeview' // hack for now
thread.innerHTML = ""
if (document.getElementById('bubble_' + id)) {
document.getElementById('bubble_' + id).style.display = 'block'
}
return
} else {
helper.style.display = 'block'
if (document.getElementById('bubble_' + id)) {
document.getElementById('bubble_' + id).style.display = 'none'
}
}
if (!open_emails[id]) {
open_emails[id] = true
}
// build treeview, set guard
var nesting = 0
treeview_guard = {}
var html = buildTreeview(nesting, [current_thread_json[id]], thread, [true])
current_thread = current_thread_json[id].tid
if (epoch !== null && localStorageAvailable) { // only non-null if localstorage works, but check anyway for consistency
try {
window.localStorage.setItem("viewed_" + current_thread_json[id].tid, epoch)
} catch(e) {
}
}
}
}