diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 891335a4..1f393127 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -269,6 +269,7 @@ if (1) "cdt_ask": "when scrolling to the bottom,$Ninstead of loading more files,$Nask what to do", "cdt_hsort": "how many sorting rules (<code>,sorthref</code>) to include in media-URLs. Setting this to 0 will also ignore sorting-rules included in media links when clicking them", "cdt_ren": "enable custom right-click menu, you can still access the regular menu by pressing the shift key and right-clicking", + "cdt_rdb": "show the regular right-click menu when the custom one is already open and right-clicking again", "tt_entree": "show navpane (directory tree sidebar)$NHotkey: B", "tt_detree": "show breadcrumbs$NHotkey: B", @@ -650,7 +651,7 @@ if (1) "rc_ply": "play", "rc_pla": "play as audio", "rc_txt": "open in textfile viewer", - "rc_md": "open in text editor", + "rc_md": "open in markdown viewer", "rc_dl": "download", "rc_zip": "download as archive", "rc_cpl": "copy link", @@ -658,6 +659,7 @@ if (1) "rc_cut": "cut", "rc_cpy": "copy", "rc_pst": "paste", + "rc_rnm": "rename", "rc_nfo": "new folder", "rc_nfi": "new file", "rc_sal": "select all", @@ -990,7 +992,7 @@ ebi('op_cfg').innerHTML = ( ' \n' + '\n' + '

' + L.cl_keytype + '

\n' + - (!MOBILE ? '

' + L.cl_rcm + '

enable
' : '') + + (!MOBILE ? '

' + L.cl_rcm + '

enabledouble
' : '') + '

' + L.cl_hiddenc + '  ' + (MOBILE ? '' + L.cl_hidec + ' / ' : '') + '' + L.cl_reset + '

' ); @@ -1034,13 +1036,12 @@ ebi('rcm').innerHTML = ( '' + L.rc_zip + '' : '') + '
' + - (has(perms, "move") ? - '' + L.rc_del + '' + - '' + L.rc_cut + '' - : '') + + (have_del ? '' + L.rc_del + '' : '') + + (have_mv ? '' + L.rc_cut + '' : '') + '' + L.rc_cpy + '' + (has(perms, "write") ? '' + L.rc_pst + '' + + (have_mv ? '' + L.rc_rnm + '' : '') + '
' + '' + L.rc_nfo + '' + '' + L.rc_nfi + '' @@ -9480,9 +9481,11 @@ var rcm = (function () { return {enabled: false} var r = { - enabled: true + enabled: true, + double: false }; bcfg_bind(r, 'enabled', 'ren', true); + bcfg_bind(r, 'double', 'rdb', false); var menu = ebi('rcm'); var nsFile = { @@ -9556,7 +9559,7 @@ var rcm = (function () { case 'ply': selFile.type == 'gf' ? thegrid.imshow(selFile.relpath) : play('f-' + selFile.id); break; case 'pla': play('f-' + selFile.id); break; case 'txt': location = '?doc=' + selFile.relpath; break; - case 'md': location = selFile.path + '?v'; break; + case 'md': location = selFile.path + (has(selFile.path, '?') ? '&v' : '?v'); break; case 'cpl': cliptxt(selFile.url, function() {toast.ok(2, L.clipped)}); break; case 'dl': ebi('seldl').click(); break; case 'zip': ebi('selzip').click(); break; @@ -9567,6 +9570,7 @@ var rcm = (function () { fileman.paste(); fileman.clip = []; break; + case 'rnm': fileman.rename(); break; case 'nfo': mktemp(true); break; case 'nfi': mktemp(); break; case 'sal': @@ -9593,8 +9597,8 @@ var rcm = (function () { selFile.elem = file; selFile.url = file.children[1].firstChild.href; - selFile.path = basenames(selFile.url).split('?')[0]; - selFile.relpath = selFile.path.split('/').slice(-1)[0]; + selFile.path = basenames(selFile.url).replace(/(&|\?)v/, ''); + selFile.relpath = selFile.path.split('/').slice(-1)[0].split("?")[0]; if (noq_href(file.children[1].firstChild).endsWith("/")) selFile.type = "dir"; else { @@ -9604,6 +9608,7 @@ var rcm = (function () { } } } + console.log(selFile); msel.selui(); var has_sel = msel.getsel().length; @@ -9614,7 +9619,7 @@ var rcm = (function () { clmod(ebi('rpla'), 'hide', selFile.type != 'gf'); clmod(ebi('rtxt'), 'hide', !selFile.id); clmod(ebi('rs1'), 'hide', !selFile.path); - clmod(ebi('rmd'), 'hide', !selFile.id || selFile.path.slice(-3) != '.md'); + clmod(ebi('rmd'), 'hide', !selFile.id || selFile.relpath.slice(-3) != ".md"); clmod(ebi('rcpl'), 'hide', !selFile.path); clmod(ebi('rdl'), 'hide', !has_sel); clmod(ebi('rzip'), 'hide', !has_sel); @@ -9623,7 +9628,9 @@ var rcm = (function () { clmod(ebi('rdel'), 'hide', !has_sel); clmod(ebi('rcpy'), 'hide', !has_sel); clmod(ebi('rpst'), 'hide', !has_clip); - clmod(ebi('rs3'), 'hide', !has_sel || !has_clip); + clmod(ebi('rrnm'), 'hide', !has_sel); + clmod(ebi('rs3'), 'hide', !has_sel); + clmod(ebi('rs4'), 'hide', !has_sel && !has(perms, "write")); menu.style.left = x + 5 + 'px'; menu.style.top = y + 5 + 'px'; @@ -9631,7 +9638,7 @@ var rcm = (function () { menu.focus(); } - r.hide = function (force) { + r.hide = function(force) { if (!menu.style.display || (!force && menu.contains(document.activeElement))) return; if (selFile.elem && !selFile.no_dsel) { @@ -9643,10 +9650,14 @@ var rcm = (function () { } ebi('wrap').oncontextmenu = function(e) { - if (!r.enabled || e.shiftKey || menu.style.display) { - r.hide(true); + r.hide(true); + if (!r.enabled || e.shiftKey || (r.double && menu.style.display)) { return true; } + if (selFile.elem && !selFile.no_dsel) { + clmod(selFile.elem, "sel", false); + msel.selui(); + } ev(e); var gfile = thegrid.en && e.target && e.target.closest('#ggrid > a'); show(xscroll() + e.clientX, yscroll() + e.clientY, gfile || e.target, gfile);