Ver Fonte

This works better

Piotr Czajkowski há 4 anos atrás
pai
commit
d81ce47177
1 ficheiros alterados com 10 adições e 8 exclusões
  1. 10 8
      static/processResults.js

+ 10 - 8
static/processResults.js

@@ -1,9 +1,17 @@
 let app = {};
 
 app.filterTable = function(value) {
-	const filter = value.toUpperCase();
 	let data = document.getElementById("dataRows");
 	let rows = data.getElementsByTagName("tr");
+	if (value === "") {
+		for (let i = 0; i < rows.length; i++) {
+			let row = rows[i];
+			row.style.display = "";
+		}
+		return;
+	}
+
+	const filter = value.toUpperCase();	
 
 	for (let i = 0; i < rows.length; i++) {
 		let row = rows[i];
@@ -22,15 +30,9 @@ app.filterTable = function(value) {
 };
 
 app.clearFilter = function() {
-	let table = document.getElementsByTagName("tbody")[0];
-	let tr = table.getElementsByTagName("tr");
-
-	for (let i = 0; i < tr.length; i++) {
-		tr[i].style.display = "";
-	}
-
 	let filter = document.getElementById("filter");
 	filter.value = "";
+	app.filterTable("");
 };
 
 app.sortTable = function() {