-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
128 lines (112 loc) · 4.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// functions
let loadMainPage = () => {
if (window.location.pathname !== '/Spatial_WebXR/index.html') {
window.location = '/Spatial_WebXR/index.html'; //githubpages
}
};
let loadVRexamples = () => {
if (window.location.pathname !== '/Spatial_WebXR/VR_index.html') {
window.location = '/Spatial_WebXR/VR_index.html'; //githubpages
}
};
let loadARexamples = () => {
if (window.location.pathname !== '/Spatial_WebXR/AR_index.html') {
window.location = '/Spatial_WebXR/AR_index.html'; //githubpages
}
};
//navigation
let aboutElement, vrElement, arElement, wglElement;
const mediaQuery = window.matchMedia('(max-width: 426px)');
if (mediaQuery.matches && window.location.pathname == '/Spatial_WebXR/index.html') {
aboutElement = document.getElementById('menu-wrapper-links-aboutProject');
let scrollAP = () => {
let scrollTo = document.getElementById('about-component');
scrollTo.scrollIntoView({ behavior: 'smooth', block: 'end', inline: 'nearest' });
};
aboutElement.addEventListener('click', scrollAP);
} else {
aboutElement = document.getElementById('menu-wrapper-links-aboutProject');
aboutElement.addEventListener('click', loadMainPage);
}
if (mediaQuery.matches && window.location.pathname == '/Spatial_WebXR/VR_index.html') {
vrElement = document.getElementById('menu-wrapper-links-WebVR');
let scrollVR = () => {
let scrollTo = document.getElementById('vrexamples-component');
scrollTo.scrollIntoView({ behavior: 'smooth', block: 'end', inline: 'nearest' });
};
vrElement.addEventListener('click', scrollVR);
} else {
vrElement = document.getElementById('menu-wrapper-links-WebVR');
vrElement.addEventListener('click', loadVRexamples);
}
if (mediaQuery.matches && window.location.pathname == '/Spatial_WebXR/AR_index.html') {
arElement = document.getElementById('menu-wrapper-links-WebAR');
let scrollAR = () => {
let scrollTo = document.getElementById('arexamples-component');
scrollTo.scrollIntoView({ behavior: 'smooth', block: 'end', inline: 'nearest' });
};
arElement.addEventListener('click', scrollAR);
} else {
arElement = document.getElementById('menu-wrapper-links-WebAR');
arElement.addEventListener('click', loadARexamples);
}
//app version
let appVersion = document.getElementById('app-version');
appVersion.innerHTML = '1.0.16';
//VR examples navigation
let loadVrExOne = () => {
if (window.location.pathname !== '/examples/example_01/ex_01.html') {
window.location = '/Spatial_WebXR/examples/example_01/ex_01.html';
}
};
let loadVrExTwo = () => {
if (window.location.pathname !== '/examples/example_02/ex_02.html') {
window.location = '/Spatial_WebXR/examples/example_02/ex_02.html';
}
};
let loadVrExThree = () => {
if (window.location.pathname !== '/examples/example_03/ex_03.html') {
window.location = '/Spatial_WebXR/examples/example_03/ex_03.html';
}
};
let loadVrExFour = () => {
if (window.location.pathname !== '/examples/example_04/ex_04.html') {
window.location = '/Spatial_WebXR/examples/example_04/ex_04.html';
}
};
let loadArExOne = () => {
if (window.location.pathname !== '/examples/example_05/ex_05.html') {
window.location = '/Spatial_WebXR/examples/example_05/ex_05.html';
}
};
let loadArExTwo = () => {
if (window.location.pathname !== '/examples/example_06/ex_06.html') {
window.location = '/Spatial_WebXR/examples/example_06/ex_06.html';
}
};
if (
window.location.pathname == '/VR_index.html' ||
window.location.pathname == '/Spatial_WebXR/VR_index.html'
) {
let btnVrOne;
btnVrOne = document.getElementById('btn-enterVR-one');
btnVrOne.addEventListener('click', loadVrExOne);
let btnVrTwo;
btnVrTwo = document.getElementById('btn-enterVR-two');
btnVrTwo.addEventListener('click', loadVrExTwo);
let btnVrThree;
btnVrThree = document.getElementById('btn-enterVR-three');
btnVrThree.addEventListener('click', loadVrExThree);
let btnVrFour;
btnVrFour = document.getElementById('btn-enterVR-four');
btnVrFour.addEventListener('click', loadVrExFour);
}
if (
window.location.pathname == '/AR_index.html' ||
window.location.pathname == '/Spatial_WebXR/AR_index.html'
) {
let btnArOne = document.getElementById('btn-enterAR-one');
btnArOne.addEventListener('click', loadArExOne);
let btnArTwo = document.getElementById('btn-enterAR-two');
btnArTwo.addEventListener('click', loadArExTwo);
}