From 5718caa95790c50a6355e2e7000fce2d969d39f9 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 30 Oct 2024 19:24:00 +0000 Subject: [PATCH] ui: url-options to set grid/thumbs on/off --- README.md | 1 + copyparty/web/browser.js | 16 +++++++++++++++- docs/devnotes.md | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dfe8fd34..3c020c19 100644 --- a/README.md +++ b/README.md @@ -577,6 +577,7 @@ click the `🌲` or pressing the `B` hotkey to toggle between breadcrumbs path ( press `g` or `田` to toggle grid-view instead of the file listing and `t` toggles icons / thumbnails * can be made default globally with `--grid` or per-volume with volflag `grid` +* enable by adding `?imgs` to a link, or disable with `?imgs=0` ![copyparty-thumbs-fs8](https://user-images.githubusercontent.com/241032/129636211-abd20fa2-a953-4366-9423-1c88ebb96ba9.png) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index d40d9e37..4a7a809f 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -2118,8 +2118,9 @@ function set_files_html(html) { // actx breaks background album playback on ios var ACtx = !IPHONE && (window.AudioContext || window.webkitAudioContext), ACB = sread('au_cbv') || 1, - noih = /[?&]v\b/.exec('' + location), hash0 = location.hash, + sloc0 = '' + location, + noih = /[?&]v\b/.exec(sloc0), ldks = [], dks = {}, dk, mp; @@ -6047,6 +6048,19 @@ var thegrid = (function () { toast.warn(10, L.ul_btnlk); }; + if (/[?&]grid\b/.exec(sloc0)) + swrite('griden', /[?&]grid=0\b/.exec(sloc0) ? 0 : 1) + + if (/[?&]thumb\b/.exec(sloc0)) + swrite('thumbs', /[?&]thumb=0\b/.exec(sloc0) ? 0 : 1) + + if (/[?&]imgs\b/.exec(sloc0)) { + var n = /[?&]imgs=0\b/.exec(sloc0) ? 0 : 1; + swrite('griden', n); + if (n) + swrite('thumbs', 1); + } + bcfg_bind(r, 'thumbs', 'thumbs', true, r.setdirty); bcfg_bind(r, 'ihop', 'ihop', true); bcfg_bind(r, 'vau', 'gridvau', false); diff --git a/docs/devnotes.md b/docs/devnotes.md index af6e1117..71f3bba8 100644 --- a/docs/devnotes.md +++ b/docs/devnotes.md @@ -208,6 +208,12 @@ upload modifiers: | method | params | result | |--|--|--| | GET | `?pw=x` | logout | +| GET | `?grid` | ui: show grid-view | +| GET | `?imgs` | ui: show grid-view with thumbnails | +| GET | `?grid=0` | ui: show list-view | +| GET | `?imgs=0` | ui: show list-view | +| GET | `?thumb` | ui, grid-mode: show thumbnails | +| GET | `?thumb=0` | ui, grid-mode: show icons | # event hooks