| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <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>
|