whitebophir/client-data/js/index.js

26 lines
801 B
JavaScript
Raw Permalink Normal View History

2021-04-01 16:08:50 +00:00
function showRecentBoards() {
var parent = document.getElementById("recent-boards");
var ul = document.querySelector("#recent-boards ul");
2021-04-01 16:08:50 +00:00
ul && parent.removeChild(ul);
parent.classList.add("hidden");
var recentBoards = JSON.parse(localStorage.getItem("recent-boards")) || [];
2021-04-01 16:08:50 +00:00
if (recentBoards.length === 0) return;
var list = document.createElement("ul");
2021-04-01 16:08:50 +00:00
recentBoards.forEach(function (name) {
var listItem = document.createElement("li");
var link = document.createElement("a");
link.setAttribute("href", `/boards/${encodeURIComponent(name)}`);
2021-04-01 16:08:50 +00:00
link.textContent = name;
listItem.appendChild(link);
list.appendChild(listItem);
});
parent.appendChild(list);
parent.classList.remove("hidden");
}
window.addEventListener("pageshow", showRecentBoards);