sort-order indicators

This commit is contained in:
ed 2021-12-03 23:53:41 +01:00
parent 1521307f1e
commit f39f575a9c
3 changed files with 70 additions and 30 deletions

View file

@ -79,6 +79,25 @@ a, #files tbody div a:last-child {
color: #999;
font-weight: normal;
}
.s0:after,
.s1:after {
content: '⌄';
}
.s0r:after,
.s1r:after {
content: '⌃';
}
.s0:after,
.s0r:after {
color: #fb0;
}
.s1:after,
.s1r:after {
color: #d09;
}
#files thead th:after {
margin-right: -.8em;
}
#files tbody tr:hover td {
background: #1c1c1c;
}
@ -1042,7 +1061,6 @@ html.light #rui {
font-size: 1.5em;
}
#doc {
background: none;
overflow: visible;
margin: -1em 0 .5em 0;
padding: 1em 0 1em 0;
@ -1130,6 +1148,7 @@ a.btn,
html,
#doc,
#rui,
#files td,
#files thead th,
@ -1211,6 +1230,7 @@ html.light {
html.light #ops,
html.light .opbox,
html.light #path,
html.light #doc,
html.light #srch_form,
html.light .ghead,
html.light #u2etas {
@ -1288,6 +1308,14 @@ html.light #ops a,
html.light #files tbody div a:last-child {
color: #06a;
}
html.light .s0:after,
html.light .s0r:after {
color: #059;
}
html.light .s1:after,
html.light .s1r:after {
color: #f5d;
}
html.light #files thead th {
background: #eaeaea;
border-color: #ccc;

View file

@ -3907,7 +3907,7 @@ var treectl = (function () {
id = 'f-' + ('00000000' + crc32(fname)).slice(-8),
lang = showfile.getlang(fname);
while (seen[id])
while (seen[id]) // ejyefs ev69gg y9j8sg .opus
id += 'a';
seen[id] = 1;
@ -4426,27 +4426,6 @@ var mukey = (function () {
})();
function addcrc() {
var links = QSA(
'#files>tbody>tr>td:first-child+td>' + (
ebi('unsearch') ? 'div>a:last-child' : 'a'));
var seen = {}; // ejyefs ev69gg y9j8sg .opus
for (var a = 0, aa = links.length; a < aa; a++) {
var id = links[a].getAttribute('id');
if (!id) {
var crc = crc32(links[a].textContent || links[a].innerText);
id = 'f-' + ('00000000' + crc).slice(-8);
while (seen[id])
id += 'a';
links[a].setAttribute('id', id);
}
seen[id] = 1;
}
}
var light;
(function () {
function freshen() {
@ -5046,7 +5025,8 @@ function reload_browser() {
filecols.set_style();
var parts = get_evpath().split('/'),
rm = QSA('#path>a+a+a');
rm = QSA('#path>a+a+a'),
ftab = ebi('files');
for (a = rm.length - 1; a >= 0; a--)
rm[a].parentNode.removeChild(rm[a]);
@ -5068,9 +5048,9 @@ function reload_browser() {
oo[a].textContent = hsz;
}
addcrc();
reload_mp();
makeSortable(ebi('files'), mp.read_order.bind(mp));
try { showsort(ftab); } catch (ex) { }
makeSortable(ftab, mp.read_order.bind(mp));
for (var a = 0; a < 2; a++)
clmod(ebi(a ? 'pro' : 'epi'), 'hidden', ebi('unsearch'));

View file

@ -329,14 +329,45 @@ function clgot(el, cls) {
}
function showsort(tab) {
var v, vn, v1, v2, th = tab.tHead,
sopts = jread('fsort', [["href", 1, ""]]);
th && (th = th.rows[0]) && (th = th.cells);
for (var a = sopts.length - 1; a >= 0; a--) {
if (!sopts[a][0])
continue;
v2 = v1;
v1 = sopts[a];
}
v = [v1, v2];
vn = [v1 ? v1[0] : '', v2 ? v2[0] : ''];
var ga = QSA('#ghead a[s]');
for (var a = 0; a < ga.length; a++)
ga[a].className = '';
for (var a = 0; a < th.length; a++) {
var n = vn.indexOf(th[a].getAttribute('name')),
cl = n < 0 ? ' ' : ' s' + n + (v[n][1] > 0 ? ' ' : 'r ');
th[a].className = th[a].className.replace(/ *s[01]r? */, ' ') + cl;
if (n + 1) {
ga = QS('#ghead a[s="' + vn[n] + '"]');
if (ga)
ga.className = cl;
}
}
}
function sortTable(table, col, cb) {
var tb = table.tBodies[0],
th = table.tHead.rows[0].cells,
tr = Array.prototype.slice.call(tb.rows, 0),
i, reverse = th[col].className.indexOf('sort1') !== -1 ? -1 : 1;
for (var a = 0, thl = th.length; a < thl; a++)
th[a].className = th[a].className.replace(/ *sort-?1 */, " ");
th[col].className += ' sort' + reverse;
i, reverse = /s0[^r]/.exec(th[col].className + ' ') ? -1 : 1;
var stype = th[col].getAttribute('sort');
try {
var nrules = [], rules = jread("fsort", []);
@ -354,6 +385,7 @@ function sortTable(table, col, cb) {
break;
}
jwrite("fsort", nrules);
try { showsort(table); } catch (ex) { }
}
catch (ex) {
console.log("failed to persist sort rules, resetting: " + ex);