From d2aab08a39f04356ae9c706717bbf9d88dd4308a Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Thu, 16 Apr 2020 20:44:41 -0600 Subject: [PATCH] Tracking: bump item to top of history when tracked another time (close #40) --- www/assets/js/toolbox_track.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/www/assets/js/toolbox_track.js b/www/assets/js/toolbox_track.js index c804d74..5ab25a9 100644 --- a/www/assets/js/toolbox_track.js +++ b/www/assets/js/toolbox_track.js @@ -94,7 +94,14 @@ function openTrackingHistory(code) { } else { history = JSON.parse(history); } - if (infocontext.code != "" && !history.includes(infocontext.code)) { + if (infocontext.code != "") { + // Search the history list and remove the current code if it's there + for (var i = 0; i < history.length; i++) { + if (history[i] == infocontext.code) { + history.splice(i, 1); + } + } + // Add the code back to the list so it's at the top history.push(infocontext.code); } while (history.length > 5) {