From 4bf4f754c9693672dbaccf822e24b2799f84a5e6 Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 5 Aug 2022 02:13:23 +0200 Subject: [PATCH] add prefix to item id when using as html id prevents accidental re-use of html ids --- static/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/index.js b/static/index.js index c0fac55..1b1db31 100644 --- a/static/index.js +++ b/static/index.js @@ -28,7 +28,7 @@ function renderItems() { clone.querySelector(".name").textContent = item.name; clone.querySelector(".content").textContent = item.content; clone.querySelector(".note").textContent = item.note; - clone.querySelector(".result").id = id; + clone.querySelector(".result").id = `item-${id}`; clone.querySelector("a").href = `form.html?id=${id}`; if (item.hidden) { clone.querySelector(".result").classList.add('hidden') @@ -69,7 +69,7 @@ function search(e) { const regex = new RegExp(query, 'i') for (const elem of document.getElementsByClassName('result')) { - const item = items[elem.id]; + const item = items[elem.id.substr(5)]; let found = false; if (query) { for (const a in searchAttrs) {