on master help sign in
add in forgotten random
commita651d20080a1b97a0c2776df415a45ce65fe4947 authorckipp01 <ckipp@pm.me> dateSat 10 Aug 2019, 12:07 (7 years ago) parent42d7c39
2 files changed+7−1
links/main.css+1 scripts/wiki.js+6−1
links/main.css+1
@@ -58,6 +58,7 @@ body #wiki { background: #ccc; color:#333; }
5858body #wiki main { display: flex; }
5959body #wiki main { flex: 1; }
6060body #wiki main { max-width: calc(100% - 230px); }
61+body #wiki main a { text-decoration: underline; }
6162body #wiki main h1 { font-size: 1.3em; margin: 5px 0; font-weight: bold; }
6263body #wiki main div.related { border-bottom: 1px solid white; margin-bottom: 10px; }
6364body #wiki #main { width: 100%; }
scripts/wiki.js+6−1
@@ -40,6 +40,11 @@ const Wiki = sites => {
4040 ? 'selected'
4141 : ''
4242
43+ const randomTerm = () => {
44+ const keys = Object.keys(entries)
45+ return keys[Math.floor(Math.random() * keys.length)]
46+ }
47+
4348 const formatSideBarCat = (key, entries) => (currentHtml, cat) => {
4449 const catLength = Object.keys(entries[cat]).length
4550 const newHtml = `<li class='${selected(key, cat)}'}'>
@@ -98,7 +103,7 @@ const Wiki = sites => {
98103 : ''
99104 main.innerHTML = `<div class='related'><h1>${key}</h1>${relatedHtml}</div>${items}`
100105 } else {
101− const html = `Click a /topic to get started, or try a random page`
106+ const html = `Click a /topic to get started, or try a <a href='#${randomTerm()}'>random page</a>`
102107 const stats = `The wiki contains ${terms.size} terms in ${Object.keys(entries).length} categories, from ${authors.size} authors.`
103108 main.innerHTML = `${html}<br />${stats}`
104109 }