Minor cleanup

This commit is contained in:
Devine Lu Linvega 2018-10-03 15:48:55 +12:00
parent 93804e64e0
commit ae6fc2dd21
5 changed files with 104 additions and 114 deletions

View File

@ -12,6 +12,7 @@
<body>
<script>
const portal = new Portal(sites);
portal.install(document.body);
portal.start();
</script>
</body>

View File

@ -1,22 +1,15 @@
/* Input Mono */
@font-face {
font-family: 'input_mono_regular';
src: url('../media/fonts/input_mono_regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
font-family: 'input_mono_regular';
src: url('../media/fonts/input_mono_regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'input_mono_medium';
src: url('../media/fonts/input_mono_medium.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'input_mono_thin';
src: url('../media/fonts/input_mono_thin.ttf') format('truetype');
font-weight: normal;
font-style: normal;
font-family: 'input_mono_medium';
src: url('../media/fonts/input_mono_medium.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}

Binary file not shown.

View File

@ -4,31 +4,41 @@ function Portal(sites)
{
this.el = document.createElement("div");
this.sites = sites;
this.install = function()
{
document.body.appendChild(this.el);
}
this.start = function()
{
this.install();
this.el.innerHTML = window.location.hash && window.location.hash.length > 4 ? this.redirect() : this.directory();
}
// Templates
this.readme = function()
function _readme()
{
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/index.html' 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>`
}
this.buttons = function()
function _buttons()
{
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></p>`
}
this.directory = function()
function _directory(sites)
{
return `<ul>${this.sites.reduce((acc,val,id) => { return `${acc}<li>${id}) <a href='${val}'>${val.split("//")[1]}</a></li>`},"")}</ul>\n${this.readme()}${this.buttons()}`
return `
<ul>${sites.reduce((acc,val,id) => { return `${acc}<li>${id}) <a href='${val}'>${val.split("//")[1]}</a></li>`; },"")}</ul>\n${_readme()}${_buttons()}`
}
function _redirect(target)
{
return `<p>Redirecting to <b>${target}</b></p><meta http-equiv="refresh" content="3; url=${target}">
<p class='buttons'><a href='#' onClick="portal.reload('')">Directory</a> | <a href='#${target}' 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>`
}
//
this.install = function(host)
{
host.appendChild(this.el);
}
this.start = function()
{
this.el.innerHTML = window.location.hash && window.location.hash.length > 4 ? _redirect(this.next()) : _directory(this.sites);
}
this.reload = function()
@ -38,44 +48,27 @@ function Portal(sites)
this.navigate = function(target)
{
setTimeout(() => {
window.location.href = target
},3000)
}
this.location = function()
{
return window.location.hash.replace("#","").trim();
setTimeout(() => { window.location.href = target; },3000)
}
this.locate = function()
{
const hash = this.location();
const hash = window.location.hash.replace("#","").trim();
if(hash == "random"){
return Math.floor(Math.random()*this.sites.length)
}
for(const id in this.sites){
const site = this.sites[id];
if(site.indexOf(hash) >-1){
if(this.sites[id].indexOf(hash) >-1){
return parseInt(id)
}
}
return -1
return -1;
}
this.next = function(loc)
this.next = function(loc = this.locate())
{
return loc == this.sites.length-1 ? this.sites[0] : this.sites[loc+1];
}
this.redirect = function()
{
const location = this.locate();
const target = this.next(location);
this.navigate(target)
return `<p>Redirecting to <b>${target}</b></p><meta http-equiv="refresh" content="3; url=${target}">
<p class='buttons'><a href='#' onClick="portal.reload('')">Directory</a> | <a href='#${target}' 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>`
}
}

View File

@ -1,63 +1,66 @@
'use strict';
// Don't forget the comma! No trailing slashes
// protocole://url.domain.ext
const sites = [
"https://wiki.xxiivv.com"
, "http://estevancarlos.com"
, "https://electro.pizza"
, "https://monochromatic.co"
, "https://joshavanier.github.io"
, "http://kaemura.com"
, "https://liamcooke.com"
, "https://electricgecko.de"
, "https://wichniow.ski"
, "https://hraew.autophagy.io"
, "https://evenunto.net"
, "https://anxl.faith"
, "https://xvw.github.io"
, "https://heracl.es"
, "https://felipecortez.net"
, "http://luminghao.com"
, "https://theiceshelf.com"
, "https://turelio.github.io"
, "https://spaceshipsin.space"
, "http://log.lectronice.com"
, "https://craze.co.uk"
, "https://shaneckel.com"
, "https://cblgh.org"
, "https://ellugar.co"
, "http://hur.bet"
, "http://chigby.org"
, "https://longest.voyage"
, "https://palomakop.tv"
, "https://travisshears.com"
, "https://v-os.ca"
, "http://secretinternet.club"
, "https://jmandel.xyz"
, "https://systems.ws"
, "https://jamesin.space"
, "https://nathanwentworth.co"
, "https://eswat.ca"
, "https://uonai.space"
, "http://controls.ee"
, "https://wasin.io"
, "https://inns.studio"
, "http://kokorobot.ca"
, "https://ameyama.com"
, "https://wake.st"
, "https://xarene.la"
, "https://alex.zyzhang.me"
, "http://bildwissenschaft.vortok.info"
, "https://jakofranko.github.com"
, "https://aeriform.io"
, "http://blog.lucasdidthis.com"
, "http://npisanti.com"
, "https://underscorediscovery.ca"
, "https://drisc.io"
, "https://neufv.website"
, "https://simbolo.xyz"
, "https://ricky.codes"
, "https://maxdeviant.com"
, "https://tynandebold.com"
, "http://gytis.co"
, "https://nomand.co"
];
// Don't forget the comma! No trailing slashes
"https://wiki.xxiivv.com"
, "http://estevancarlos.com"
, "https://electro.pizza"
, "https://monochromatic.co"
, "https://joshavanier.github.io"
, "http://kaemura.com"
, "https://liamcooke.com"
, "https://electricgecko.de"
, "https://wichniow.ski"
, "https://hraew.autophagy.io"
, "https://evenunto.net"
, "https://anxl.faith"
, "https://xvw.github.io"
, "https://heracl.es"
, "https://felipecortez.net"
, "http://luminghao.com"
, "https://theiceshelf.com"
, "https://turelio.github.io"
, "https://spaceshipsin.space"
, "http://log.lectronice.com"
, "https://craze.co.uk"
, "https://shaneckel.com"
, "https://cblgh.org"
, "https://ellugar.co"
, "http://hur.bet"
, "http://chigby.org"
, "https://longest.voyage"
, "https://palomakop.tv"
, "https://travisshears.com"
, "https://v-os.ca"
, "http://secretinternet.club"
, "https://jmandel.xyz"
, "https://systems.ws"
, "https://jamesin.space"
, "https://nathanwentworth.co"
, "https://eswat.ca"
, "https://uonai.space"
, "http://controls.ee"
, "https://wasin.io"
, "https://inns.studio"
, "http://kokorobot.ca"
, "https://ameyama.com"
, "https://wake.st"
, "https://xarene.la"
, "https://alex.zyzhang.me"
, "http://bildwissenschaft.vortok.info"
, "https://jakofranko.github.com"
, "https://aeriform.io"
, "http://blog.lucasdidthis.com"
, "http://npisanti.com"
, "https://underscorediscovery.ca"
, "https://drisc.io"
, "https://neufv.website"
, "https://simbolo.xyz"
, "https://ricky.codes"
, "https://maxdeviant.com"
, "https://tynandebold.com"
, "http://gytis.co"
, "https://nomand.co"
];