'use strict'; function Portal(sites) { this.el = document.createElement("div"); this.sites = sites; // Templates function _readme() { return `

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 diaries, wikis & portfolios.

To add yourself to the ring, submit a Pull Request.
If you found a broken link, please report it.

` } function _buttons() { return `

Random | Information

` } function _directory(sites) { return ` \n${_readme()}${_buttons()}` } function _redirect(target) { return `

Redirecting to ${target}

Directory | Skip | Random | Information

` } // 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() { setTimeout(()=>{ window.location.reload() },500) } this.navigate = function(target) { setTimeout(() => { window.location.href = target; },3000) } this.locate = function() { const hash = window.location.hash.replace("#","").trim(); if(hash == "random"){ return Math.floor(Math.random()*this.sites.length) } for(const id in this.sites){ if(this.sites[id].indexOf(hash) >-1){ return parseInt(id) } } return -1; } this.next = function(loc = this.locate()) { return loc == this.sites.length-1 ? this.sites[0] : this.sites[loc+1]; } }