on master help sign in
fix firefox redirect issue
50db8a2ckipp01
scripts/hallway.js+4−4
@@ -18,8 +18,8 @@ function Hallway (sites) {
18 this._main.id = 'entries'
18 this._main.id = 'entries'
19 this._footer = document.createElement('footer')
19 this._footer = document.createElement('footer')
20 this._footer.id = 'footer'
20 this._footer.id = 'footer'
21− this.readme = `<p>The <strong>Hallway</strong> is a decentralized forum, to join the conversation, add a <a href="https://github.com/XXIIVV/webring#joining-the-hallway">feed:</a> field to your entry in the <a href="https://github.com/XXIIVV/Webring/">webring</a>.</p>`
21+ this.readme = '<p>The <strong>Hallway</strong> is a decentralized forum, to join the conversation, add a <a href="https://github.com/XXIIVV/webring#joining-the-hallway">feed:</a> field to your entry in the <a href="https://github.com/XXIIVV/Webring/">webring</a>.</p>'
22− this.nav = `<p class='buttons'><a href='https://github.com/XXIIVV/webring'>Information</a> | <a href="index.html">The Portal</a> | <a href="wiki.html">The Wiki</a> | <a id="opml">OPML</a></p>`
22+ this.nav = '<p class="buttons"><a href="https://github.com/XXIIVV/webring">Information</a> | <a href="index.html">The Portal</a> | <a href="wiki.html">The Wiki</a> | <a id="opml">OPML</a></p>'
23 this._footer.innerHTML = `${this.readme}${this.nav}`
23 this._footer.innerHTML = `${this.readme}${this.nav}`
24
24
25 this.install = function (host) {
25 this.install = function (host) {
@@ -118,10 +118,10 @@ function Hallway (sites) {
118
118
119 this.templateEntry = function (entry) {
119 this.templateEntry = function (entry) {
120 entry.html = entry.body
120 entry.html = entry.body
121− .replace(reChannel, `$1<span class='channel'>/$2</span>`)
121+ .replace(reChannel, '$1<span class="channel">/$2</span>')
122 .replace(reUser, this.findMention)
122 .replace(reUser, this.findMention)
123 .replace(reTag, '$1<span class="tag">$2</span>')
123 .replace(reTag, '$1<span class="tag">$2</span>')
124− .replace(reUrl, `<a target="_blank" href='$1'>$1</a>`)
124+ .replace(reUrl, '<a target="_blank" href="$1">$1</a>')
125
125
126 const filter = window.location.hash.substr(1).replace(/\+/g, ' ').toLowerCase()
126 const filter = window.location.hash.substr(1).replace(/\+/g, ' ').toLowerCase()
127 const highlight = filter === entry.author.toLowerCase()
127 const highlight = filter === entry.author.toLowerCase()
scripts/portal.js+17−13
@@ -8,18 +8,18 @@ function Portal (sites) {
8 // Templates
8 // Templates
9
9
10 function _readme () {
10 function _readme () {
11− return `<p class='readme'>This webring is an attempt to inspire artists & developers to build their own website and share traffic among each other. The ring welcomes personalized websites such as <b>diaries, wikis & portfolios</b>.</p><p>To add yourself to the ring, submit a <a href='https://github.com/XXIIVV/webring/edit/master/scripts/sites.js' target='_blank'>Pull Request</a>.<br />If you found a broken link, please <a href='https://github.com/XXIIVV/webring/issues/new' target='_blank'>report it</a>.</p>`
11+ return '<p class="readme">This webring is an attempt to inspire artists & developers to build their own website and share traffic among each other. The ring welcomes personalized websites such as <b>diaries, wikis & portfolios</b>.</p><p>To add yourself to the ring, submit a <a href="https://github.com/XXIIVV/webring/edit/master/scripts/sites.js" target="_blank">Pull Request</a>.<br />If you found a broken link, please <a href="https://github.com/XXIIVV/webring/issues/new" target="_blank">report it</a>.</p>'
12 }
12 }
13
13
14 function _buttons () {
14 function _buttons () {
15− return `<p class='buttons'><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> | <a href="hallway.html">The Hallway</a> | <a href="wiki.html">The Wiki</a> | <a id="opml">OPML</a></p>`
15+ return '<p class="buttons"><a href="#random" onClick="portal.reload()">Random</a> | <a href="https://github.com/XXIIVV/webring">Information</a> <a id="icon" href="#random" onClick="portal.reload()"></a> | <a href="hallway.html">The Hallway</a> | <a href="wiki.html">The Wiki</a> | <a id="opml">OPML</a></p>'
16 }
16 }
17
17
18 function _directory (sites) {
18 function _directory (sites) {
19 const siteTypesArray = [...new Set(sites.map(site => site.type).filter(Boolean))]
19 const siteTypesArray = [...new Set(sites.map(site => site.type).filter(Boolean))]
20 const siteTypes = siteTypesArray.reduce((output, siteType) =>
20 const siteTypes = siteTypesArray.reduce((output, siteType) =>
21− `${output}<a data-type='${siteType}' href='#' onclick='toggleType(event)'>&lt;${siteType}&gt;</a>`,
21+ `${output}<a data-type="${siteType}" href="#" onclick="toggleType(event)">&lt;${siteType}&gt;</a>`,
22− `<a class='current' href='#' onclick='toggleType(event)'>&lt;all&gt;</a>`)
22+ '<a class="current" href="#" onclick="toggleType(event)">&lt;all&gt;</a>')
23 const listItems = sites.reduce((acc, site, id) =>
23 const listItems = sites.reduce((acc, site, id) =>
24 `${acc}<li ${_type(site)} id='${id}'><a href='${site.url}'>${_name(site)}</a></li>`, '')
24 `${acc}<li ${_type(site)} id='${id}'><a href='${site.url}'>${_name(site)}</a></li>`, '')
25 return `<nav>${siteTypes}</nav><main><ul>${listItems}</ul></main><footer>${_readme()}${_buttons()}</footer>`
25 return `<nav>${siteTypes}</nav><main><ul>${listItems}</ul></main><footer>${_readme()}${_buttons()}</footer>`
@@ -35,8 +35,7 @@ function Portal (sites) {
35
35
36 function _redirect (site) {
36 function _redirect (site) {
37 return `<main><p>Redirecting to <a href="${site.url}">${site.url}</a></p></main>
37 return `<main><p>Redirecting to <a href="${site.url}">${site.url}</a></p></main>
38− <meta http-equiv="refresh" content="3; url=${site.url}">
39− <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>`
38+ <footer><p class='buttons'><a href='#' onClick="portal.reload('')">Directory</a> | <a href='#${site.url}' onClick="portal.reload()">Skip</a> | <a href='#random' onClick="portal.reload()">Random</a> | <a href='https://github.com/XXIIVV/webring'>Information</a> <a id='icon' href='#random' onClick="portal.reload()"></a></p>`
40 }
39 }
41
40
42 //
41 //
@@ -46,7 +45,13 @@ function Portal (sites) {
46 }
45 }
47
46
48 this.start = function () {
47 this.start = function () {
49− this.el.innerHTML = window.location.hash && window.location.hash.length > 4 ? _redirect(this.next()) : _directory(this.sites)
48+ if (window.location.hash && window.location.hash.length > 4) {
49+ const site = this.next()
50+ this.el.innerHTML = _redirect(site)
51+ setTimeout(() => { window.location = site.url }, 3000)
52+ } else {
53+ this.el.innerHTML = _directory(this.sites)
54+ }
50 }
55 }
51
56
52 this.reload = function () {
57 this.reload = function () {
@@ -69,19 +74,18 @@ function Portal (sites) {
69 }
74 }
70
75
71 this.next = function (loc = this.locate()) {
76 this.next = function (loc = this.locate()) {
72− return loc == this.sites.length - 1 ? this.sites[0] : this.sites[loc + 1]
77+ return loc === this.sites.length - 1 ? this.sites[0] : this.sites[loc + 1]
73 }
78 }
74−
75}
79}
76
80
77function toggleType (e) {
81function toggleType (e) {
78 e.preventDefault()
82 e.preventDefault()
79 const navLink = e.target
83 const navLink = e.target
80 const selectedType = navLink.dataset.type
84 const selectedType = navLink.dataset.type
81− document.querySelector(`nav a.current`).classList.remove('current')
85+ document.querySelector('nav a.current').classList.remove('current')
82 navLink.classList.add('current')
86 navLink.classList.add('current')
83− document.querySelectorAll(`main li`).forEach(el => el.style.display = 'block')
87+ document.querySelectorAll('main li').forEach(el => { el.style.display = 'block' })
84− if(selectedType) {
88+ if (selectedType) {
85− document.querySelectorAll(`main li:not([data-type='${selectedType}'])`).forEach(el => el.style.display = 'none')
89+ document.querySelectorAll(`main li:not([data-type='${selectedType}'])`).forEach(el => { el.style.display = 'none' })
86 }
90 }
87}
91}