script.js (1988B)
1 const Config = { 2 name: "user", 3 scale: 1, 4 Links: [ 5 [ 6 "site", 7 [ 8 ["link", "https://www.example.com"], 9 ["link", "https://www.example.com"] 10 ] 11 ], 12 [ 13 "site", 14 [ 15 ["link", "https://www.example.com"], 16 ["link", "https://www.example.com"] 17 ] 18 ], 19 [ 20 "site", 21 [ 22 ["link", "https://www.example.com"], 23 ["link", "https://www.example.com"], 24 ["link", "https://www.example.com"] 25 ] 26 ], 27 [ 28 "site", 29 [ 30 ["link", "https://www.example.com"], 31 ["link", "https://www.example.com"], 32 ["link", "https://www.example.com"], 33 ["link", "https://www.example.com"] 34 ] 35 ] 36 ] 37 } 38 39 const Main = (() => { 40 const list = document.getElementById("list"); 41 const names = document.querySelectorAll("[data-Name]"); 42 const search = document.getElementById("search"); 43 const form = document.forms[0]; 44 45 const init = () => { 46 list.innerHTML = Config.Links.map(([gName, Links]) => ` 47 <li> 48 <h1 onclick="this.parentNode.classList.toggle('hideChildren')">${gName}</h1> 49 <ul> 50 ${Links.map(([lName, url]) => ` 51 <li> 52 <a href="${url}">${lName}</a> 53 </li>` 54 ).join("")} 55 </ul> 56 </li>` 57 ).join("") 58 59 names.forEach(el => { 60 el.innerText = Config.name; 61 }); 62 63 document.addEventListener("keydown", e => e.key.length === 1 && search.focus()); 64 search.addEventListener("keydown", () => (window.event ? event.keyCode : e.which) == 13 && form.submit()); 65 }; 66 67 return { 68 init, 69 }; 70 })(); 71 72 Main.init()