in webui/js/source/listview-header.js [20:118]
function listview_header(state, json) {
if (isEmpty(json)) { // Bad search request?
modal("Bad search request", "Your request could not be parsed.", "warning");
return;
}
let list_title = json.list;
prev_listview_json = json;
prev_listview_state = state;
if (G_current_list == 'virtual' && G_current_domain == 'inbox') {
list_title = "Virtual inbox, past 30 days";
}
let blobs = json.emails ? json.emails : [];
if (G_current_listmode == 'threaded' || G_current_listmode == 'treeview') blobs = json.thread_struct;
if (G_current_year && G_current_month) {
list_title += ", %s %u".format(MONTHS[G_current_month - 1], G_current_year);
} else {
list_title += ", past month";
}
if (json.searchParams && (
json.searchParams.q &&
json.searchParams.q.length ||
(json.searchParams.d || "").match(/=/))
){
list_title = "Custom search";
}
document.title = list_title + " - " + prefs.title;
document.getElementById('listview_title').innerText = list_title + ":";
let download = new HTML('button', {
title: 'Download as mbox archive',
download: 'true'
}, new HTML('span', {
class: 'glyphicon glyphicon-save'
}, " "));
document.getElementById('listview_title').inject(download);
download.addEventListener('click', () => {
let sep = '?';
let dl_url = G_apiURL + 'api/mbox.lua';
for (let key in json.searchParams || {}) {
dl_url += sep + key + "=" + encodeURIComponent(json.searchParams[key]);
sep = '&';
}
location.href = dl_url;
});
let chevrons = document.getElementById('listview_chevrons');
G_current_per_page = calc_per_page();
G_current_index_pos = state.pos || 0;
let first = 1;
if (state && state.pos) {
first = 1 + state.pos;
}
if (!blobs || blobs.length == 0) {
chevrons.innerHTML = "No topics to show";
blobs = [];
} else {
chevrons.innerHTML = "Showing <b>%u through %u</b> of <b>%u</b> topics ".format(first, Math.min(first + G_current_per_page - 1, blobs.length), blobs.length || 0);
}
let pprev = Math.max(0, first - G_current_per_page - 1);
let cback = new HTML('button', {
onclick: 'listview_header({pos: %u}, G_current_json);'.format(pprev),
disabled: (first == 1) ? 'true' : null
}, new HTML('span', {
class: 'glyphicon glyphicon-chevron-left'
}, " "));
chevrons.inject(cback);
let pnext = first + G_current_per_page - 1;
let cforward = new HTML('button', {
onclick: 'listview_header({pos: %u}, G_current_json);'.format(pnext),
disabled: (first + G_current_per_page - 1 >= blobs.length) ? 'true' : null
}, new HTML('span', {
class: 'glyphicon glyphicon-chevron-right'
}, " "));
chevrons.inject(cforward);
let crefresh = new HTML('button', {
onclick: 'parseURL({noprefs: true});',
title: 'Refresh results',
style: {
marginLeft: '8px'
}
}, new HTML('span', {
class: 'glyphicon glyphicon-refresh'
}, " "));
chevrons.inject(crefresh);
if (state && state.pos != undefined) {
if (G_current_listmode == 'threaded') {
listview_threaded(json, state.pos);
} else if (G_current_listmode == 'flat') {
listview_flat(json, state.pos);
} else {
listview_treeview(json, state.pos);
}
}
}