mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-15 10:12:06 -05:00
Upload files to "semag/shape"
This commit is contained in:
parent
687e0fc2aa
commit
74db1d7b80
BIN
semag/shape/favicon.png
Normal file
BIN
semag/shape/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
62
semag/shape/index.html
Normal file
62
semag/shape/index.html
Normal file
@ -0,0 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>ld53</title>
|
||||
|
||||
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="./favicon.png">
|
||||
|
||||
<script src="./progress.js"></script>
|
||||
|
||||
<script>
|
||||
window.addEventListener ("touchmove", function (event) { event.preventDefault (); }, { capture: false, passive: false });
|
||||
if (typeof window.devicePixelRatio != 'undefined' && window.devicePixelRatio > 2) {
|
||||
var meta = document.getElementById ("viewport");
|
||||
meta.setAttribute ('content', 'width=device-width, initial-scale=' + (2 / window.devicePixelRatio) + ', user-scalable=no');
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
html,body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
|
||||
#openfl-content { background: #000000; width: 800px; height: 600px; }
|
||||
#progress { position: relative; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 50%; }
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<noscript>This webpage makes extensive use of JavaScript. Please enable JavaScript in your web browser to view this page.</noscript>
|
||||
|
||||
<div id="openfl-content"><progress id="progress" value="0" max = "1"></progress></div>
|
||||
|
||||
<script>
|
||||
|
||||
var __filesToLoad = {
|
||||
"./ld53.js": {total: 2360761}
|
||||
}
|
||||
|
||||
var __progressBar;
|
||||
|
||||
var __progressListener = function __progressListener(progress) {
|
||||
if(!__progressBar) __progressBar = document.getElementById("progress");
|
||||
if(__progressBar) __progressBar.value = progress;
|
||||
};
|
||||
|
||||
var __completionCallback = function __completionCallback() {
|
||||
__progressBar.parentNode.removeChild(__progressBar);
|
||||
lime.embed ("ld53", "openfl-content", 800, 600, { parameters: {} });
|
||||
};
|
||||
|
||||
__loadWithProgress(__filesToLoad, __progressListener, __completionCallback);
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
82
semag/shape/progress.js
Normal file
82
semag/shape/progress.js
Normal file
@ -0,0 +1,82 @@
|
||||
var __loadWithProgress = function __loadWithProgress(filesToLoad, progressListener, completionCallback) {
|
||||
var progressManager = {},
|
||||
interval;
|
||||
var __loadedFiles = {};
|
||||
|
||||
var scriptsToLoad = Object.keys(filesToLoad).filter(function (url) {return url.indexOf('.js') > 0;});
|
||||
|
||||
var sentProgress = false;
|
||||
|
||||
var fileCount = Object.keys(filesToLoad).length;
|
||||
|
||||
var __loadFile = function __loadFile(url) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('GET', url);
|
||||
request.responseType = 'blob';
|
||||
|
||||
request.onload = function () {
|
||||
if (request.status === 200) {
|
||||
__loadedFiles[url] = request.response;
|
||||
if(--fileCount == 0)
|
||||
__prepareScripts();
|
||||
} else {
|
||||
console.error("Couldn't load " + url);
|
||||
}
|
||||
};
|
||||
|
||||
request.onerror = function () {
|
||||
console.error("Couldn't load " + url);
|
||||
};
|
||||
|
||||
request.onprogress = function (event) {
|
||||
progressManager[url] = {
|
||||
loaded: event.loaded,
|
||||
total: filesToLoad[url].total
|
||||
};
|
||||
};
|
||||
|
||||
request.send();
|
||||
};
|
||||
|
||||
var urls = Object.keys(filesToLoad);
|
||||
interval = setInterval(function () {
|
||||
var currentProgress = __getProgress() || 0;
|
||||
progressListener(currentProgress);
|
||||
sentProgress = true;
|
||||
if (currentProgress === 1 && Object.keys(progressManager).length === urls.length) clearInterval(interval);
|
||||
}, 50);
|
||||
|
||||
var __getProgress = function __getProgress() {
|
||||
var loaded = 0,
|
||||
total = 0;
|
||||
Object.keys(progressManager).forEach(function (url) {
|
||||
loaded += progressManager[url].loaded;
|
||||
total += progressManager[url].total;
|
||||
});
|
||||
return loaded / total;
|
||||
};
|
||||
|
||||
var urlCreator = window.URL || window.webkitURL;
|
||||
|
||||
var __prepareScripts = function __prepareScripts() {
|
||||
var scriptCount = scriptsToLoad.length;
|
||||
scriptsToLoad.forEach(function(url) {
|
||||
var script = document.createElement('script'),
|
||||
src = urlCreator.createObjectURL(__loadedFiles[url]);
|
||||
script.src = src;
|
||||
script.onload = function(){
|
||||
if(--scriptCount == 0)
|
||||
{
|
||||
if(!sentProgress)
|
||||
progressListener(1.0);
|
||||
completionCallback();
|
||||
}
|
||||
};
|
||||
document.body.appendChild(script);
|
||||
});
|
||||
};
|
||||
|
||||
Object.keys(filesToLoad).forEach(function(url) {
|
||||
__loadFile(url);
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user