// timer in milliseconds
function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

async function create_popup(text = undefined, timer = undefined) {

	if (text == undefined)
		text = "notice undefined";

	let popup = document.getElementById("popup");
	popup.textContent = "Notice: " + text;
	popup.style.opacity = 0.95;
	popup.onclick = async () => {
		popup.style.opacity = 0;
		return ;
	}

	if (timer == undefined)
		timer = 5000;
	await sleep(timer);

	popup.style.opacity = 0;
	//popup.style.visibility = "hidden"

}

export {create_popup}
