mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
* Move tests, create makefile action to run tests on examples * Correct import file for html files * Build environment for tests * Fix the CI * rearrange CI * fix find cmd and make sure we don't delete the folder implicitly * more rearranging * fix folder permissions and custom sed for subfolders * add toga wheels files * re-add missing file * mirror latest changes in alpha ci * fix find cmd * try different fix for find * remove redundant build Co-authored-by: mariana <marianameireles@protonmail.com> Co-authored-by: pww217 <pwilson@anaconda.com> Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
63 lines
1.4 KiB
JavaScript
63 lines
1.4 KiB
JavaScript
//simple resource loader
|
|
(function() {
|
|
var resourceCache = {};
|
|
var loading = [];
|
|
var readyCallbacks = [];
|
|
|
|
// Load an image url or an array of image urls
|
|
function load(urlOrArr) {
|
|
if(urlOrArr instanceof Array) {
|
|
urlOrArr.forEach(function(url) {
|
|
_load(url);
|
|
});
|
|
}
|
|
else {
|
|
_load(urlOrArr);
|
|
}
|
|
}
|
|
|
|
function _load(url) {
|
|
if(resourceCache[url]) {
|
|
return resourceCache[url];
|
|
}
|
|
else {
|
|
var img = new Image();
|
|
img.onload = function() {
|
|
resourceCache[url] = img;
|
|
|
|
if(isReady()) {
|
|
readyCallbacks.forEach(function(func) { func(); });
|
|
}
|
|
};
|
|
resourceCache[url] = false;
|
|
img.src = url;
|
|
}
|
|
}
|
|
|
|
function get(url) {
|
|
return resourceCache[url];
|
|
}
|
|
|
|
function isReady() {
|
|
var ready = true;
|
|
for(var k in resourceCache) {
|
|
if(resourceCache.hasOwnProperty(k) &&
|
|
!resourceCache[k]) {
|
|
ready = false;
|
|
}
|
|
}
|
|
return ready;
|
|
}
|
|
|
|
function onReady(func) {
|
|
readyCallbacks.push(func);
|
|
}
|
|
|
|
window.resources = {
|
|
load: load,
|
|
get: get,
|
|
onReady: onReady,
|
|
isReady: isReady
|
|
};
|
|
})();
|