forked from gn-math/html
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18.html
More file actions
159 lines (141 loc) · 5.41 KB
/
18.html
File metadata and controls
159 lines (141 loc) · 5.41 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
<!DOCTYPE html>
<html lang="en-us">
<head>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-');
</script>
<base href="https://cdn.jsdelivr.net/gh/bubbls/youtube-playables@deb1b2add97f0d2eccb9d8c6a2fc540e54cd4a9e/stacky-dash/">
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>YT Game Wrapper WebGL Template</title>
<link rel="stylesheet" href="TemplateData/style.css" nonce="HAt98xrEi1FgKij6Uu5NSw">
<script src="https://cdn.jsdelivr.net/gh/bubbls/youtube-playables@main/ytgame.js" nonce="HAt98xrEi1FgKij6Uu5NSw">// Load YT Game API code</script>
</head>
<body>
<div id="unity-container" class="unity-desktop">
<canvas id="unity-canvas" width=100% height=100% tabindex="-1"></canvas>
<div id="unity-loading-bar">
<div id="unity-logo"></div>
<div id="unity-progress-bar-empty">
<div id="unity-progress-bar-full"></div>
</div>
</div>
<div id="unity-warning"> </div>
</div>
<script src="unarchiver.min.js" nonce="HAt98xrEi1FgKij6Uu5NSw"></script>
<script nonce="HAt98xrEi1FgKij6Uu5NSw">
var container = document.querySelector("#unity-container");
var canvas = document.querySelector("#unity-canvas");
var loadingBar = document.querySelector("#unity-loading-bar");
var progressBarFull = document.querySelector("#unity-progress-bar-full");
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
var fullscreenOverlayButton = document.querySelector("#unity-overlay-fullscreen-button");
var quitcanvas = document.querySelector("#quit-canvas");
var warningBanner = document.querySelector("#unity-warning");
function unityShowBanner(msg, type) {}
var buildUrl = "Build";
var loaderUrl = buildUrl + "/Web.loader.js";
var config = {
dataUrl: buildUrl + "/Web.data.unityweb",
frameworkUrl: buildUrl + "/Web.framework.js.unityweb",
codeUrl: buildUrl + "/Web.wasm.unityweb",
streamingAssetsUrl: "StreamingAssets",
companyName: "Born2Play",
productName: "StackyDash",
productVersion: "4.8.6",
showBanner: unityShowBanner,
};
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
var meta = document.createElement('meta');
meta.name = 'viewport';
meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
document.getElementsByTagName('head')[0].appendChild(meta);
container.className = "unity-mobile";
canvas.className = "unity-mobile";
} else {
canvas.style.width = "100%";
canvas.style.height = "100%";
}
loadingBar.style.display = "block";
loadResources = (callback) => {
var codeUrl = config.codeUrl;
var shouldDecompress = true;
let processedCount = 0;
let readyDefiner = () => {
processedCount++;
if(processedCount === 2) {
callback();
}
}
DecompressFile(config.codeUrl, 'application/wasm', (file) => {
config.codeUrl = file;
readyDefiner();
});
DecompressFile(config.dataUrl, 'application/data', (file) => {
config.dataUrl = file;
readyDefiner();
});
}
loadZipData = (url, callback) => {
fetch(url)
.then(response => response.blob())
.then(blob => {
callback(blob);
});
}
function UrlExists(urlToCheck)
{
var httpReq = new XMLHttpRequest();
httpReq.open('HEAD', urlToCheck, false);
httpReq.send();
return httpReq.status!=404;
}
function DecompressFile(file, blobMimeType, callback) {
let decompressedFile;
loadZipData(file, (f) => {
Unarchiver.open(f).then(async function (archive) {
for (let entry of archive.entries) {
if (entry.is_file) {
let entryRead = await entry.read();
let entryData = await entryRead.arrayBuffer();
let dataBlob = new Blob([new Uint8Array(entryData)], { type: blobMimeType });
decompressedFile = window.URL.createObjectURL(dataBlob);
}
}
callback(decompressedFile);
});
});
}
var unityGameInstance = null;
function InitUnitySection() {
var script = document.createElement("script");
script.src = loaderUrl;
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
progressBarFull.style.width = 100 * progress + "%";
}).then((unityInstance) => {
unityGameInstance = unityInstance;
loadingBar.style.display = "none";
}).catch((message) => {
console.error(message);
});
};
document.body.appendChild(script);
}
InitUnitySection();
window.onfocus = function() {
unityGameInstance.SendMessage("YTGameWrapper", "ReceiveOnResumeEvent");
};
window.onblur = function() {
unityGameInstance.SendMessage("YTGameWrapper", "ReceiveOnPauseEvent");
};
</script>
</body>
</html>