JSFiddle - React, Tailwind, and code Playground

by Kishore Sahasranaman

JavaScript

function MessageBox(title, text, type, severity) {
            var buttonType = [];
            var dialogIcon = "";
            switch (type) {
            case "ABORT":
                buttonType = [{
                    text: "Abort",
                    click: function () {
                        $(this).dialog("close");
                        return "abort";
                    }
                }, {
                    text: "Retry",
                    click: function () {
                        $(this).dialog("close");
                        return "retry";
                    }
                }, {
                    text: "Cancel",
                    click: function () {
                        $(this).dialog("close");
                        return "cancel";
                    }
                }];
                break;
            case "OK":
                buttonType = [{
                    text: "OK",
                    click: function () { $(this).dialog("close"); }
                }];
                break;
            case "OKCANCEL":
                buttonType = [{
                    text: "OK",
                    click: function () {
                        $(this).dialog("close");
                        return true;
                    }
                }, {
                    text: "CANCEL",
                    click: function () { $(this).dialog("close");
                        return false; }
                }];
                break;
            case "YESNO":
                buttonType = [{
                    text: "YES",
                    click: function () {
                        $(this).dialog("close");
                        return true;
                    }
                }, {
                    text: "NO",
                    click: function () {
                        $(this).dialog("close");
                        return false;
                    }
                }];
                break;
           ...