(text = "")
| 664 | } |
| 665 | |
| 666 | export function showLoading(text = "") { |
| 667 | let html = /*html*/ ` |
| 668 | <div class="loading-container"> |
| 669 | <div> |
| 670 | <div class="loader"></div><br/> |
| 671 | <p class="text">${text}</p> |
| 672 | </div> |
| 673 | </div> |
| 674 | `; |
| 675 | let div = document.createElement("div"); |
| 676 | div.innerHTML = html; |
| 677 | document.body.appendChild(div); |
| 678 | |
| 679 | return { |
| 680 | closeLoading: () => div?.remove?.(), |
| 681 | setLoadingText: (textOrFunction) => { |
| 682 | let textP = document.querySelector(".loading-container .text"); |
| 683 | if (!textP) return; |
| 684 | if (typeof textOrFunction === "function") { |
| 685 | textP.innerHTML = textOrFunction(textP.innerHTML); |
| 686 | } else { |
| 687 | textP.innerHTML = textOrFunction; |
| 688 | } |
| 689 | }, |
| 690 | }; |
| 691 | } |
| 692 | |
| 693 | export function openPopupWithHtml(html, width = 300, height = 300) { |
| 694 | let win = window.open( |
no test coverage detected