| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <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 banner = document.querySelector(".banner");
- 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>
|