Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions copyparty/web/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ if (1)
"cl_hpick": "tap on column headers to hide in the table below",
"cl_hcancel": "column hiding aborted",
"cl_rcm": "right-click menu",
"cl_gauto": "autogrid",

"ct_grid": '田 the grid',
"ct_ttips": '◔ ◡ ◔">ℹ️ tooltips',
Expand Down Expand Up @@ -282,6 +283,8 @@ if (1)
"tt_dynt": "autogrow as tree expands",
"tt_wrap": "word wrap",
"tt_hover": "reveal overflowing lines on hover$N( breaks scrolling unless mouse $N  cursor is in the left gutter )",
"tt_gauto": "display as grid or list depending on folder contents",
"tt_gathr": "use grid if this percentage of files are pics/vids",

"ml_pmode": "at end of folder...",
"ml_btns": "cmds",
Expand Down Expand Up @@ -936,6 +939,13 @@ ebi('op_cfg').innerHTML = (
' </div>\n' +
'</div>\n' +
'<div>\n' +
' <h3>' + L.cl_gauto + '</h3>\n' +
' <div>\n' +
' <a id="gauto" class="tgl btn" href="#" tt="' + L.tt_gauto + '">' + L.enable + '</a>\n' +
' <input type="text" id="ga_thresh" value="" ' + NOAC + ' style="width:1.5em" tt="' + L.tt_gathr + '" />' +
' </div>\n' +
'</div>\n' +
'<div>\n' +
' <h3>' + L.cl_hfsz + '</h3>\n' +
' <div><select id="fszfmt">\n' +
' <option value="0">0 ┃ 1234567</option>\n' +
Expand Down Expand Up @@ -5557,6 +5567,16 @@ var thegrid = (function () {
r.setvis();
};

r.autogrid = function (res) {
var ni = 0;
var nf = res.files.length;
for (var a = 0; a < nf; a++)
if (img_re.test('.' + res.files[a].ext))
ni++;
if (nf)
thegrid.en = 100 * ni / nf >= r.gathr;
};

function setln(v) {
if (v) {
r.ln += v;
Expand Down Expand Up @@ -5944,6 +5964,17 @@ var thegrid = (function () {
pbar.onresize();
vbar.onresize();
});
bcfg_bind(r, 'gaen', 'gauto', false, function(v) {
if (r.en && sread("griden") != 1) {
r.en = false;
r.setvis(true);
}
});
ebi('ga_thresh').value = r.gathr = icfg_get('ga_thresh', 70);
ebi('ga_thresh').oninput = function (e) {
var n = parseInt(this.value);
swrite('ga_thresh', r.gathr = (isNum(n) ? n : 0) || 70);
};
ebi('wtgrid').onclick = ebi('griden').onclick;

return r;
Expand Down Expand Up @@ -7656,6 +7687,9 @@ var treectl = (function () {
}
}

if (thegrid.gaen && sread('griden') != 1)
thegrid.autogrid(res);

if (url) setTimeout(asdf, 1); else asdf();
}

Expand Down