summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2015-06-28 20:59:10 +0200
committerJohannes Löthberg <johannes@kyriasis.com>2015-07-04 12:32:26 +0200
commit5cd77a826f5a52168335e1db0926215da6e23ad0 (patch)
tree424b9b7f3cb927dd1af8f204e544bf016fa99a38
parent062fa097c9adb1254fa215fa1735cac9195f71bf (diff)
downloadaurweb-checked-count.tar.xz
Show number of selected packages on search pagechecked-count
Fixes FS#45379. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
-rw-r--r--web/html/packages.php16
-rw-r--r--web/template/pkg_search_results.php5
2 files changed, 20 insertions, 1 deletions
diff --git a/web/html/packages.php b/web/html/packages.php
index bf3daf8..4b11f09 100644
--- a/web/html/packages.php
+++ b/web/html/packages.php
@@ -71,6 +71,22 @@ $(document).ready(function() {
collapseDependsList("#pkgdepslist");
collapseDependsList("#pkgreqslist");
collapseDependsList("#pkgsrcslist");
+
+ function update_checked_count() {
+ var one_pkg = '<?= __("1 package selected") ?>';
+ var pkgs = '<?= __("%d packages selected") ?>';
+
+ var count = $('.package-checkbox:checked').length;
+ if (count === 1) {
+ var res = one_pkg;
+ } else {
+ var res = pkgs;
+ }
+ $('#pkglist-checked-count').text(res.replace('%s', count.toString()));
+ }
+ update_checked_count(); // Set initial string
+
+ $('.package-checkbox').change(update_checked_count);
});
</script>
diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php
index cce533c..4d99dd6 100644
--- a/web/template/pkg_search_results.php
+++ b/web/template/pkg_search_results.php
@@ -9,6 +9,7 @@ if (!$result): ?>
<p>
<?= _n('%d package found.', '%d packages found.', $total) ?>
<?= __('Page %d of %d.', $current, $pages) ?>
+ <span id="pkglist-checked-count"></span>
</p>
<?php if (count($templ_pages) > 1): ?>
<p class="pkglist-nav">
@@ -49,7 +50,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 +90,8 @@ if (!$result): ?>
<p>
<?= _n('%d package found.', '%d packages found.', $total) ?>
<?= __('Page %d of %d.', $current, $pages) ?>
+
+ <span id="pkglist-checked-count"></span>
</p>
<?php if (count($templ_pages) > 1): ?>
<p class="pkglist-nav">