| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <div class="banner">
- <ul></ul>
- </div>
- <script>
- let banner = {
- errorList: [],
- notificationList: [],
- createNotification: function(value){
- this.notificationList.push(value);
- this.updateNotifications();
- setTimeout(()=>{
- this.notificationList.splice(0, 1);
- this.updateNotifications();
- }, 10000);
- },
- createError: function(value){
- this.errorList.push(value);
- this.updateNotifications();
- setTimeout(()=>{
- this.errorList.splice(0, 1);
- this.updateNotifications();
- }, 10000);
- },
- updateNotifications: function(){
- let ul = document.querySelector(".banner ul");
- while(ul.hasChildNodes()){
- ul.removeChild(ul.firstChild);
- }
- for(let notification of this.notificationList){
- let li = document.createElement("li");
-
- li.classList = "notification";
- li.innerText = notification;
- ul.appendChild(li);
- }
- for(let error of this.errorList){
- let li = document.createElement("li");
- li.classList = "error";
- li.innerText = error;
- ul.appendChild(li);
- }
- }
- }
- </script>
|