mirror of
https://github.com/XXIIVV/webring.git
synced 2024-09-11 19:47:14 +03:00
Basics
This commit is contained in:
parent
447b0441d0
commit
2f380e097a
@ -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>
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user