on master help sign in
Basics
commit2f380e097a6b73dd860d6fb1114524e7c11328de authorDevine Lu Linvega <aliceffekt@gmail.com> dateThu 17 May 2018, 09:22 (8 years ago) parent447b044
2 files changed+43−2
index.html+1−1 scripts/portal.js+42−1
index.html+1−1
@@ -16,7 +16,7 @@
1616 "https://wiki.xxiivv.com/",
1717 "http://estevancarlos.com/"
1818 ]
19− var portal = New Portal(sites);
19+ var portal = new Portal(sites);
2020 portal.start();
2121 </script>
2222</body>
scripts/portal.js+42−1
@@ -1,14 +1,55 @@
11function Portal(sites)
22{
3+ this.el = document.createElement("div");
34 this.sites = sites;
45
56 this.install = function()
67 {
7−
8+ document.body.appendChild(this.el)
89 }
910
1011 this.start = function()
1112 {
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);
1252
53+ console.log(location,target)
1354 }
1455}