@@ -16,19 +16,22 @@ function Portal (sites) {
18 function _directory (sites) {
18 function _directory (sites) {
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>`
19+ const listItems= sites.reduce((acc, site, id) => `${acc}<li ${_type(site)} id='${id}'><a href='${site.url}'>${_name(site)}</a></li>`, '')
22− , '')}</ul>\n${_readme()}${_buttons()}`
20+ return `<main><ul>${listItems}</ul></main><footer>${_readme()}${_buttons()}</footer>`
25 function _name (site) {
23 function _name (site) {
26 return site.title || `${site.url.split('//')[1]}`
24 return site.title || `${site.url.split('//')[1]}`
27+ function _type (site) {
28+ return site.type ? `data-type="${site.type}"` : ''
29 function _redirect (site) {
31 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}">
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}">
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>`
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>`
@@ -52,17 +55,12 @@ function Portal (sites) {
52 this.locate = function () {
55 this.locate = function () {
53 const hash = window.location.hash.replace('#', '').trim()
56 const hash = window.location.hash.replace('#', '').trim()
55− if (hash == 'random') {
58+ if (hash === 'random') {
56 return Math.floor(Math.random() * this.sites.length)
59 return Math.floor(Math.random() * this.sites.length)
61+ const id = sites.findIndex(site => site.url.indexOf(hash) > -1)
62+ return id > -1 ? parseInt(id) : -1
59− for (const id in this.sites) {
60− const site = this.sites[id]
61− if (site.url.indexOf(hash) > -1) {
68 this.next = function (loc = this.locate()) {
66 this.next = function (loc = this.locate()) {