diff --git a/cont/nav.php b/cont/nav.php
index ca453c3..dca5465 100644
--- a/cont/nav.php
+++ b/cont/nav.php
@@ -11,18 +11,18 @@
@@ -30,7 +30,7 @@
- - ">
+
- ">
Liste
- ">
diff --git a/js/list.js b/js/list.js
index d551cbe..d1ff10c 100644
--- a/js/list.js
+++ b/js/list.js
@@ -9,11 +9,11 @@ $(document).ready(function () {
function highlightNewEntry(){
var cookies = document.cookie;
- var cookieRegExp = new RegExp(/;?\s+newItem=(\d+)/g);
+ var cookieRegExp = new RegExp(/[;]{0,1}\s{0,1}newItem=(\d+)/g);
var match = cookieRegExp.exec(cookies);
if(match!=null){
var newID = match[1];
- var checkBox = $("[data-id=" + newID + "]");
+ var checkBox = $(`[data-id='${newID}']`);
var newRow = checkBox.parent().parent();
newRow.removeClass($(checkBox).data("color"));
newRow.addClass("alert-primary");
@@ -22,7 +22,6 @@ function highlightNewEntry(){
newRow.addClass($(checkBox).data("color"));
}, 1000);
document.cookie = "newItem=-1"
- console.log(document.cookie);
}
}
@@ -48,29 +47,29 @@ function checkItem() {
status: $(this).prop("checked")
},
success: function () {
- var color = $("[data-id='" + dataId + "'").data("color");
-
- $("[data-id='" + dataId + "'").parent().parent().removeClass("bg-danger");
+ var dataIdSelector = (`[data-id='${dataId}']`);
+ var color = $(dataIdSelector).data("color");
+ $(dataIdSelector).parent().parent().removeClass("bg-danger");
- if($("[data-id='" + dataId + "'").prop("checked")){
- $("[data-id='" + dataId + "'").parent().parent().removeClass(color);
- $("[data-id='" + dataId + "'").parent().parent().addClass("bg-success");
+ if($(dataIdSelector).prop("checked")){
+ $(dataIdSelector).parent().parent().removeClass(color);
+ $(dataIdSelector).parent().parent().addClass("bg-success");
}
else{
- $("[data-id='" + dataId + "'").parent().parent().removeClass("bg-success");
- $("[data-id='" + dataId + "'").parent().parent().addClass(color);
+ $(dataIdSelector).parent().parent().removeClass("bg-success");
+ $(dataIdSelector).parent().parent().addClass(color);
}
},
error: function () {
- $("[data-id='" + dataId + "'").parent().parent().addClass("bg-danger");
- $("[data-id='" + dataId + "'").parent().parent().data("toggle", "popover");
- $("[data-id='" + dataId + "'").parent().parent().data("container", "body");
- $("[data-id='" + dataId + "'").parent().parent().data("placement", "top");
- $("[data-id='" + dataId + "'").parent().parent().data("html", true);
- $("[data-id='" + dataId + "'").parent().parent().data("trigger", "focus");
- $("[data-id='" + dataId + "'").parent().parent().data("content", "Dieses Element konnte nicht gespeichert werden.
Bitte die Seite Aktualisieren");
- $("[data-id='" + dataId + "'").parent().parent().attr("title", "Fehler!");
- $("[data-id='" + dataId + "'").parent().parent().popover('show');
+ $(dataIdSelector).parent().parent().addClass("bg-danger");
+ $(dataIdSelector).parent().parent().data("toggle", "popover");
+ $(dataIdSelector).parent().parent().data("container", "body");
+ $(dataIdSelector).parent().parent().data("placement", "top");
+ $(dataIdSelector).parent().parent().data("html", true);
+ $(dataIdSelector).parent().parent().data("trigger", "focus");
+ $(dataIdSelector).parent().parent().data("content", "Dieses Element konnte nicht gespeichert werden.
Bitte die Seite Aktualisieren");
+ $(dataIdSelector).parent().parent().attr("title", "Fehler!");
+ $(dataIdSelector).parent().parent().popover('show');
}
});
}
\ No newline at end of file
diff --git a/js/search.js b/js/search.js
index 9df7b69..8218d1e 100644
--- a/js/search.js
+++ b/js/search.js
@@ -1,33 +1,32 @@
-$(document).ready(function(){
- var recipes = $("#recipes a");
- var headerLetters = $("#recipes h2");
- $("#search-recipes").on("keyup", searchRecipe(recipes, headerLetters));
+$(document).ready(function () {
+ $("#search-recipes").on("keyup", searchRecipe);
$("#clear-search-string").click(clearSearchString);
});
-function searchRecipe(recipes, headerLetters) {
- return function () {
- var search = $("#search-recipes").val().toUpperCase();
- for (var i = 0; i < recipes.length; i++) {
- if (recipes[i].innerHTML.toUpperCase().indexOf(search) > -1) {
- recipes[i].style.display = "";
- }
- else {
- recipes[i].style.display = "none";
- }
+function searchRecipe() {
+ var searchString = $("#search-recipes").val().toUpperCase();
+ var recipes = $("#recipes a");
+
+ for (var i = 0; i < recipes.length; i++) {
+ if (recipes[i].innerHTML.toUpperCase().indexOf(searchString) > -1) {
+ $(recipes[i]).show()
}
- for (var j = 0; j < headerLetters.length; j++) {
- if (($("*[data-letter='" + headerLetters[j].innerHTML + "']:visible")).length > 0) {
- headerLetters[j].style.display = "";
- }
- else {
- headerLetters[j].style.display = "none";
- }
+ else {
+ $(recipes[i]).hide();
}
- };
+ }
+
+ $("#recipes").children().each(index => {
+ var container = ($("#recipes").children())[index];
+ $(container).removeClass("d-none").addClass("d-flex");
+ if(($(container).find("a:visible")).length==0){
+ $(container).removeClass("d-flex").addClass("d-none");
+ }
+ });
+
}
-function clearSearchString(){
+function clearSearchString() {
$("#search-recipes").val("");
$("#search-recipes").focus();
$("#search-recipes").keyup();
diff --git a/style/helper.css b/style/helper.css
index d4ce33a..ea7e18e 100644
--- a/style/helper.css
+++ b/style/helper.css
@@ -6,4 +6,8 @@
.list-row {
transition: .5s;
+}
+
+.nav-link-font {
+ font-size: 16px !important;
}
\ No newline at end of file