1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| var bubbleNum = 0; function bubbleNoticer(text, type, time = 1500) { bubbleNum = setBubbleNoticer(text, type, time); function setBubbleNoticer(text, type, time) { if (type == "normal") { var bg = "#cfe2ff" ; var iconbg = "#084298" ; var icon = "\\f021"; } else if (type == "problem") { var bg = "#fff3cd"; var iconbg = "#664d03"; var icon = "\\f071"; } else if (type == "err") { var bg = "#f8d7da"; var iconbg = "#842029"; var icon = "\\f12a"; } else if (type == "ok") { var bg = "#d1e7dd"; var iconbg = "#0f5132"; var icon = "\\f00c"; } else { var bg = type; var iconbg = "#084298" ; var icon = "\\f021"; } var noticer = document.createElement("div"); var c = document.getElementsByClassName("bubbleNoticer").length; if (c == 0) { bubbleNum = 0; } else { bubbleNum = bubbleNum+1; } noticer.setAttribute("class", "bubbleNoticer " + type); noticer.style.backgroundColor = bg; noticer.style.top = 60 + bubbleNum * 40 + "px"; var node = document.createTextNode(text); noticer.appendChild(node); var page = document.getElementById("kratos-wrapper"); page.appendChild(noticer); document.styleSheets[0].insertRule('.' + type + '::before{color: '+ iconbg +';content: "'+ icon +'";}',0) setTimeout(() => { remove(); }, time); function remove() { noticer.style.top = "-40px"; setTimeout(() => { page.removeChild(noticer); }, 500); } return bubbleNum; } }
|