diff --git a/templates/article.html b/templates/article.html index 5b11226..05a45a7 100644 --- a/templates/article.html +++ b/templates/article.html @@ -18,11 +18,17 @@

Find links to "{{ title }}"

{{ title }} ↗ + {% if redirect_to %} + → redirects to {{ redirect_to }} ↗ + {% endif %}
{{ total }} mentions total {{ with_link }} already linked ({{ "{:.0%}".format(with_link / total) }}) + {% if saves_this_session %} + {{ saves_this_session }} added this session + {% endif %}
@@ -57,11 +63,11 @@
{% if hits %} -
- {{ hits | length }} candidates -
    +
    + {{ hits | length }} candidates +
      {% for hit in hits %} -
    1. +
    2. {{ hit.title }}
    3. {% endfor %} @@ -76,6 +82,7 @@ (function () { const hits = {{ hits | map(attribute='title') | list | tojson }}; const linkTo = {{ title | tojson }}; + const redirectTo = {{ redirect_to | tojson }}; const apiUrl = {{ url_for('api_valid_hit') | tojson }}; const pageUrl = new URL(window.location.href); @@ -83,6 +90,16 @@ const elStatus = document.getElementById('search-status'); const elResult = document.getElementById('result'); const elAllDone = document.getElementById('all-done'); + const elList = document.getElementById('candidates-list'); + + function removeCandidate(title) { + if (!elList) return; + const li = elList.querySelector(`li[data-title="${CSS.escape(title)}"]`); + if (!li) return; + li.remove(); + const elCount = document.getElementById('candidates-count'); + if (elCount) elCount.textContent = elList.children.length; + } async function search() { for (const hitTitle of hits) { @@ -91,6 +108,7 @@ let data; try { const params = new URLSearchParams({ link_to: linkTo, link_from: hitTitle }); + if (redirectTo) params.append('redirect_to', redirectTo); const resp = await fetch(apiUrl + '?' + params); if (!resp.ok) continue; data = await resp.json(); @@ -98,7 +116,7 @@ continue; } - if (!data.valid) continue; + if (!data.valid) { removeCandidate(hitTitle); continue; } elProgress.hidden = true; @@ -123,6 +141,8 @@ } elProgress.hidden = true; + const elCandidates = document.getElementById('candidates-section'); + if (elCandidates) elCandidates.hidden = true; elAllDone.hidden = false; } diff --git a/templates/base.html b/templates/base.html index 324d9fc..0328311 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,14 +5,14 @@ - {% block title %}{% endblock %} – Find Link + {% block title %}{% endblock %} – Missing Link {% block style %}{% endblock %}