@@ -1,36 +1,45 @@
1function Portal(sites)
1function Portal(sites)
3− this.el = document.createElement("div");
3+ this.el = document.createElement("pre");
4 this.sites = sites;
4 this.sites = sites;
6 this.install = function()
6 this.install = function()
8− document.body.appendChild(this.el)
8+ document.body.appendChild(this.el);
11 this.start = function()
11 this.start = function()
13− if(window.location.hash){
14+ this.el.innerHTML = window.location.hash ? this.redirect() : this.directory();
21 this.directory = function()
17 this.directory = function()
21+ for(id in this.sites){
22+ var site = this.sites[id]
23+ html += `${id}) <a href='${site}'>${site}</a>\n`
25+ html += `\n<a href='#random' onClick="window.location.reload()">Random</a> | <a href='https://github.com/XXIIVV/webring'>Information</a>`
23− return "hello"
27+ return html
26 this.location = function()
30 this.location = function()
28− return "hello"
32+ return window.location.hash.replace("#","").trim();
31 this.locate = function()
35 this.locate = function()
33− var hash = window.location.hash.replace("#","").trim();
37+ var hash = this.location();
39+ if(hash == "random"){
40+ return Math.floor(Math.random()*this.sites.length)
34 for(var id in this.sites){
43 for(var id in this.sites){
35 var site = this.sites[id];
44 var site = this.sites[id];
36 if(site.indexOf(hash) >-1){
45 if(site.indexOf(hash) >-1){
@@ -49,7 +58,12 @@ function Portal(sites)
50 var location = this.locate();
59 var location = this.locate();
51 var target = this.next(location);
60 var target = this.next(location);
53− console.log(location,target)
64+ html = `Redirecting to ${target}
65+ <meta http-equiv="refresh" content="30; url=${target}">
66+<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>`