| 642 | } |
| 643 | |
| 644 | export async function flashConfirm( |
| 645 | message, |
| 646 | type, |
| 647 | yesCall = () => { |
| 648 | /* Placeholder */ |
| 649 | }, |
| 650 | cancelCall = () => { |
| 651 | /* Placeholder */ |
| 652 | }, |
| 653 | yesNo = false, |
| 654 | ): Promise<boolean> { |
| 655 | return new Promise(function (resolve, reject) { |
| 656 | let yesText = api.storage.lang('Ok'); |
| 657 | let noText = api.storage.lang('Cancel'); |
| 658 | if (yesNo) { |
| 659 | yesText = api.storage.lang('Yes'); |
| 660 | noText = api.storage.lang('No'); |
| 661 | } |
| 662 | message = `<div style="text-align: center;">${message}</div><div style="display: flex; justify-content: space-around;"><button class="Yes" style="background-color: transparent; border: none; color: rgb(255,64,129);margin-top: 10px; cursor:pointer;">${yesText}</button><button class="Cancel" style="background-color: transparent; border: none; color: rgb(255,64,129);margin-top: 10px; cursor:pointer;">${noText}</button></div>`; |
| 663 | const flasmessage = flashm(message, { |
| 664 | permanent: true, |
| 665 | position: 'top', |
| 666 | type, |
| 667 | }); |
| 668 | flasmessage.find('.Yes').click(function (evt) { |
| 669 | resolve(true); |
| 670 | j.$(evt.target) |
| 671 | .parentsUntil('.flash') |
| 672 | .fadeOut(300, function () { |
| 673 | // @ts-ignore |
| 674 | j.$(this).remove(); |
| 675 | }); |
| 676 | yesCall(); |
| 677 | }); |
| 678 | flasmessage.find('.Cancel').click(function (evt) { |
| 679 | resolve(false); |
| 680 | j.$(evt.target) |
| 681 | .parentsUntil('.flash') |
| 682 | .fadeOut(300, function () { |
| 683 | // @ts-ignore |
| 684 | j.$(this).remove(); |
| 685 | }); |
| 686 | cancelCall(); |
| 687 | }); |
| 688 | }); |
| 689 | } |
| 690 | |
| 691 | function initflashm() { |
| 692 | api.storage.addStyle( |