Smarter clipboard copies
This commit is contained in:
@@ -100,6 +100,9 @@ function set(short, long) {
|
|||||||
params.set('short', short);
|
params.set('short', short);
|
||||||
params.set('long', long);
|
params.set('long', long);
|
||||||
|
|
||||||
|
const oldShort = document.getElementById('short').value;
|
||||||
|
const oldLong = document.getElementById('long').value;
|
||||||
|
|
||||||
fetch(`./?${params.toString()}`, {
|
fetch(`./?${params.toString()}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
}).then(async (resp) => {
|
}).then(async (resp) => {
|
||||||
@@ -113,9 +116,14 @@ function set(short, long) {
|
|||||||
|
|
||||||
setShortItem(newShort, 'check-square');
|
setShortItem(newShort, 'check-square');
|
||||||
|
|
||||||
|
// Only set the icons if we were actually setting from these inputs
|
||||||
if (document.getElementById('short').value == short && document.getElementById('long').value == long) {
|
if (document.getElementById('short').value == short && document.getElementById('long').value == long) {
|
||||||
document.getElementById('short-icon').setAttribute('name', 'check-square');
|
document.getElementById('short-icon').setAttribute('name', 'check-square');
|
||||||
document.getElementById('long-icon').setAttribute('name', 'check-square');
|
document.getElementById('long-icon').setAttribute('name', 'check-square');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only set the clipboard if the user didn't change the inputs
|
||||||
|
if (document.getElementById('short').value == oldShort && document.getElementById('long').value == oldLong) {
|
||||||
await navigator.clipboard.writeText(`${window.location.origin}/${newShort}`);
|
await navigator.clipboard.writeText(`${window.location.origin}/${newShort}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user