-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.html
More file actions
267 lines (240 loc) · 10.8 KB
/
index.html
File metadata and controls
267 lines (240 loc) · 10.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
266
267
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta property="og:title" content="Slope Plus Online">
<meta property="og:description" content="Play Slope Plus unblocked, with no ads. Supports saving your progress!">
<meta property="og:image" content="https://lonfro.github.io/SlopePlusWeb/home/icon.png">
<meta property="og:url" content="https://lonfro.github.io/SlopePlusWeb/">
<meta property="og:type" content="website">
<!-- android -->
<meta name="mobile-web-app-capable" content="yes">
<script>
if ('serviceWorker' in navigator) {
// Register root SW so it controls / and can fetch /version.txt
navigator.serviceWorker.register('/sw.js').then(reg=>{
console.log('[page] SW registered scope=', reg.scope);
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage({type:'FORCE_CHECK'});
} else {
navigator.serviceWorker.addEventListener('controllerchange', () => {
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage({type:'FORCE_CHECK'});
}
});
}
}).catch(e=>console.warn('SW reg failed',e));
navigator.serviceWorker.addEventListener('message', evt => {
if (!evt.data) return;
if (evt.data.type === 'VERSION_UPDATE') {
console.log('[page] VERSION_UPDATE new version =', evt.data.version);
setTimeout(()=>location.reload(),150);
} else if (evt.data.type === 'VERSION_INFO') {
console.log('[page] Active SW version =', evt.data.version);
}
});
window.requestSWVersion = () => {
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage({type:'GET_VERSION'});
} else {
console.log('No SW controller yet.');
}
};
}
</script>
<!-- ios -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Slope Mobile">
<link rel="apple-touch-icon" href="/PWA/icon.png">
<!-- Canonical: signal /home/ as the primary landing page for search while still serving this root to users -->
<link rel="canonical" href="https://lonfro.github.io/SlopePlusWeb/home/" />
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Slope Plus</title>
<link id="favicon-png" rel="icon" type="image/png" href="/icon.png">
<link id="favicon-ico" rel="shortcut icon" href="/TemplateData/favicon.ico">
<link rel="stylesheet" href="style.css">
<script src="TemplateData/UnityProgress.js"></script>
<script src="Build/UnityLoader.js"></script>
<script>
// Prevent pinch zoom / gesture events
['gesturestart','gesturechange','gestureend'].forEach(type=>{
document.addEventListener(type, e=>e.preventDefault());
});
var gameInstance;
function initUnity() {
if (gameInstance) return;
const container = document.getElementById('gameContainer');
if (!container) {
// If container still not present, try again at DOMContentLoaded
window.addEventListener('DOMContentLoaded', initUnity, { once: true });
return;
}
gameInstance = UnityLoader.instantiate('gameContainer', 'Build/SlopePlusWeb.json', { onProgress: UnityProgress });
}
const isAndroid = /android/i.test(navigator.userAgent);
if (isAndroid) {
window.addEventListener('DOMContentLoaded', initUnity, { once: true });
} else {
// Try immediate; fallback to DOMContentLoaded if container not yet there
initUnity();
}
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
function closeWarning() {
const gameDiv = document.getElementById('gameContainer');
if (!gameDiv) return;
const button = gameDiv.querySelector('button');
if (button) {
button.click();
return true;
}
return false;
}
function resizeGameContainer() {
var container = document.getElementById('gameContainer');
container.style.width = window.innerWidth + 'px';
container.style.height = window.innerHeight + 'px';
if (typeof gameInstance !== 'undefined' && gameInstance.Module) {
if (gameInstance.Module.setCanvasSize) {
gameInstance.Module.setCanvasSize(window.innerWidth, window.innerHeight);
}
}
}
window.addEventListener('resize', resizeGameContainer);
window.addEventListener('DOMContentLoaded', () => {
resizeGameContainer();
const popup = document.getElementById('popup');
popup.classList.remove('hidden');
void popup.offsetWidth;
setTimeout(() => {
popup.classList.add('hidden');
setTimeout(() => {
popup.remove();
}, 3000);
}, 2000);
const interval = setInterval(() => {
if (closeWarning()) {
clearInterval(interval); // Stop once clicked
}
}, 500);
setTimeout(() => {
clearInterval(interval); // Stop after 10 seconds
}, 10000);
});
</script>
<script src="Patches/i18n.js"></script>
</head>
<body>
<button id="keyboard-btn" class="keyboard-btn" type="button" aria-label="Open keyboard">
<img src="home/keyboard.png" alt="" style="width: 28px; height: 28px;">
</button>
<input id="keyboard-input" class="keyboard-input" type="text" style="position:absolute;opacity:0;pointer-events:none;">
<div id="keybindMenu" class="hidden">
<h3 data-i18n="root.settings.title">Settings</h3>
<div class="keybind-row">
<div class="keybind-btn lang-switcher-row" style="cursor:default;">
<span class="keybind-label" data-i18n="root.settings.language">Language:</span>
<div class="lang-switcher-btns">
<button class="lang-btn" data-lang="en">EN</button>
<button class="lang-btn" data-lang="zh-CN">中文</button>
<button class="lang-btn" data-lang="ja">日本語</button>
<button class="lang-btn" data-lang="de">DE</button>
<button class="lang-btn" data-lang="es">ES</button>
</div>
</div>
</div>
<div class="keybind-row keybind-row-pair">
<button id="leftKeyBtn" class="keybind-btn">
<span class="keybind-label" id="leftKeyValueLabel" data-i18n="root.settings.left">Left:</span>
<span class="keybind-value-box" id="leftKeyValueBox">
<span class="keybind-value" id="leftKeyValue">A</span>
</span>
</button>
<button id="rightKeyBtn" class="keybind-btn">
<span class="keybind-label" id="rightKeyValueLabel" data-i18n="root.settings.right">Right:</span>
<span class="keybind-value-box" id="rightKeyValueBox">
<span class="keybind-value" id="rightKeyValue">D</span>
</span>
</button>
</div>
<div class="keybind-row">
<button id="hideKeyBtn" class="keybind-btn">
<span class="keybind-label" id="hideKeyValueLabel" data-i18n="root.settings.hide">Hide game:</span>
<span class="keybind-value-box" id="hideKeyValueBox">
<span class="keybind-value" id="hideKeyValue">\</span>
</span>
</button>
</div>
<div class="keybind-row">
<button id="keybindMenuKeyBtn" class="keybind-btn">
<span class="keybind-label" id="keybindMenuKeyValueLabel" data-i18n="root.settings.menuKey">Settings:</span>
<span class="keybind-value-box" id="keybindMenuKeyValueBox">
<span class="keybind-value" id="keybindMenuKeyValue">ShiftRight</span>
</span>
</button>
</div>
<div class="keybind-row">
<button id="freezeGameBtn" class="keybind-btn">
<span class="keybind-label" id="freezeGameValueLabel" data-i18n="root.settings.pause">Pause on unfocus:</span>
<span class="toggle-box" id="freezeGameValueBox">
<span class="toggle-slider" id="freezeGameValue">O</span>
</span>
</button>
</div>
<div class="keybind-row">
<button id="exportDataBtn" class="keybind-btn">
<span class="keybind-label" data-i18n="root.settings.export">Export Data</span>
</button>
</div>
<div class="keybind-row">
<button id="importDataBtn" class="keybind-btn">
<span class="keybind-label" data-i18n="root.settings.import">Import Data</span>
</button>
</div>
<button id="closeMenuBtn" class="close-btn" data-i18n="root.settings.close">Close</button>
</div>
<div id="popup" class="hidden">
<span id="bold" data-i18n="root.popup.ported">Slope Plus</span>
<a href="https://github.com/lonfro/SlopePlusWeb" target="_blank">
<span data-i18n="root.popup.github">GitHub Repo</span>
</a>
<a href="https://lonfro.github.io/slopemobile">
<span data-i18n="root.popup.old">Old Slope Mobile</span>
</a>
<p id="dynamicOptions"></p>
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
const dynamicOptions = document.getElementById("dynamicOptions");
let keybindMenuKey = localStorage.getItem('keybindMenuKey') || 'ShiftRight';
let optionKey;
if (keybindMenuKey == 'ShiftRight') {
optionKey = "right-shift";
} else if (keybindMenuKey && keybindMenuKey.startsWith('Key')) {
optionKey = keybindMenuKey.replace('Key', '').toUpperCase();
} else {
optionKey = keybindMenuKey ? keybindMenuKey : "right-shift";
}
dynamicOptions.innerHTML = `
<span data-i18n="root.popup.press">Press</span> ${optionKey} <span data-i18n="root.popup.forOptions">for options</span>
`;
if (window.applyI18n) window.applyI18n();
});
</script>
<div class="webgl-content">
<div id="gameContainer"></div>
</div>
<div class="hider" style="display: none; background-color: white; height:100vh; width:100vw; position: fixed; top: 0; left: 0; z-index: 9999;">
<h1 style="margin-left: 10px; font-size: 25px; font-family:Arial, Helvetica, sans-serif; font-weight:bold;">
404 not found
</h1>
</div>
<script src="Patches/mobile.js"> </script>
<script src="Patches/import.js"> </script>
<script src="Patches/settings.js"> </script>
<script src="Patches/freezegame.js"> </script> // btw freezegame relies on variables in settings
<script></script>
</body>
</html>