diff --git a/bin/list.js b/bin/list.js index ad0f094..24f877a 100644 --- a/bin/list.js +++ b/bin/list.js @@ -1,4 +1,5 @@ $(document).ready(function () { + highlightNewEntry(); $("input[type=checkbox]").change(checkItem); $("#remove").click(deleteCheckeditems); $("#nameField").focus(); @@ -6,6 +7,13 @@ $(document).ready(function () { $("#nameField").on("focus", function () { $(this).select(); }); }); +function highlightNewEntry(){ + var cookies = document.cookie; + var cookieRegExp = new RegExp(/newItem(\d+)/ig); + console.log(cookies.match(cookieRegExp)); + +} + function deleteCheckeditems() { $.post({ url: "api/list/del", diff --git a/config/config.php b/config/config.php index 45ebdb2..0c1fa1c 100644 --- a/config/config.php +++ b/config/config.php @@ -1,11 +1,6 @@ true, - 'host' => 'localhost', - 'username' => 'shoppinglist', - 'passwd' => 'Erfolg100%', - 'database' => 'shoppinglist', - 'theme' => 'default', + 'installed' => false, ); ?> \ No newline at end of file diff --git a/php/classes.list.php b/php/classes.list.php index 3d4d56c..f6c0e3a 100644 --- a/php/classes.list.php +++ b/php/classes.list.php @@ -41,7 +41,9 @@ $insertQuery = $mysqli->prepare("INSERT INTO `Einkauf` (`Anzahl`, `Einheit`, `Name`, `Erledigt`) VALUES (?, ?, ?, 0);"); $insertQuery->bind_param("sss", $anzahl, $einheit, $name); $result = $insertQuery->execute(); + $insertID = $mysqli->insert_id; $mysqli->close(); + return $insertID; } function newItems($itemList){ diff --git a/php/edit-list.php b/php/edit-list.php index 6fab0cf..76dff09 100644 --- a/php/edit-list.php +++ b/php/edit-list.php @@ -4,7 +4,8 @@ switch ($_GET["function"]) { case 'new': - $shopping->newItem($_POST["anzahl"], $_POST["einheit"], $_POST["name"]); + $newID = $shopping->newItem($_POST["anzahl"], $_POST["einheit"], $_POST["name"]); + setcookie("newItem", "$newID", 0, "/", ""); header("Location: /list"); break;