function setupUser()

in site/js/dev/ponymail_user_preferences.js [154:254]


function setupUser() {
    var uimg = document.getElementById('uimg')
    if (!uimg) {
        return
    }
    uimg.setAttribute("src", URL_BASE + "/images/user.png")
    uimg.setAttribute("title", "Logged in as " + login.credentials.fullname)
    if (login.notifications && login.notifications > 0) {
        uimg.setAttribute("src", URL_BASE + "/images/user_notif.png")
        uimg.setAttribute("title", "Logged in as " + login.credentials.fullname + " - You have " + login.notifications + " new notifications!")
    }
    var pd = document.getElementById('prefs_dropdown')
    pd.innerHTML = ""
    
    // thread item
    var li = document.createElement("li")
    var a = document.createElement("a")
    var t = document.createTextNode("Start a new discussion")
    a.setAttribute("href", "javascript:void(0);")
    a.setAttribute("onclick", "compose(null, 'xlist')")
    a.appendChild(t)
    li.appendChild(a)
    pd.appendChild(li)
    
    
    // Prefs item
    var li = document.createElement("li")
    var a = document.createElement("a")
    var t = document.createTextNode((prefs.fullname ? prefs.fullname : login.credentials.fullname) + "'s preferences")
    a.setAttribute("href", "javascript:void(0);")
    a.setAttribute("onclick", "showPreferences()")
    a.appendChild(t)
    li.appendChild(a)
    pd.appendChild(li)
    
    // Notifications item
    var li = document.createElement("li")
    var a = document.createElement("a")
    var t = document.createTextNode("Notifications")
    a.setAttribute("href", URL_BASE + "/notifications.html")
    
    a.appendChild(t)
    if (login.notifications && login.notifications > 0) {
        a.setAttribute("style", "font-weight: bold;")
        t.nodeValue = "Notifications (" + login.notifications + ")"
        a.innerHTML += ' <span class="glyphicon glyphicon-star"> </span>'
    }
    
    li.appendChild(a)
    pd.appendChild(li)
    
    // Favorites
    if (login.favorites && login.favorites.length > 0) {
        var li = document.createElement("li")
        li.setAttribute("class", "dropdown-submenu pull-left")
        var a = document.createElement("a")
        var t = document.createTextNode("Favorite lists")
        a.setAttribute("href", "#")
        a.appendChild(t)
        var ul = document.createElement('ul')
        ul.setAttribute("class", "dropdown-menu")
        a.setAttribute("tabindex", "-1")
        li.appendChild(a)
        ul.style.left = "0"
        li.appendChild(ul)
        for (var i in login.favorites) {
            var l = login.favorites[i]
            var sli = document.createElement('li')
            sli.setAttribute("class", "pull-left")
            var st = document.createTextNode(l)
            var sa = document.createElement('a')
            sa.setAttribute("href", URL_BASE + "/list.html?" + l)
            sa.appendChild(st)
            sli.appendChild(sa)
            ul.appendChild(sli)
        }
        
        pd.appendChild(li)
    }
    
    
    // Merge accounts item
    var li = document.createElement("li")
    var a = document.createElement("a")
    var t = document.createTextNode("Manage email addresses")
    a.setAttribute("href", URL_BASE + "/merge.html")
    a.appendChild(t)
    
    li.appendChild(a)
    pd.appendChild(li)
    
    // Logout item
    var li = document.createElement("li")
    var a = document.createElement("a")
    var t = document.createTextNode("Log out")
    a.setAttribute("href", "javascript:void(0);")
    a.setAttribute("onclick", "logout()")
    a.appendChild(t)
    li.appendChild(a)
    pd.appendChild(li)
}