Fixes FS#45379. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- This is an initial version, so might not be perfect. Note that since we have to do it through JS we have to use strings like "1 package(s) selected" instead of properly gettext'ed ones. web/html/packages.php | 11 +++++++++++ web/template/pkg_search_results.php | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/web/html/packages.php b/web/html/packages.php index 75a574e..b4c5c39 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -67,10 +67,21 @@ function collapseDependsList(list) { }); } +function checkboxes() { + document.getElementById("pkglist-checked-count").innerHTML = document.querySelectorAll('input[type="checkbox"]:checked').length; +} + $(document).ready(function() { collapseDependsList("#pkgdepslist"); collapseDependsList("#pkgreqslist"); collapseDependsList("#pkgsrcslist"); + checkboxes(); // Set initial value + + var elements = document.getElementsByClassName('package-checkbox'); + + for (var i = 0, len = elements.length; i < len; i++) { + elements[i].onchange = checkboxes; + } }); </script> diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index cce533c..b40c87d 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -9,6 +9,8 @@ if (!$result): ?> <p> <?= _n('%d package found.', '%d packages found.', $total) ?> <?= __('Page %d of %d.', $current, $pages) ?> + <?= __('%s%s%s package(s) selected.', + '<span id="pkglist-checked-count">', '0', '</span>') ?> </p> <?php if (count($templ_pages) > 1): ?> <p class="pkglist-nav"> @@ -49,7 +51,7 @@ if (!$result): ?> <?php while (list($indx, $row) = each($searchresults)): ?> <tr class="<?= ($indx % 2 == 0) ? 'odd' : 'even' ?>"> <?php if ($SID): ?> - <td><input type="checkbox" name="IDs[<?= $row["PackageBaseID"] ?>]" value="1" /></td> + <td><input class="package-checkbox" type="checkbox" name="IDs[<?= $row["PackageBaseID"] ?>]" value="1" /></td> <?php endif; ?> <td><a href="<?= htmlspecialchars(get_pkg_uri($row["Name"]), ENT_QUOTES); ?>"><?= htmlspecialchars($row["Name"]) ?></a></td> <td<?php if ($row["OutOfDateTS"]): ?> class="flagged"<?php endif; ?>><?= htmlspecialchars($row["Version"]) ?></td> @@ -89,6 +91,8 @@ if (!$result): ?> <p> <?= _n('%d package found.', '%d packages found.', $total) ?> <?= __('Page %d of %d.', $current, $pages) ?> + <?= __('%s%s%s package(s) selected.', + '<span id="pkglist-checked-count">', '0', '</span>') ?> </p> <?php if (count($templ_pages) > 1): ?> <p class="pkglist-nav"> -- 2.4.4