in webui/js/ponymail.js [3264:3377]
function init_preferences(state, json) {
G_ponymail_preferences = json || {};
// First, load session local settings, if possible
if (G_can_store) {
let local_preferences = window.localStorage.getItem('G_ponymail_preferences');
if (local_preferences) {
let ljson = JSON.parse(local_preferences);
if (ljson.G_chatty_layout !== undefined) {
G_chatty_layout = ljson.G_chatty_layout;
}
if (ljson.G_current_listmode !== undefined) {
G_current_listmode = ljson.G_current_listmode;
}
if (ljson.G_current_listmode_compact !== undefined) {
G_current_listmode_compact = ljson.G_current_listmode_compact;
}
if (ljson.G_show_stats_sidebar !== undefined) {
G_show_stats_sidebar = ljson.G_show_stats_sidebar;
}
}
}
// Set chatty/plain email rendering mode:
let cl = document.getElementById('chatty_link'); // legacy button
if (cl) {
cl.setAttribute("class", G_chatty_layout ? "enabled" : "disabled");
}
let cle = document.getElementById('email_mode_chatty');
if (cle) {
cle.checked = G_chatty_layout;
}
let cld = document.getElementById('email_mode_plain');
if (cld) {
cld.checked = !G_chatty_layout;
}
let cla = document.getElementById('G_show_stats_sidebar');
if (cla) {
cla.checked = G_show_stats_sidebar;
}
// Set list display mode:
let dmt = document.getElementById('display_mode_threaded');
if (dmt) {
dmt.checked = (G_current_listmode == 'threaded');
}
let dmf = document.getElementById('display_mode_flat');
if (dmf) {
dmf.checked = (G_current_listmode == 'flat');
}
let dmtr = document.getElementById('display_mode_treeview');
if (dmtr) {
dmtr.checked = (G_current_listmode == 'treeview');
}
// Compact list view
let dmc = document.getElementById('display_mode_compact');
if (dmc) {
dmc.checked = G_current_listmode_compact;
}
if (G_ponymail_preferences.login && G_ponymail_preferences.login.credentials) {
let prefsmenu = document.getElementById('login_dropdown') || document.getElementById('prefs_dropdown');
let uimg = document.getElementById('uimg');
uimg.setAttribute("src", "images/user.png");
uimg.setAttribute("title", "Logged in as %s".format(G_ponymail_preferences.login.credentials.fullname));
// Generate user menu
prefsmenu.innerHTML = "";
let logout = new HTML('a', {
href: "javascript:void(logout());"
}, "Log out");
let li = new HTML('li', {}, logout)
prefsmenu.inject(li);
} else {
let prefsmenu = document.getElementById('login_dropdown') || document.getElementById('prefs_dropdown');
if (prefsmenu) {
prefsmenu.innerHTML = "";
let login = new HTML('a', {
href: "javascript:location.href='oauth.html';"
}, "Log In");
let li = new HTML('li', {}, login)
prefsmenu.inject(li);
}
}
if (json) {
listview_list_lists(state, json);
if (state && state.prime) {
// If lists is accessible, show it
if (json.lists[G_current_domain] && (G_current_list == '*' || json.lists[G_current_domain][G_current_list] != undefined)) {
post_prime(state);
} else if (G_current_domain == '*') { // assume a match
post_prime(state);
} else { // otherwise, bork
if (G_current_list.length > 0 && (!json.lists[G_current_domain] || Object.keys(json.lists[G_current_domain]).length > 0)) {
let eml = document.getElementById('emails');
eml.innerText = "We couldn't find this list. It may not exist or require you to be logged in with specific credentials.";
eml.inject(new HTML('br'));
eml.inject(new HTML('a', {
href: 'oauth.html',
onclick: 'location.href="oauth.html";'
}, "Click here to log in via OAuth"));
} else {
switch_project(G_current_domain);
}
}
}
}
}