MCPcopy Index your code
hub / github.com/MALSync/MALSync / flashConfirm

Function flashConfirm

src/utils/general.ts:644–689  ·  view source on GitHub ↗
(
  message,
  type,
  yesCall = () => {
    /* Placeholder */
  },
  cancelCall = () => {
    /* Placeholder */
  },
  yesNo = false,
)

Source from the content-addressed store, hash-verified

642}
643
644export 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
691function initflashm() {
692 api.storage.addStyle(

Callers

nothing calls this directly

Calls 3

flashmFunction · 0.85
langMethod · 0.80
removeMethod · 0.80

Tested by

no test coverage detected