-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreview.js
More file actions
22 lines (18 loc) · 729 Bytes
/
Copy pathpreview.js
File metadata and controls
22 lines (18 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const backBtn = document.getElementById("btn-back");
const fName = document.querySelector(".f-name");
const codetxt = document.querySelector(".o-field-txt");
const snippets = JSON.parse(localStorage.getItem("snippets") ?? "[]");
const id = JSON.parse(localStorage.getItem("previewID"));
snippets.forEach((item) => {
displaySnippetDetails(id);
});
function displaySnippetDetails(id) {
const item = snippets.at(id);
const fName = document.querySelector(".f-name");
const codetxt = document.querySelector(".o-field-txt");
fName.textContent = item.title;
codetxt.textContent = item.code;
}
backBtn.addEventListener("click", function () {
window.location.href = "index.html";
});