diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 61514329..fc6644b3 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -760,6 +760,61 @@ ebi('ops').innerHTML = ( '
' ); +// mkdir + md +function mktemp(is_dir) { + qsr('#rcm_tmp'); + if (!thegrid.en) { + var row = mknod('tr', 'rcm_tmp', + '" + esc(req.responseText) + '');
+ treectl.goto();
+ };
+ req.send(data);
+ }
+
+ var input = ebi("tempname");
+ input.onblur = function() {
+ sendit(input.value);
+ // Chrome blurs elements when calling remove for some reason
+ input.onblur = null;
+ row.remove();
+ };
+ input.onkeydown = function(e) {
+ if (e.key == "Enter")
+ sendit(input.value);
+ if (e.key == "Enter" || e.key == "Escape") {
+ input.onblur = null;
+ row.remove();
+ ev(e);
+ }
+ };
+ input.focus();
+}
// media player
@@ -1189,6 +1244,17 @@ ebi('rcm').innerHTML = (
modalopen('cfg')
e.stopPropagation();
};
+
+ // new file
+ ebi('opa_md').onclick = function(){
+ mktemp();
+ }
+
+ // new folder
+ ebi('opa_mkd').onclick = function(){
+ mktemp(true);
+ }
+
})();
function modalopen(dest){
@@ -5897,8 +5963,8 @@ var thegrid = (function () {
var ths = QSA('#ggrid>a');
for (var a = 0, aa = ths.length; a < aa; a++) {
- var tr = ebi(ths[a].getAttribute('ref')).closest('tr'),
- cl = tr.className || '';
+ var tr = ebi(ths[a].getAttribute('ref'))?.closest('tr'),
+ cl = tr?.className || '';
if (noq_href(ths[a]).endsWith('/'))
cl += ' dir';
@@ -9898,71 +9964,6 @@ var rcm = (function () {
};
var selFile = jcp(nsFile);
- function mktemp(is_dir) {
- qsr('#rcm_tmp');
- if (!thegrid.en) {
- var row = mknod('tr', 'rcm_tmp',
- '" + esc(req.responseText) + '');
- treectl.goto();
- };
- req.send(data);
- }
-
- var input = ebi("tempname");
- input.onblur = function() {
- sendit(input.value);
- // Chrome blurs elements when calling remove for some reason
- input.onblur = null;
- row.remove();
- };
- input.onkeydown = function(e) {
- if (e.key == "Enter")
- sendit(input.value);
- if (e.key == "Enter" || e.key == "Escape") {
- input.onblur = null;
- row.remove();
- ev(e);
- }
- };
- input.focus();
- }
-
- // new file
- ebi('opa_md').onclick = function(){
- mktemp();
- }
-
- // new file
- ebi('opa_mkd').onclick = function(){
- mktemp(true);
- }
-
var opts = QSA('#rcm a');
for (var i = 0; i < opts.length; i++) {
opts[i].onclick = function(e) {