From 87e896cbe6ce3359dfcf08fed6c2e1b4113d7799 Mon Sep 17 00:00:00 2001 From: Tim Krehan Date: Thu, 23 May 2019 08:47:48 +0200 Subject: [PATCH] provide new item flashing --- bin/list.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/bin/list.js b/bin/list.js index 24f877a..5b234dc 100644 --- a/bin/list.js +++ b/bin/list.js @@ -9,9 +9,24 @@ $(document).ready(function () { function highlightNewEntry(){ var cookies = document.cookie; - var cookieRegExp = new RegExp(/newItem(\d+)/ig); - console.log(cookies.match(cookieRegExp)); - + var cookieRegExp = new RegExp(/;?\s+newItem=(\d+)/g); + var match = cookieRegExp.exec(cookies); + if(match!=null){ + var newID = match[1]; + var checkBox = $("[data-id=" + newID + "]"); + var newRow = checkBox.parent().parent(); + newRow.removeClass($(checkBox).data("color")); + newRow.addClass("alert-primary"); + setTimeout(function () { + newRow.css({ + transition: ".5s" + }); + newRow.removeClass("alert-primary"); + newRow.addClass($(checkBox).data("color")); + }, 1000); + document.cookie = "newItem=-1" + console.log(document.cookie); + } } function deleteCheckeditems() {