1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

36 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-01-06 20:18:44 +00:00
// Toggle the display of IP addresses under interfaces
$('button.toggle-ips').click(function() {
var selected = $(this).attr('selected');
if (selected) {
$('#interfaces_table tr.interface:visible + tr.ipaddresses').hide();
2020-01-06 20:18:44 +00:00
} else {
$('#interfaces_table tr.interface:visible + tr.ipaddresses').show();
2020-01-06 20:18:44 +00:00
}
$(this).attr('selected', !selected);
$(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
return false;
});
// Inteface filtering
$('input.interface-filter').on('input', function() {
var filter = new RegExp(this.value);
var interface;
2020-01-06 20:18:44 +00:00
for (interface of $('#interfaces_table > tbody > tr.interface')) {
2020-01-06 20:18:44 +00:00
// Slice off 'interface_' at the start of the ID
if (filter.test(interface.id.slice(10))) {
2020-01-06 20:18:44 +00:00
// Match the toggle in case the filter now matches the interface
$(interface).find('input:checkbox[name=pk]').prop('checked', $('input.toggle').prop('checked'));
$(interface).show();
if ($('button.toggle-ips').attr('selected')) {
$(interface).next('tr.ipaddresses').show();
}
2020-01-06 20:18:44 +00:00
} else {
// Uncheck to prevent actions from including it when it doesn't match
$(interface).find('input:checkbox[name=pk]').prop('checked', false);
$(interface).hide();
$(interface).next('tr.ipaddresses').hide();
2020-01-06 20:18:44 +00:00
}
}
});