@@ -1,36 +1,45 @@
11function Portal(sites)
22{
3− this.el = document.createElement("div");
3+ this.el = document.createElement("pre");
44 this.sites = sites;
55
66 this.install = function()
77 {
8− document.body.appendChild(this.el)
8+ document.body.appendChild(this.el);
99 }
1010
1111 this.start = function()
1212 {
13− if(window.location.hash){
14− this.redirect();
15− return;
16− }
17−
18− this.directory();
13+ this.install();
14+ this.el.innerHTML = window.location.hash ? this.redirect() : this.directory();
1915 }
2016
2117 this.directory = function()
2218 {
23− return "hello"
19+ var html = ""
20+
21+ for(id in this.sites){
22+ var site = this.sites[id]
23+ html += `${id}) <a href='${site}'>${site}</a>\n`
24+ }
25+ html += `\n<a href='#random' onClick="window.location.reload()">Random</a> | <a href='https://github.com/XXIIVV/webring'>Information</a>`
26+
27+ return html
2428 }
2529
2630 this.location = function()
2731 {
28− return "hello"
32+ return window.location.hash.replace("#","").trim();
2933 }
3034
3135 this.locate = function()
3236 {
33− var hash = window.location.hash.replace("#","").trim();
37+ var hash = this.location();
38+
39+ if(hash == "random"){
40+ return Math.floor(Math.random()*this.sites.length)
41+ }
42+
3443 for(var id in this.sites){
3544 var site = this.sites[id];
3645 if(site.indexOf(hash) >-1){
@@ -49,7 +58,12 @@ function Portal(sites)
4958 {
5059 var location = this.locate();
5160 var target = this.next(location);
61+
62+ var html = ""
5263
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>`
67+ return html
5468 }
5569}