diff options
Diffstat (limited to 'resources/js/ui.js')
-rw-r--r-- | resources/js/ui.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/resources/js/ui.js b/resources/js/ui.js index 455e785..b80ff6f 100644 --- a/resources/js/ui.js +++ b/resources/js/ui.js @@ -699,9 +699,16 @@ const UI = { const popup = UI.createPopup(); const dialog = UI.createTemplate(Template.dialogSave); - dialog.querySelector('[data-template-slot="saveData"]').value = Game.save(); - dialog.querySelector('[data-template-slot="saveClipboard"]').addEventListener('click', () => { - alert('Saved to clipboard!'); + const saveData = Game.save(); + + dialog.querySelector('[data-template-slot="saveData"]').value = saveData; + dialog.querySelector('[data-template-slot="saveClipboard"]').addEventListener('click', async () => { + if (navigator.clipboard) { + await navigator.clipboard.writeText(saveData); + alert('Saved to clipboard!'); + } else { + alert('ERROR: Browser can\'t copy to clipboard! You have to do it manually.'); + } }); popup.querySelector('.popup').appendChild(dialog); |