~vesto/feedon

44d291030780dfd160f608a48ac5641b8fd9de80 — Steve Gattuso 10 months ago e6b8d0b
add clipboard copy/paste
2 files changed, 22 insertions(+), 1 deletions(-)

M feedon/static/style.css
M feedon/templates/timelines/index.html
M feedon/static/style.css => feedon/static/style.css +1 -1
@@ 37,7 37,7 @@ code {
    color: #D9FFA9;
}

input {
input, button {
    font-family: monospace, sans-serif;
    background: var(--light);
    border: 1px solid var(--gray);

M feedon/templates/timelines/index.html => feedon/templates/timelines/index.html +21 -0
@@ 25,6 25,7 @@
              </div>
              <div class="timeline--details">
                  <input disabled type="text" value="{{timeline.rss_url()}}" />
                  <button class="timeline--copy" data-url="{{timeline.rss_url()}}" title="Copy to clipboard">📋</button>
                  <form method="POST" action="/timelines/{{timeline.id}}/regenerate-url">
                      <input type="submit" value="↻" title="Regenerate feed URL" />
                  </form>


@@ 32,4 33,24 @@
          </div>
      {% endfor %}
  </div>
  <script>
  function copyToClipboard(e) {
    const url = e.target.getAttribute('data-url');
    navigator.clipboard.writeText(url)
      .then(() => {
        e.target.innerText = '✅';
        e.target.disabled = true;
        setTimeout(() => {
          e.target.innerText = '📋';
          e.target.disabled = false;
        }, 1000);
      }, () => {
        alert('Could not write to clipboard');
      });
  }
  document.querySelectorAll('.timeline--copy').forEach((el) => {
    el.addEventListener('click', copyToClipboard);
  })
  </script>

{% endblock %}