(text, time = 2000, opacity = 0.8, id)
| 638 | } |
| 639 | |
| 640 | notice(text, time = 2000, opacity = 0.8, id) { |
| 641 | let oldNoticeEle; |
| 642 | if (id) { |
| 643 | oldNoticeEle = document.getElementById(`dplayer-notice-${id}`); |
| 644 | if (oldNoticeEle) { |
| 645 | oldNoticeEle.innerHTML = text; |
| 646 | } |
| 647 | if (this.noticeList[id]) { |
| 648 | clearTimeout(this.noticeList[id]); |
| 649 | this.noticeList[id] = null; |
| 650 | } |
| 651 | } |
| 652 | if (!oldNoticeEle) { |
| 653 | const notice = Template.NewNotice(text, opacity, id); |
| 654 | this.template.noticeList.appendChild(notice); |
| 655 | oldNoticeEle = notice; |
| 656 | } |
| 657 | |
| 658 | this.events.trigger('notice_show', oldNoticeEle); |
| 659 | |
| 660 | if (time > 0) { |
| 661 | this.noticeList[id] = setTimeout( |
| 662 | (function (e, dp) { |
| 663 | return () => { |
| 664 | e.addEventListener('animationend', () => { |
| 665 | dp.template.noticeList.removeChild(e); |
| 666 | }); |
| 667 | e.classList.add('remove-notice'); |
| 668 | dp.events.trigger('notice_hide'); |
| 669 | dp.noticeList[id] = null; |
| 670 | }; |
| 671 | })(oldNoticeEle, this), |
| 672 | time |
| 673 | ); |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | resize() { |
| 678 | if (this.danmaku) { |
no test coverage detected