UNPKG

comic-bubbles

Version:

Animated comic bubbles - what else?

50 lines (42 loc) 1.38 kB
import { getScene } from './sceneCache.mjs' export function wait(ms) { return new Promise((resolve) => setTimeout(resolve, ms)) } export function fixParents(sceneId) { let scene = getScene(sceneId) fixParent(scene, undefined) } function fixParent(obj, parent) { for (let prop in obj) { //console.log(obj.getPrefStr() + '.' + prop) if ( (obj[prop] == undefined && prop != 'parent') || typeof obj[prop] == 'number' || typeof obj[prop] == 'string' || prop == 'canvas' || prop == 'ctx' ) { continue } else if (prop == 'parent' && obj[prop] != undefined) { continue } else if (prop == 'parent' && obj[prop] == undefined) { obj['parent'] = parent } else if (Array.isArray(obj[prop])) { // console.log("...isArray") for (let k = 0; k < obj[prop].length; k++) { fixParent(obj[prop][k], obj) } } else { fixParent(obj[prop], obj) } } } export function getResourceUrl(description, pathSuffix) { const currentUrl = new URL(import.meta.url) const currentPath = decodeURIComponent(currentUrl.pathname) const parentDir = currentPath.substring(0, currentPath.lastIndexOf('/')) const baseDir = parentDir.substring(0, parentDir.lastIndexOf('/')) const fullPath = baseDir + pathSuffix console.log(`##### ${description}: ${fullPath}`) return fullPath }