Commit acdbac07 authored by Leo Iannacone's avatar Leo Iannacone

add a packages search bar

parent 6d941d82
# 0.5.0
* [new] packages search bar
# 0.4.2 (2014-06-15) # 0.4.2 (2014-06-15)
* [fix] calculate pidfile for debomatic status check after merging configurations * [fix] calculate pidfile for debomatic status check after merging configurations
......
...@@ -142,7 +142,8 @@ function Page_Distrubion(socket) { ...@@ -142,7 +142,8 @@ function Page_Distrubion(socket) {
tmp.package = p; tmp.package = p;
// get datestamp if package is clicked // get datestamp if package is clicked
$('#packages ul').append('<li id="package-' + p.orig_name + '"><a href="' + $('#packages ul').append('<li id="package-' + p.orig_name + '"><a href="' +
Utils.from_view_to_hash(tmp) + '/datestamp">' + p.name + ' <span>' + p.version + '</span></a></li>'); Utils.from_view_to_hash(tmp) + '/datestamp"><span class="name">' + p.name + '</span> ' +
'<span class="version">' + p.version + '</span></a></li>');
view.packages[p.orig_name] = Utils.clone(p); view.packages[p.orig_name] = Utils.clone(p);
}); });
packages.select(); packages.select();
...@@ -154,6 +155,7 @@ function Page_Distrubion(socket) { ...@@ -154,6 +155,7 @@ function Page_Distrubion(socket) {
}, },
clean: function () { clean: function () {
$('#packages ul').html(''); $('#packages ul').html('');
$('#packages .search').val('');
}, },
get: function () { get: function () {
if (Utils.check_view_distribution(view)) { if (Utils.check_view_distribution(view)) {
...@@ -168,6 +170,7 @@ function Page_Distrubion(socket) { ...@@ -168,6 +170,7 @@ function Page_Distrubion(socket) {
if (Utils.check_view_package(view)) { if (Utils.check_view_package(view)) {
$('#packages li[id="package-' + view.package.orig_name + '"]').addClass('active'); $('#packages li[id="package-' + view.package.orig_name + '"]').addClass('active');
} }
packages.search();
}, },
unselect: function () { unselect: function () {
$('#packages li').removeClass('active'); $('#packages li').removeClass('active');
...@@ -195,6 +198,26 @@ function Page_Distrubion(socket) { ...@@ -195,6 +198,26 @@ function Page_Distrubion(socket) {
}, },
hide: function () { hide: function () {
$('#packages').hide(); $('#packages').hide();
},
search: function (token) {
if (!token)
token = $("#packages .search").val();
if (!token) {
debug(2, "packages search token empty - showing all");
$("#packages li").show();
} else {
$("#packages li").not('.active').each(function (index) {
var p_name = $(this).find('a span.name').text();
if (p_name.indexOf(token) < 0) {
debug(2, "packages search token:", token, "hiding:", this);
$(this).hide();
} else {
debug(2, "packages search token:", token, "showing:", this);
$(this).show();
}
});
}
sticky.updateOffset();
} }
}; };
...@@ -662,6 +685,11 @@ function Page_Distrubion(socket) { ...@@ -662,6 +685,11 @@ function Page_Distrubion(socket) {
} }
watch_for_new_lines(); watch_for_new_lines();
// Handle search packages
$('#packages .search').on('keyup', function (event) {
packages.search($(event.target).val());
});
// Update html according with preferences // Update html according with preferences
preferences(); preferences();
......
...@@ -102,6 +102,10 @@ footer { ...@@ -102,6 +102,10 @@ footer {
border-top: 1px solid #f0f0f0; border-top: 1px solid #f0f0f0;
} }
#packages .search {
margin-bottom: 5px;
}
#packages li .icon { #packages li .icon {
float: right; float: right;
margin-top: -3px; margin-top: -3px;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<aside id="sidebar" class="col-md-3"> <aside id="sidebar" class="col-md-3">
<nav id="packages"> <nav id="packages">
<h2>Packages</h2> <h2>Packages</h2>
<input type="text" class="form-control search" placeholder="Search">
<ul class="nav nav-pills nav-stacked"></ul> <ul class="nav nav-pills nav-stacked"></ul>
</nav> </nav>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment