use kfid instead of kfname for consistency, and now we have 2 loops of kfids, then keep the count explicit (kfid.count) rather than implicity loop.index

This commit is contained in:
2021-03-28 16:17:01 +11:00
parent 7e7d757afb
commit 5f42e19bcd

View File

@@ -49,7 +49,7 @@
$('[id^=kf' + row + '-f]').attr('class', 'alert alert-danger sm-txt py-1') $('[id^=kf' + row + '-f]').attr('class', 'alert alert-danger sm-txt py-1')
$('[id^=kf' + row + '-f]').attr('class', 'alert alert-danger sm-txt py-1') $('[id^=kf' + row + '-f]').attr('class', 'alert alert-danger sm-txt py-1')
$('#kf'+row+'-f'+which).attr('class', 'alert alert-' + al + ' py-1') $('#kf'+row+'-f'+which).attr('class', 'alert alert-' + al + ' py-1')
$('#kfname-'+row).val( F[row.toString()+which.toString()] ) $('#kfid-'+row).val( F[row.toString()+which.toString()] )
} }
function KeepDir(row, which) function KeepDir(row, which)
{ {
@@ -67,9 +67,12 @@
{% set pref=namespace(have="") %} {% set pref=namespace(have="") %}
{% set count=namespace( del=0, keep=0 ) %} {% set count=namespace( del=0, keep=0 ) %}
{% set all_count=namespace( d_files=0, k_files=0, manual=0 ) %} {% set all_count=namespace( d_files=0, k_files=0, manual=0 ) %}
{% set kfid=namespace( count=0 ) %}
{# for each hash in ip_to_sp_dups_*, auto keep the _keep, auto delete the _del, only need hidden input #} {# for each hash in ip_to_sp_dups_*, auto keep the _keep, auto delete the _del, only need hidden input #}
{% for h in DD.ip_to_sp_dups_keep %} {% for h in DD.ip_to_sp_dups_keep %}
<input type="hidden" name="kfhash-{{outer_loop}}" value="{{h}}"> {% set kfid.count = kfid.count+1 %}
<input type="hidden" name="kfhash-{{kfid.count}}" value="{{h}}">
<input type="hidden" name="kfid-{{kfid.count}}" value="{{DD.ip_to_sp_dups_keep[h].id}}">
{% set count.keep = count.keep+1 %} {% set count.keep = count.keep+1 %}
{% set count.del = count.del + DD.ip_to_sp_dups_del[h]|length %} {% set count.del = count.del + DD.ip_to_sp_dups_del[h]|length %}
{% endfor %} {% endfor %}
@@ -88,7 +91,9 @@
{% if DD.preferred_file[dup.h] %} {% if DD.preferred_file[dup.h] %}
{% set pref.have = "True" %} {% set pref.have = "True" %}
{% if DD.preferred_file[dup.h] == dup.id %} {% if DD.preferred_file[dup.h] == dup.id %}
<input type="hidden" name="kfhash-{{outer_loop}}" value="{{dup.h}}"> {% set kfid.count = kfid.count+1 %}
<input type="hidden" name="kfhash-{{kfid.count}}" value="{{dup.h}}">
<input type="hidden" name="kfid-{{kfid.count}}" value="{{dup.id}}">
{% set count.keep = count.keep + 1 %} {% set count.keep = count.keep + 1 %}
{% else %} {% else %}
{% set count.del = count.del + (dups|length-1) %} {% set count.del = count.del + (dups|length-1) %}
@@ -101,21 +106,21 @@
{% if page.cnt <= pagesize %} {% if page.cnt <= pagesize %}
{% if loop.index == 1 %} {% if loop.index == 1 %}
<div class="col-lg-12 py-2"> <div class="col-lg-12 py-2">
{% set kfid.count = kfid.count+1 %}
<input type="hidden" name="kfhash-{{kfid.count}}" value="{{dup.h}}">
<input type="hidden" id="kfid-{{kfid.count}}" name="kfid-{{kfid.count}}" value="">
{% endif %} {% endif %}
<alert id="kf{{outer_loop}}-f{{loop.index}}" style="cursor: pointer;" class="alert" <alert id="kf{{kfid.count}}-f{{loop.index}}" style="cursor: pointer;" class="alert"
onClick="KeepFile({{outer_loop}},{{loop.index}},'success')">{{dup.d}}/{{dup.f}}</alert> onClick="KeepFile({{kfid.count}},{{loop.index}},'success')">{{dup.d}}/{{dup.f}}</alert>
{% if DD.preferred_file[dup.h] == dup.id %} {% if DD.preferred_file[dup.h] == dup.id %}
{% set pref.have="kf{}-f{}".format(outer_loop,loop.index) %} {% set pref.have="kf{}-f{}".format(outer_loop,loop.index) %}
{% endif %} {% endif %}
{% if loop.index < dups|length %} {% if loop.index < dups|length %}
or or
{% else %} {% endif %}
<input type="hidden" name="kfhash-{{outer_loop}}" value="{{dup.h}}"> <script>
<input type="hidden" id="kfname-{{outer_loop}}" name="kfname-{{outer_loop}}" value=""> F[{{kfid.count}}{{loop.index}}]="{{dup.id}}"
{% endif %} </script>
<script>
F[{{outer_loop}}{{loop.index}}]="{{dup.id}}"
</script>
{% if loop.index == dups|length %} {% if loop.index == dups|length %}
</div class="col-lg-12"> </div class="col-lg-12">
{% endif %} {% endif %}
@@ -123,7 +128,7 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if pref.have == "" %} {% if pref.have == "" %}
<script>KeepFile( {{outer_loop}}, 1,'warning' )</script> <script>KeepFile( {{kfid.count}}, 1,'warning' )</script>
{% set page.cnt = page.cnt + 1 %} {% set page.cnt = page.cnt + 1 %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
@@ -137,12 +142,11 @@
{% set count=namespace( keep_d=0, keep_f=0 ) %} {% set count=namespace( keep_d=0, keep_f=0 ) %}
{% for dup in DD.per_path_dups %} {% for dup in DD.per_path_dups %}
{% if DD.preferred_path[dup.did1] or DD.preferred_path[dup.did2] %} {% if DD.preferred_path[dup.did1] or DD.preferred_path[dup.did2] %}
<input id="kdid-{{loop.index}}" type="hidden" name="kdid-1">
<input name="kdhash-{{loop.index}}" type="hidden" value="{{dup.hashes}}"> <input name="kdhash-{{loop.index}}" type="hidden" value="{{dup.hashes}}">
{% if DD.preferred_path[dup.did1] %} {% if DD.preferred_path[dup.did1] %}
<input type="hidden" name="kdid-{{loop.index}}" value="DD.preferred_path[dup.did1]"> <input type="hidden" name="kdid-{{loop.index}}" value="{{dup.did1}}">
{% else %} {% else %}
<input type="hidden" name="kdid-{{loop.index}}" value="DD.preferred_path[dup.did2]"> <input type="hidden" name="kdid-{{loop.index}}" value="{{dup.did2}}">
{% endif %} {% endif %}
{% set count.keep_d = count.keep_d + 1 %} {% set count.keep_d = count.keep_d + 1 %}
{% set count.keep_f = count.keep_f + dup.hashes|wordcount %} {% set count.keep_f = count.keep_f + dup.hashes|wordcount %}