1
1
mirror of https://github.com/XXIIVV/webring.git synced 2024-09-11 19:47:14 +03:00
This commit is contained in:
Devine Lu Linvega 2018-05-17 09:22:20 +12:00
parent 447b0441d0
commit 2f380e097a
2 changed files with 43 additions and 2 deletions

View File

@ -16,7 +16,7 @@
"https://wiki.xxiivv.com/",
"http://estevancarlos.com/"
]
var portal = New Portal(sites);
var portal = new Portal(sites);
portal.start();
</script>
</body>

View File

@ -1,14 +1,55 @@
function Portal(sites)
{
this.el = document.createElement("div");
this.sites = sites;
this.install = function()
{
document.body.appendChild(this.el)
}
this.start = function()
{
if(window.location.hash){
this.redirect();
return;
}
this.directory();
}
this.directory = function()
{
return "hello"
}
this.location = function()
{
return "hello"
}
this.locate = function()
{
var hash = window.location.hash.replace("#","").trim();
for(var id in this.sites){
var site = this.sites[id];
if(site.indexOf(hash) >-1){
return parseInt(id)
}
}
return -1
}
this.next = function(loc)
{
return loc == this.sites.length-1 ? this.sites[0] : this.sites[loc+1];
}
this.redirect = function()
{
var location = this.locate();
var target = this.next(location);
console.log(location,target)
}
}