futureproof clipboard function

This commit is contained in:
ed 2022-04-09 19:38:05 +02:00
parent e40cd2a809
commit e9be7e712d

View file

@ -747,14 +747,26 @@ var widget = (function () {
o.style.cssText = 'position:fixed;top:45%;left:48%;padding:1em;z-index:9'; o.style.cssText = 'position:fixed;top:45%;left:48%;padding:1em;z-index:9';
o.value = m; o.value = m;
document.body.appendChild(o); document.body.appendChild(o);
o.focus();
o.select(); var cln = function () {
document.execCommand("copy");
o.value = 'copied to clipboard '; o.value = 'copied to clipboard ';
setTimeout(function () { setTimeout(function () {
document.body.removeChild(o); document.body.removeChild(o);
}, 500); }, 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(); }
};
r.set(sread('au_open') == 1); r.set(sread('au_open') == 1);
setTimeout(function () { setTimeout(function () {
clmod(widget, 'anim', 1); clmod(widget, 'anim', 1);