[projects/pld-ftp-admin] Add filter-out feature to rpmqa query page (adamg?)

baggins baggins at pld-linux.org
Sat Jan 16 20:57:51 CET 2021


commit 11c36e0f8d3d0c89bffd65eab0370c4b5169e2bf
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sat Jan 16 20:57:11 2021 +0100

    Add filter-out feature to rpmqa query page (adamg?)

 html/qa.php | 74 ++++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 44 insertions(+), 30 deletions(-)
---
diff --git a/html/qa.php b/html/qa.php
index a24416e..4a74ff3 100644
--- a/html/qa.php
+++ b/html/qa.php
@@ -1,42 +1,20 @@
-<html>
+<!doctype html>
+<html lang='en'>
 <head>
 <link rel="Shortcut Icon" href="//www.pld-linux.org/favicon.ico"/>
 	<title>PLD QA Reports</title>
 	<link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="//srcbuilder.pld-linux.org/th/style.css">
 	<style>
-	.hidden { display: none; }
-	span#count { font-weight: bold; }
+		.hidden { display: none; }
+		span#count { font-weight: bold; }
 	</style>
 </head>
-<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
-<script>
-jQuery(function($) {
-	$('#q').on('change', function(e) {
-		var el = e.target;
-		var o = el.options;
-		var v = o[o.selectedIndex].value;
-		location.href = "?q=" + v;
-	});
-
-	var $lines = $('#lines>li');
-	var $count = $('#count');
-	$('#filter').on('keyup', function() {
-		var search = $(this).val();
-		var count = 0;
-		$lines.each(function() {
-			var $line = $(this);
-			var text = $line.text();
-			var fn = text.match(search) && ++count ? 'removeClass' : 'addClass';
-			$line[fn]('hidden');
-		});
-		$count.html(count);
-	});
-	$count.html($lines.length);
-});
-</script>
 <body>
 <?php
 
+// (c) -2019 PLD developers
+// filter-out feature - adamg
+
 $report = isset($_GET['q']) ? basename($_GET['q']) : null;
 $reports = array(
 	"main" => "Main deps x86_64",
@@ -72,7 +50,8 @@ function reports_selection($reports) {
  * Create text input for filtering results
  */
 function filter_box() {
-	echo '<br>Filter results: <input id="filter">';
+	echo '<br>Filter results: <input id="filter" class="filter">';
+	echo '<br>Filter-out (grep -v) <input id="filter_out" class="filter">';
 	echo '<br><span id="count">?</span> errors';
 }
 
@@ -99,5 +78,40 @@ if (isset($reports[$report])) {
 }
 
 ?>
+<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
+<script>
+jQuery(function($) {
+	$('#q').on('change', function(e) {
+		var el = e.target;
+		var o = el.options;
+		var v = o[o.selectedIndex].value;
+		location.href = "?q=" + v;
+	});
+
+	var $lines = $('#lines>li');
+	var $count = $('#count');
+	$('.filter').on('keyup', function() {
+		var filter_in = $('#filter').val();
+		var filter_out = $('#filter_out').val().trim();
+		var do_filter_out = filter_out.length > 0;
+		var count = 0;
+		$lines.each(function() {
+			var $line = $(this);
+			var text = $line.text();
+			// everything is visible by default
+			$line.removeClass('hidden');
+			count++;
+			// but we hide lines that do not match filter
+			// OR match non-empty filter-out
+			if ( ! text.match(filter_in) || (do_filter_out && text.match(filter_out)) ) {
+				$line.addClass('hidden');
+				count--;
+			}
+		});
+		$count.html(count);
+	});
+	$count.html($lines.length);
+});
+</script>
 </body>
 </html>
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/11c36e0f8d3d0c89bffd65eab0370c4b5169e2bf



More information about the pld-cvs-commit mailing list