1
1
mirror of https://github.com/XXIIVV/webring.git synced 2024-09-17 14:37:09 +03:00
webring/scripts/portal.js

55 lines
941 B
JavaScript
Raw Normal View History

2018-05-17 00:05:47 +03:00
function Portal(sites)
{
2018-05-17 00:22:20 +03:00
this.el = document.createElement("div");
2018-05-17 00:05:47 +03:00
this.sites = sites;
this.install = function()
{
2018-05-17 00:22:20 +03:00
document.body.appendChild(this.el)
2018-05-17 00:05:47 +03:00
}
this.start = function()
{
2018-05-17 00:22:20 +03:00
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);
2018-05-17 00:05:47 +03:00
2018-05-17 00:22:20 +03:00
console.log(location,target)
2018-05-17 00:05:47 +03:00
}
}