@@ -16,19 +16,22 @@ function Portal (sites) {
1616 }
1717
1818 function _directory (sites) {
19− return `
20− <ul>${sites.reduce( (acc, site, id) =>
21− `${acc}<li ${site.type ? `data-type="${site.type}"` : ''} id='${id}'><a href='${site.url}'>${_name(site)}</a></li>`
22− , '')}</ul>\n${_readme()}${_buttons()}`
19+ const listItems= sites.reduce((acc, site, id) => `${acc}<li ${_type(site)} id='${id}'><a href='${site.url}'>${_name(site)}</a></li>`, '')
20+ return `<main><ul>${listItems}</ul></main><footer>${_readme()}${_buttons()}</footer>`
2321 }
2422
2523 function _name (site) {
2624 return site.title || `${site.url.split('//')[1]}`
2725 }
2826
27+ function _type (site) {
28+ return site.type ? `data-type="${site.type}"` : ''
29+ }
30+
2931 function _redirect (site) {
30− return `<p id='footer'>Redirecting to <a href="${site.url}">${site.url}</a></p><meta http-equiv="refresh" content="3; url=${site.url}">
31− <p class='buttons'><a href='#' onClick="portal.reload('')">Directory</a> | <a href='#${site.url}' onClick="portal.reload('random')">Skip</a> | <a href='#random' onClick="portal.reload('random')">Random</a> | <a href='https://github.com/XXIIVV/webring'>Information</a> <a id='icon' href='#random' onClick="portal.reload('random')"></a></p>`
32+ return `<main><p>Redirecting to <a href="${site.url}">${site.url}</a></p></main>
33+ <meta http-equiv="refresh" content="3; url=${site.url}">
34+ <footer><p class='buttons'><a href='#' onClick="portal.reload('')">Directory</a> | <a href='#${site.url}' onClick="portal.reload('random')">Skip</a> | <a href='#random' onClick="portal.reload('random')">Random</a> | <a href='https://github.com/XXIIVV/webring'>Information</a> <a id='icon' href='#random' onClick="portal.reload('random')"></a></p>`
3235 }
3336
3437 //
@@ -52,17 +55,12 @@ function Portal (sites) {
5255 this.locate = function () {
5356 const hash = window.location.hash.replace('#', '').trim()
5457
55− if (hash == 'random') {
58+ if (hash === 'random') {
5659 return Math.floor(Math.random() * this.sites.length)
60+ } else {
61+ const id = sites.findIndex(site => site.url.indexOf(hash) > -1)
62+ return id > -1 ? parseInt(id) : -1
5763 }
58−
59− for (const id in this.sites) {
60− const site = this.sites[id]
61− if (site.url.indexOf(hash) > -1) {
62− return parseInt(id)
63− }
64− }
65− return -1
6664 }
6765
6866 this.next = function (loc = this.locate()) {