// General UI tools (progress bar, toast, prompt) /// Handle progress bars const Progress = { domElement : null, // the DOM element sticky : false, // Progress.show({..., sticky:true}) don't remove until Progress.hide({sticky:true}) interval : undefined, // the interval used if Progress.show({percent:"animate"}) percent : undefined, // the current progress percentage min : 0, // scaling for percentage max : 1, // scaling for percentage /* Show a Progress message Progress.show({ sticky : bool // keep showing text even when Progress.hide is called (unless Progress.hide({sticky:true})) percent : number | "animate" min : // minimum scale for percentage (default 0) max : // maximum scale for percentage (default 1) }) */ show : function(options) { options = options||{}; let text = options.title; if (options.sticky) Progress.sticky = true; if (options.min!==undefined) Progress.min = options.min; if (options.max!==undefined) Progress.max = options.max; let percent = options.percent; if (percent!==undefined) percent = Progress.min*100 + (Progress.max-Progress.min)*percent; if (!Progress.domElement) { if (Progress.interval) { clearInterval(Progress.interval); Progress.interval = undefined; } if (options.percent == "animate") { Progress.interval = setInterval(function() { Progress.percent += 2; if (Progress.percent>100) Progress.percent=0; Progress.show({percent:Progress.percent}); }, 100); Progress.percent = percent = 0; } let toastcontainer = document.getElementById("toastcontainer"); Progress.domElement = htmlElement(`