-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
265 lines (242 loc) · 11.8 KB
/
Copy pathindex.html
File metadata and controls
265 lines (242 loc) · 11.8 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<!doctype html>
<html lang="en">
<head>
<title>Freelancer: Sirius Revival</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="keywords" content="freelancer,space,action,game,roleplay,fun,retro,multiplayer,mod,sirius,revival" />
<meta name="description" content="FL:SR is a multiplayer modification for the 2003 space game ‘Freelancer’. It touches almost all aspects of the game’s balancing to provide a ‘vanilla plus’ experience. Different and yet familiar to the original game experience." />
<meta property="og:title" content="About FL:SR Freelancer Mod" />
<meta property="og:description" content="FL:SR is a multiplayer modification for the 2003 space game ‘Freelancer’. It touches almost all aspects of the game’s balancing to provide a ‘vanilla plus’ experience. Different and yet familiar to the original game experience." />
<meta property="og:site_name" content="Freelancer: Sirius Revival Mod" />
<meta property="og:locale" content="en" />
<meta property="og:url" content="https://fl-sr.eu/" />
<meta property="og:image" content="https://fl-sr.eu/flsr_icon.png" />
<meta property="og:image:type" content="image/png" />
<meta property="og:image:width" content="340" />
<meta property="og:image:height" content="340" />
<meta property="og:type" content="website" />
<link rel="icon" href="/flsr.ico" type="image/x-icon" />
<link rel="stylesheet" href="/flsr.css" />
</head>
<style>html { background-color: #242345 }</style>
<script>
function scrollToElement(selector)
{
let targetPosition = 0;
if (selector)
{
const headerElement = document.querySelector('header');
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
const rect = document.querySelector(selector).getBoundingClientRect();
targetPosition = scrollTop + rect.top - headerElement.clientHeight;
}
document.body.scrollTo({ top: targetPosition });
document.documentElement.scrollTo({ top: targetPosition });
const navigationElement = document.querySelector('#navigation');
navigationElement.setAttribute('hidden', '');
}
async function loadPageContents(resourceUrl)
{
try
{
const response = await fetch(resourceUrl);
if (response.ok)
{
const mainElement = document.querySelector('main');
mainElement.innerHTML = await response.text();
// If the imported HTML contains any script, execute it.
const scriptElements = mainElement.querySelectorAll('script');
for (const script of scriptElements)
// Execute contents of eval in an async function to allow arbitrary async code to be executed.
eval(`(async () => {${script.innerText}})()`);
}
}
catch (error)
{
console.error(`Cannot load ${resourceUrl}: `, error);
}
}
const defaultContentName = '/flsr/main.html';
const validPaths = {
'/features': {
contentName: defaultContentName,
anchor: 'features'
},
'/rules': {
contentName: defaultContentName,
anchor: 'rules'
},
'/map': {
contentName: defaultContentName,
anchor: 'map'
},
'/install':
{
contentName: defaultContentName,
anchor: 'install'
}
};
function addValidPath(path, options)
{
validPaths[path] = options;
}
function activateNavigationEntry(path)
{
const entries = document.querySelectorAll('#navigation .naventry');
for (const entry of Array.from(entries))
entry.removeAttribute('active');
path = path.startsWith('/') ? path.substring(1, path.length) : path;
path = path.split('/').at(0);
if (!path)
path = 'about';
const element = document.querySelector(`#navigation #nav-${path}`);
if (element)
element.setAttribute('active', '');
}
async function switchToPath(path, pushState = true)
{
path = path.endsWith('/') ? path.substring(0, path.length - 1) : path;
path = path.toLowerCase();
let pathEntry;
if (path in validPaths)
pathEntry = validPaths[path];
if (pathEntry && pathEntry.externalLink)
{
window.location.href = pathEntry.externalLink;
return;
}
if (pushState)
window.history.pushState(null, '', pathEntry ? path : '/');
activateNavigationEntry(path);
await loadPageContents(pathEntry && pathEntry.contentName ? pathEntry.contentName : defaultContentName);
if (pathEntry && pathEntry.anchor)
requestAnimationFrame(() => scrollToElement(`#${pathEntry.anchor}`));
else
scrollToElement('');
}
</script>
<body>
<header>
<hgroup>
<h1>SIRIUS REVIVAL</h1>
<p>Freelancer in Multiplayer</p>
</hgroup>
<script>
function scrollSliderTo(sliderElement, slideIndex)
{
sliderElement.dataset.slideIndex = slideIndex;
const slidesElement = sliderElement.querySelector('.slides');
slidesElement.scrollTo({ left: slideIndex * slidesElement.clientWidth });
}
function scrollToSlideBefore(element)
{
const sliderElement = element.parentElement;
const currentIndex = Number.parseInt(sliderElement.dataset.slideIndex);
const slidesElement = sliderElement.querySelector('.slides');
sliderElement.dataset.manuallySet = 'true';
scrollSliderTo(sliderElement, currentIndex === 0 ? slidesElement.childElementCount - 1 : currentIndex - 1)
}
function scrollToSlideAfter(element)
{
const sliderElement = element.parentElement;
const currentIndex = Number.parseInt(sliderElement.dataset.slideIndex);
const slidesElement = sliderElement.querySelector('.slides');
sliderElement.dataset.manuallySet = 'true';
scrollSliderTo(sliderElement, currentIndex + 1 < slidesElement.childElementCount ? currentIndex + 1 : 0)
}
</script>
</header>
<script>
let scrollRequestQueued = false;
window.addEventListener('scroll', () => {
if (!scrollRequestQueued)
{
scrollRequestQueued = true;
requestAnimationFrame(() => {
const headerElement = document.querySelector('header');
const navigationElement = document.querySelector('#navigation');
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
if (scrollTop > 64)
{
headerElement.setAttribute('condensed', '');
navigationElement.setAttribute('condensed', '');
}
else
{
headerElement.removeAttribute('condensed');
navigationElement.removeAttribute('condensed');
}
scrollRequestQueued = false;
})
}
}, { passive: true });
function toggleNavigation()
{
const navigationElement = document.querySelector('#navigation');
if (navigationElement.hasAttribute('hidden'))
navigationElement.removeAttribute('hidden');
else
navigationElement.setAttribute('hidden', '');
}
</script>
<nav id="navigation" hidden>
<div>
<ul>
<li><a tabindex="0" id="nav-about" class="naventry" title="About" onclick="switchToPath('/')">About</a></li>
<li><a tabindex="0" id="nav-features" class="naventry" title="Features" onclick="switchToPath('/features')">Features</a></li>
<li><a tabindex="0" id="nav-rules" class="naventry" title="Rules" onclick="switchToPath('/rules')">Rules</a></li>
<li><a tabindex="0" id="nav-map" class="naventry" title="Map" onclick="switchToPath('/map')">Map</a></li>
<li><a tabindex="0" id="nav-install" class="naventry" title="Download & Install" onclick="switchToPath('/install')">Download & Install</a></li>
<li><a tabindex="0" id="nav-credits" class="naventry" title="Open Credits page" href="https://github.com/Freelancer-Sirius-Revival/FLSR/blob/main/Credits.md">Credits</a></li>
</ul>
<button id="navigationToggle" title="Toggle Navigation" onclick="toggleNavigation()">
<div></div>
<div></div>
</button>
</div>
</nav>
<main></main>
</body>
<script>
const sliders = Array.from(document.querySelectorAll('.slider'));
let resizeRequestQueued = false;
window.addEventListener('resize', () => {
if (!resizeRequestQueued)
{
resizeRequestQueued = true;
requestAnimationFrame(() => {
for (const slider of sliders)
{
const slideIndex = Number.parseInt(slider.dataset.slideIndex);
scrollSliderTo(slider, slideIndex);
}
resizeRequestQueued = false;
})
}
}, { passive: true });
function isInVerticalViewport(element)
{
const rect = element.getBoundingClientRect();
const heightTolerance = rect.height / 4;
return rect.top >= -heightTolerance &&
rect.bottom <= (window.innerHeight + heightTolerance);
}
setInterval (() => {
for (const slider of sliders)
{
if (!slider.dataset.manuallySet && isInVerticalViewport(slider))
{
const slideIndex = Number.parseInt(slider.dataset.slideIndex);
const slidesElement = slider.querySelector('.slides');
scrollSliderTo(slider, slideIndex + 1 < slidesElement.childElementCount ? slideIndex + 1 : 0);
}
}
}, 5000);
window.addEventListener('pageshow', (event) => {
if (!event.persisted)
switchToPath(new URL(window.location).pathname);
});
window.addEventListener('popstate', () => switchToPath(new URL(window.location).pathname, false));
</script>
</html>