on master help sign in
Basics
2f380e0Devine Lu Linvega
index.html+1−1
@@ -16,7 +16,7 @@
16 "https://wiki.xxiivv.com/",
16 "https://wiki.xxiivv.com/",
17 "http://estevancarlos.com/"
17 "http://estevancarlos.com/"
18 ]
18 ]
19− var portal = New Portal(sites);
19+ var portal = new Portal(sites);
20 portal.start();
20 portal.start();
21 </script>
21 </script>
22</body>
22</body>
scripts/portal.js+42−1
@@ -1,14 +1,55 @@
1function Portal(sites)
1function Portal(sites)
2{
2{
3+ this.el = document.createElement("div");
3 this.sites = sites;
4 this.sites = sites;
4
5
5 this.install = function()
6 this.install = function()
6 {
7 {
7−
8+ document.body.appendChild(this.el)
8 }
9 }
9
10
10 this.start = function()
11 this.start = function()
11 {
12 {
13+ if(window.location.hash){
14+ this.redirect();
15+ return;
16+ }
17+
18+ this.directory();
19+ }
20+
21+ this.directory = function()
22+ {
23+ return "hello"
24+ }
25+
26+ this.location = function()
27+ {
28+ return "hello"
29+ }
30+
31+ this.locate = function()
32+ {
33+ var hash = window.location.hash.replace("#","").trim();
34+ for(var id in this.sites){
35+ var site = this.sites[id];
36+ if(site.indexOf(hash) >-1){
37+ return parseInt(id)
38+ }
39+ }
40+ return -1
41+ }
42+
43+ this.next = function(loc)
44+ {
45+ return loc == this.sites.length-1 ? this.sites[0] : this.sites[loc+1];
46+ }
47+
48+ this.redirect = function()
49+ {
50+ var location = this.locate();
51+ var target = this.next(location);
12
52
53+ console.log(location,target)
13 }
54 }
14}
55}