button to show/copy links for all recent uploads

This commit is contained in:
ed 2023-02-02 22:27:53 +00:00
parent e67b695b23
commit bc339f774a
3 changed files with 61 additions and 26 deletions

View file

@ -159,6 +159,9 @@ var Ls = {
"uct_q": "idle, pending",
"utl_name": "filename",
"utl_ulist": "list",
"utl_ucopy": "copy",
"utl_links": "links",
"utl_stat": "status",
"utl_prog": "progress",
@ -573,8 +576,8 @@ var Ls = {
"wt_selinv": "inverter utvalg",
"wt_selzip": "last ned de valgte filene som et arkiv",
"wt_seldl": "last ned de valgte filene$NSnarvei: Y",
"wt_npirc": "kopier sang-info (irc-formattert)",
"wt_nptxt": "kopier sang-info",
"wt_npirc": "kopiér sang-info (irc-formattert)",
"wt_nptxt": "kopiér sang-info",
"wt_grid": "bytt mellom ikoner og listevisning$NSnarvei: G",
"wt_prev": "forrige sang$NSnarvei: J",
"wt_play": "play / pause$NSnarvei: P",
@ -606,6 +609,9 @@ var Ls = {
"uct_q": "køen",
"utl_name": "filnavn",
"utl_ulist": "vis",
"utl_ucopy": "kopiér",
"utl_links": "lenker",
"utl_stat": "status",
"utl_prog": "fremdrift",
@ -1016,7 +1022,7 @@ ebi('op_up2k').innerHTML = (
'<div id="u2tabw" class="na"><table id="u2tab">\n' +
' <thead>\n' +
' <tr>\n' +
' <td>' + L.utl_name + '</td>\n' +
' <td>' + L.utl_name + ' &nbsp;(<a href="#" id="luplinks">' + L.utl_ulist + '</a>/<a href="#" id="cuplinks">' + L.utl_ucopy + '</a>' + L.utl_links + ')</td>\n' +
' <td>' + L.utl_stat + '</td>\n' +
' <td>' + L.utl_prog + '</td>\n' +
' </tr>\n' +
@ -1713,29 +1719,9 @@ var widget = (function () {
m += '[' + cv + s2ms(mp.au.currentTime) + ck + '/' + cv + s2ms(mp.au.duration) + ck + ']';
var o = mknod('input');
o.style.cssText = 'position:fixed;top:45%;left:48%;padding:1em;z-index:9';
o.value = m;
document.body.appendChild(o);
var cln = function () {
o.value = 'copied to clipboard ';
setTimeout(function () {
document.body.removeChild(o);
}, 500);
};
var fb = function () {
console.log('fb');
o.focus();
o.select();
document.execCommand("copy");
cln();
};
try {
// https only
navigator.clipboard.writeText(m).then(cln, fb);
}
catch (ex) { fb(); }
cliptxt(m, function () {
toast.ok(1, 'copied to clipboard', null, 'top');
});
};
r.set(sread('au_open') == 1);
setTimeout(function () {

View file

@ -1421,6 +1421,35 @@ function up2k_init(subtle) {
}
more_one_file();
function linklist() {
var ret = [],
base = document.location.origin.replace(/\/$/, '');
for (var a = 0; a < st.files.length; a++) {
var t = st.files[a],
url = t.purl + uricom_enc(t.name);
if (t.fk)
url += '?k=' + t.fk;
ret.push(base + url);
}
return ret.join('\r\n');
}
ebi('luplinks').onclick = function (e) {
ev(e);
modal.alert(linklist());
};
ebi('cuplinks').onclick = function (e) {
ev(e);
var txt = linklist();
cliptxt(txt + '\n', function () {
toast.inf(5, txt.split('\n').length + ' links copied to clipboard');
});
};
var etaref = 0, etaskip = 0, utw_minh = 0, utw_read = 0;
function etafun() {
var nhash = st.busy.head.length + st.busy.hash.length + st.todo.head.length + st.todo.hash.length,

View file

@ -978,6 +978,7 @@ function sethash(hv) {
}
}
function dl_file(url) {
console.log('DL [%s]', url);
var o = mknod('a');
@ -987,6 +988,25 @@ function dl_file(url) {
}
function cliptxt(txt, ok) {
var fb = function () {
console.log('fb');
var o = mknod('input');
o.value = txt;
document.body.appendChild(o);
o.focus();
o.select();
document.execCommand("copy");
document.body.removeChild(o);
ok();
};
try {
navigator.clipboard.writeText(txt).then(ok, fb);
}
catch (ex) { fb(); }
}
var timer = (function () {
var r = {};
r.q = [];