Skip to content

Commit 3fda4cb

Browse files
author
avscs
committed
fix
1 parent 94e9a68 commit 3fda4cb

File tree

1 file changed

+59
-51
lines changed

1 file changed

+59
-51
lines changed

games/flash/index.html

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,64 @@
11
<html>
2-
<head>
3-
<meta name="viewport" content="width=device-width, initial-scale=1">
4-
<title>Flash Player</title>
5-
<link id="favicon" rel="shortcut icon" type="image/png" href="/">
6-
</head>
7-
<body>
8-
<div id="ruffle" width="100%" height="100%"></div>
9-
<script src="ruffle.js"></script>
10-
<script>
11-
var defaultGame = (new URLSearchParams(window.location.search)).get('game');
12-
if (!defaultGame) {
13-
/*var fileInput = document.createElement('input');
14-
fileInput.type = 'file';
15-
fileInput.id = 'fileInput';
16-
var uploadButton = document.createElement('button');
17-
uploadButton.textContent = 'Upload File';
18-
uploadButton.addEventListener('click', handleFileUpload);
19-
// Append elements to the body
20-
document.body.appendChild(fileInput);
21-
document.body.appendChild(uploadButton);
222

23-
function handleFileUpload() {
24-
var uploadedFile = fileInput.files[0];
25-
if (uploadedFile) {
26-
// appears to take a url rather than local file
27-
load(uploadedFile);
28-
} else {
29-
alert('Please select a file to upload.');
30-
}
3+
<head>
4+
<meta name="viewport" content="width=device-width, initial-scale=1">
5+
<title>Flash Player</title>
6+
<link id="favicon" rel="shortcut icon" type="image/png" href="/">
7+
</head>
8+
9+
<body>
10+
<div id="ruffle" width="100%" height="100%"></div>
11+
<script src="ruffle.js"></script>
12+
<script>
13+
var defaultGame = (new URLSearchParams(window.location.search)).get('game');
14+
if (document.getElementsByTagName('base').length > 0 && !window.location.href.includes(document.getElementsByTagName('base')[0].href)) {
15+
const gameUrl = new URL(document.getElementsByTagName('base')[0].href);
16+
const gameUrlParams = (new URLSearchParams(gameUrl.search)).get('game');
17+
defaultGame = gameUrlParams || defaultGame;
18+
}
19+
if (!defaultGame) {
20+
/*var fileInput = document.createElement('input');
21+
fileInput.type = 'file';
22+
fileInput.id = 'fileInput';
23+
var uploadButton = document.createElement('button');
24+
uploadButton.textContent = 'Upload File';
25+
uploadButton.addEventListener('click', handleFileUpload);
26+
// Append elements to the body
27+
document.body.appendChild(fileInput);
28+
document.body.appendChild(uploadButton);
29+
30+
function handleFileUpload() {
31+
var uploadedFile = fileInput.files[0];
32+
if (uploadedFile) {
33+
// appears to take a url rather than local file
34+
load(uploadedFile);
35+
} else {
36+
alert('Please select a file to upload.');
3137
}
32-
*/
33-
} else {
34-
document.title = (defaultGame.replace(/-/g, ' ')).toLowerCase().split(' ').map(function(word) {
35-
return word[0].toUpperCase() + word.substr(1);
36-
}).join(' ');
37-
document.querySelector('#favicon').href = `images/${defaultGame}.png`;
38-
load(`files/${defaultGame}.swf`);
3938
}
39+
*/
40+
} else {
41+
document.title = (defaultGame.replace(/-/g, ' ')).toLowerCase().split(' ').map(function (word) {
42+
return word[0].toUpperCase() + word.substr(1);
43+
}).join(' ');
44+
document.querySelector('#favicon').href = `images/${defaultGame}.png`;
45+
load(`files/${defaultGame}.swf`);
46+
}
4047

41-
function load(game) {
42-
window.RufflePlayer = window.RufflePlayer || {};
43-
window.addEventListener("load", (event) => {
44-
const ruffle = window.RufflePlayer.newest();
45-
const player = ruffle.createPlayer();
46-
const container = document.getElementById("ruffle");
47-
player.id = "player";
48-
player.style.width = "100%";
49-
player.style.height = "100%";
50-
container.appendChild(player)
51-
player.load(game);
52-
});
53-
}
54-
</script>
55-
</body>
56-
</html>
48+
function load(game) {
49+
window.RufflePlayer = window.RufflePlayer || {};
50+
window.addEventListener("load", (event) => {
51+
const ruffle = window.RufflePlayer.newest();
52+
const player = ruffle.createPlayer();
53+
const container = document.getElementById("ruffle");
54+
player.id = "player";
55+
player.style.width = "100%";
56+
player.style.height = "100%";
57+
container.appendChild(player)
58+
player.load(game);
59+
});
60+
}
61+
</script>
62+
</body>
63+
64+
</html>

0 commit comments

Comments
 (0)