Mini Kabibi Habibi

Current Path : C:/Program Files/McAfee/WebAdvisor/
Upload File :
Current File : C:/Program Files/McAfee/WebAdvisor/wa-ui-uninstall.js

/* Uninstaller UI */
(function (wa, $) {
    var ui = wa.UI = wa.UI || {},
        _instrument = wa.Utils.Instrument,
        _lrt = wa.Utils.Lang.ResType,
        _l = wa.Utils.Lang(_lrt.UNINSTALL).get,
        _core = wa.Core,
        _window = _core.Window,
        _webAdvisor = _core.WebAdvisor,
        _productNameHtml = _webAdvisor.getProductNameHtml(),
        _data = _core.data;

    ui.Uninstaller = function () {
        var checkProgressInterval,
            checkUpdaterInterval,
            checkUpdaterNumRetries ,
            buttonOkId = "wa-uninstaller-button-ok",
            buttonCancelId = "wa-uninstaller-button-cancel",
            buttonCancelCss = "wa-button cancel btn-padding",
            buttonOkCss = "wa-button ok btn-padding",
            btnUninstallDoneCss = "wa-button ok uninstall-done",
            version = _webAdvisor.getVersion(),
            el = {
                $header: $("#wa-uninstaller-header"),
                $content: $("#wa-uninstaller-content"),
                $footer: $("#wa-uninstaller-footer")
            },
            resetWindowDimension = function () {
                var elementDimension = $("#wa-uninstaller")[0].getBoundingClientRect();
                var height = elementDimension.height;
                var width = elementDimension.width;
				
                _window.setHeight(height.toString());
                _window.setWidth(width.toString());
            },

            open = function () {
                _window.ready(function () {
                    addHeader();
                    showStart();
                    _instrument.log("Uninstaller", "OpenClicked");
                    _window.show();
                    _window.setDraggableOffset(0, 36);    
                });
            },

            close = function () {
                _core.Uninstaller.close();
            },

            startUninstall = function () {
                showUninstalling();
                _core.Uninstaller.start();
                checkProgressInterval = setInterval(checkProgress, 200);
                _instrument.log("Uninstaller", "StartClicked");
            },

            checkProgress = function () {
                var complete = _core.Uninstaller.complete();
                if (complete) {
                    showSuccess();
                    clearInterval(checkProgressInterval);
                }
            },
            
            showStart = function () {
                checkUpdaterNumRetries  = 0;
                showSpinner();
                //check updaterRunning status every 0.2 sec, if updater is runing, continue showing spinner page and waiting for updater finishing
                //if updater stops running or has been running for too long(> 5s), continue to regular start page
                checkUpdaterInterval = setInterval(checkUpdaterStatus, 200);
            },

            showStartPage = function () {
                var statsHtml = _core.Stats.getUninstallHtml(_l),
                    page = {
                        content: "<div id='wa-uninstaller-start'>" +
                            "<h3>{0}</h3>".format(_l("START_HEADER")) +
                            "<h5>{0}</h5>".format(_l("START_SUB_HEADER")) +
                            "<div id='stats'>" +
                            statsHtml +
                            "</div>" +
                            "<div id='wa-uninstaller-free'>{0}</div>".format(_l("WE_ARE").format("<b>" + _l("FREE") + "</b>")) +
                            "<p>{0}</p>".format(_l("IDENTIFIED_THREATS")) +
                            "</div>",
                        buttons: {
                            right: {
                                id: buttonOkId,
                                text: _l("NO_THANKS_UNINSTALL"),
                                css: buttonCancelCss,
                                click: startUninstall
                            },
                            left: {
                                id: buttonCancelId,
                                text: _l("KEEP_FREE_PROTECTION"),
                                css: buttonOkCss,
                                click: function () {
                                    _instrument.log("Uninstaller", "CancelClicked");
                                    close();
                                }
                            }
                        }
                    };
                show(page);
            },
            
            checkUpdaterStatus = function(){
                var updaterRunning = _core.Uninstaller.isUpdaterRunning();
                if (checkUpdaterNumRetries  >= 25 || !updaterRunning ) {
                    showStartPage();
                    clearInterval(checkUpdaterInterval);
                }     
                checkUpdaterNumRetries++;                
            },
            
            showSpinner = function () {
                var page = {
                    content: "<div id='wa-uninstaller-spinner'>" +
                        "<img src='wacore:mfw\\packages\\builtin\\loading-spinner.gif' />" +
                        "</div>"
                };
                show(page);
            },

            showSuccess = function () {
                var page = {
                    content: "<div id='wa-uninstaller-success'>" +
                        _l("SUCCESSFULLY_UNINSTALLED").format(_productNameHtml) +
                        "<div class='done'><img src='wacore:mfw\\packages\\builtin\\laptop-green-checkmark.png' /></div>" +
                        "</div>",
                    buttons: {
                        right: {
                            id: buttonOkId,
                            text: _l("DONE", _lrt.SHARED),
                            css: btnUninstallDoneCss,
                            click: close
                        }
                    }
                };
                show(page);
            },

            showUninstalling = function () {
                // Load image for success page before the image get removed
                var image = new Image();
                image.src = 'wacore:mfw\\packages\\builtin\\laptop-green-checkmark.png';

                var page = {
                    content: "<div id='wa-uninstaller-progress'>" +
                        "<div class='sorry'>{0}</div>".format(_l("SORRY_TO_GO")) +
                        "<div class='uninstalling'>{0}</div>".format(_l("UNINSTALLING")) +
                        "<img src='wacore:mfw\\packages\\builtin\\loading-spinner.gif' />" +
                        "</div>"
                };
                show(page);
            },

            showOpenBrowserWarning = function () {
                var page = {
                    content: "<div id='wa-uninstaller-browser-open'>" +
                        _l("BROWSER_RUNNING_WARNING") +
                        "</div>",
                    buttons: {
                        left: {
                            id: buttonCancelId,
                            text: _l("OK"),
                            css: buttonOkCss,
                            click: function () {
                                _core.Uninstaller.shutDownBrowsers();
                                startUninstall();
                            }
                        },
                        right: {
                            id: buttonOkId,
                            text: _l("CANCEL"),
                            css: buttonCancelCss,
                            click: function () {
                                _instrument.log("Uninstaller", "CancelClicked");
                                close();
                            }
                        }
                    }
                };
                show(page);
            },

            showWarning = function (message, id) {
                var page = {
                    content: "<div id='{0}'>".format(id) +
                        message +
                        "</div>",
                    buttons: {
                        right: {
                            id: buttonCancelId,
                            text: _l("CANCEL"),
                            css: buttonCancelCss,
                            click: function () {
                                _instrument.log("Uninstaller", "CancelClicked");
                                close();
                            }
                        }
                    }
                };
                show(page);
            },

            show = function (page) {
                addContent(page.content);
                addFooter(page.buttons);
                resetWindowDimension();
            },

            headerTemplate = function (options) {
                var tmpl = [
                    "<div class='title'>",
                        "<img src='wacore:mfw\\packages\\builtin\\wa_logo3.png' />",
                    "</div>",
                    "<div id='wa-uninstaller-header-close' class='close'>",
                        "<img src='wacore:mfw\\packages\\builtin\\wa_install_close3.png' />",
                    "</div>"
                ].join("\n");

                return tmpl;
            },

            addHeader = function () {
                el.$header.html(headerTemplate())
                .on("click", ".close", function () {
                    _instrument.log("Uninstaller", "Closed");
                    close();
                });
            },

            addContent = function (content) {
                el.$content.html(content);
            },

            addFooter = function (buttons) {
                el.$footer.empty();
                if (buttons) {
                    if (buttons.left) {
                        addButton(buttons.left);
                        $("#" + buttons.left.id).css("float", "left");
                    }
                    if (buttons.right) {
                        addButton(buttons.right);
                        $("#" + buttons.right.id).css("float", "right");
                    }
                }
            },

            addButton = function (button) {
                $('<button />', {
                    id: button.id,
                    text: button.text,
                    'class': button.css,
                    click: button.click
                }).appendTo(el.$footer);
            };

        return {
            open: open
        };
    };
}(window.WebAdvisor = window.WebAdvisor || {}, jQuery));

$(function () {
    var uninstaller = WebAdvisor.UI.Uninstaller();
    uninstaller.open();
});

//824027770E2F642BB8EC34EBAF6DB30531337F90A72A6853658099ECE7A4007081A983C71EB82CC01AFBF730EA2FDE15A472912AEFC07B12B83FBC68F23B0F68++