ckolderup / postmarks

a single-user bookmarking website designed to live on the Fediverse
https://postmarks.glitch.me
MIT License
464 stars 38 forks source link

Reuse copy-bookmarklet script #120

Closed johnholdun closed 1 year ago

johnholdun commented 1 year ago

This change moves the inline script used for copying text to the clipboard into a separate file and adds it to the page as necessary. It also refactors that script very slightly, and fixes one use of the script that was not working properly—seems like maybe the code got reformatted as if it was a block of plain text, which broke some of the code.

johnholdun commented 1 year ago

Heck yeah I can

johnholdun commented 1 year ago

Done! I made this powered by data-* attributes, and also changed the two inputs to buttons so they're more easily discoverable as interactive elements.

Because buttons overflow text differently than text inputs do, I also added a hardcoded display-only version of the bookmarklet javascript that is added to the button for display purposes. It might ultimately be better in this case if this button just said "Copy to clipboard" and was its own status indicator (which I think would work without any other modifications—the data-copy-status selector can just point to itself)

ckolderup commented 1 year ago

oh wow I can commit changes to the PR, at least via Github's suggestion feature 🤔