MyTube/public/js/toasts.js

24 lines
738 B
JavaScript
Raw Permalink Normal View History

2021-01-06 23:43:51 +00:00
(function () {
let toastCounter = 0;
const toastTime = 3000;
window.toast = function (str) {
let id = "toast" + toastCounter++;
let element = document.createElement("div");
element.id = id;
element.className = "customToast customToastStart";
element.innerText = str;
document.body.appendChild(element);
window.setTimeout(function () {
element.className = "customToast customToastMain";
}, 0);
window.setTimeout(function () {
element.className = "customToast customToastStop";
}, toastTime);
window.setTimeout(function () {
document.body.removeChild(element);
}, toastTime + 1000)
}
})();