There we go

This commit is contained in:
Devine Lu Linvega 2018-05-17 09:41:09 +12:00
parent 2f380e097a
commit 3247f77bf8

View File

@ -1,36 +1,45 @@
function Portal(sites)
{
this.el = document.createElement("div");
this.el = document.createElement("pre");
this.sites = sites;
this.install = function()
{
document.body.appendChild(this.el)
document.body.appendChild(this.el);
}
this.start = function()
{
if(window.location.hash){
this.redirect();
return;
}
this.directory();
this.install();
this.el.innerHTML = window.location.hash ? this.redirect() : this.directory();
}
this.directory = function()
{
return "hello"
var html = ""
for(id in this.sites){
var site = this.sites[id]
html += `${id}) <a href='${site}'>${site}</a>\n`
}
html += `\n<a href='#random' onClick="window.location.reload()">Random</a> | <a href='https://github.com/XXIIVV/webring'>Information</a>`
return html
}
this.location = function()
{
return "hello"
return window.location.hash.replace("#","").trim();
}
this.locate = function()
{
var hash = window.location.hash.replace("#","").trim();
var hash = this.location();
if(hash == "random"){
return Math.floor(Math.random()*this.sites.length)
}
for(var id in this.sites){
var site = this.sites[id];
if(site.indexOf(hash) >-1){
@ -50,6 +59,11 @@ function Portal(sites)
var location = this.locate();
var target = this.next(location);
console.log(location,target)
var html = ""
html = `Redirecting to ${target}
<meta http-equiv="refresh" content="30; url=${target}">
<a href='' onClick="window.location.reload()">Directory</a> | <a href='#${target}' onClick="window.location.reload()">Skip</a> | <a href='#random' onClick="window.location.reload()">Random</a> | <a href='https://github.com/XXIIVV/webring'>Information</a>`
return html
}
}