From fc8160d4404f18042b7d265f2f595e4a3d75242b Mon Sep 17 00:00:00 2001
From: xengineering <me@xengineering.eu>
Date: Sun, 3 Mar 2024 19:14:26 +0100
Subject: view: Move all JavaScript code to ceres.js

This allows to cache the involved JavaScript code.
---
 view/html/recipes.html | 20 +-------------------
 view/static/ceres.js   | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 19 deletions(-)

(limited to 'view')

diff --git a/view/html/recipes.html b/view/html/recipes.html
index b5bf786..0287dc5 100644
--- a/view/html/recipes.html
+++ b/view/html/recipes.html
@@ -15,25 +15,7 @@
 			</ul>
 		</main>
 		{{ template "footer" }}
-		<script>
-			function filter() {
-				var input, query, ul, li, a, i, txtValue;
-				input = document.getElementById('search');
-				query = input.value.toUpperCase();
-				ul = document.getElementById("recipes");
-				li = ul.getElementsByTagName('li');
-
-				for (i = 0; i < li.length; i++) {
-					a = li[i].getElementsByTagName("a")[0];
-					txtValue = a.textContent || a.innerText;
-					if (txtValue.toUpperCase().indexOf(query) > -1) {
-						li[i].style.display = "";
-					} else {
-						li[i].style.display = "none";
-					}
-				}
-			}
-		</script>
+		<script src="/static/view/static/ceres.js"></script>
 	</body>
 </html>
 {{end}}
diff --git a/view/static/ceres.js b/view/static/ceres.js
index a6b5591..3bfeb6c 100644
--- a/view/static/ceres.js
+++ b/view/static/ceres.js
@@ -47,3 +47,21 @@ function del(url) {
 		console.error('Network error:', error);
 	});
 }
+
+function filter() {
+	var input, query, ul, li, a, i, txtValue;
+	input = document.getElementById('search');
+	query = input.value.toUpperCase();
+	ul = document.getElementById("recipes");
+	li = ul.getElementsByTagName('li');
+
+	for (i = 0; i < li.length; i++) {
+		a = li[i].getElementsByTagName("a")[0];
+		txtValue = a.textContent || a.innerText;
+		if (txtValue.toUpperCase().indexOf(query) > -1) {
+			li[i].style.display = "";
+		} else {
+			li[i].style.display = "none";
+		}
+	}
+}
-- 
cgit v1.2.3-70-g09d2