Mini Kabibi Habibi

Current Path : C:/Program Files/McAfee/WebAdvisor/MFW/packages/mwb/
Upload File :
Current File : C:/Program Files/McAfee/WebAdvisor/MFW/packages/mwb/wa-controller-mwb-checklist.js

/* MWB CheckList Controller */
(function (wa, $) {
    var ui = wa.UI = wa.UI || {},
        _settings = wa.Utils.Settings,
        _external = wa.Utils.External,
        _instrument = wa.Utils.Instrument,
        _tmpl = wa.UI.CheckList.templates,
        _core = wa.Core,
        _window = _core.Window,
        _lrt = wa.Utils.Lang.ResType,
        _l = wa.Utils.Lang(_lrt.WEBBOOST).get,
        _checkList = _core.CheckList;

    ui.CheckListController = function () {
        var self = this;
        var browser = _window.getBrowserType();
        var wbShown = "WBShown";
        var wbLastShown = "WBLastShownDate";
        var installDir = _external.getInstallDir();
        if (browser === "FF") {
            wbShown = wbShown + "_" + browser.toLowerCase();
            wbLastShown = wbLastShown + "_" + browser.toLowerCase();
        }
        this.update = function () {
            _window.ready(function () {
                var args = JSON.parse(_external.getArgument("template_args"));
                var isInitial = false;

                if (args.checklisttype === 'showChecklistInitial') {
                    isInitial = true;
                } else if (args.checklisttype === 'showChecklistLast') {
                    isInitial = false;
                } else {
                    return;
                }

                self.showWBChecklist(isInitial);
            });
        };

        this.installChromeWebBoost = function () {
            window.external.install_extension(2, "klekeajafkkpokaofllcadenjdckhinm", "");            
        };

        this.installFirefoxWebBoost = function (installPath) {
            window.external.install_extension(1, "{EF0645D5-78D6-4B33-BC45-95B1874977AF}", "e10swbffplg.xpi");            
        };

        this.showWBChecklist = function (isInitial) {
            var title = isInitial ? _l("TITLE_FIRST") : _l("TITLE_SECOND");
            var content = isInitial ? _l("CONTENT_FIRST") : _l("CONTENT_SECOND");
            content = content.format(_l("MCAFEE_WEB_BOOST"));
            var contentImage = "wacore:mfw\\packages\\mwb\\stop-video-alert-icon.png";

            // Create EULA message
            var linktag = "<a style=\"cursor: pointer; color: #00AEEF; text-decoration:none;\" href='{0}'>{1}</a>";
            var license = linktag.format(_l("LICENSE_URL"), _l("LICENSE"));
            var privacy = linktag.format(_l("PRIVACY_URL"), _l("PRIVACY"));
            var eula = _l("AGREEMENT_MSG").format("<b>" + _l("YES_GET_IT") + "</b>", license, privacy);

            var html = "";
            html += "<div style=\"background: #ffffff; border: 1px solid #B1BABF; height: auto; width: 430px; font-family: Open Sans;\">";
            html += "    <div style=\"overflow: auto; padding: 20px 20px 0px 20px\">";
            html += "        <div style=\"float:left; width: 97px;\">";
            html += "            <img src=\"" + contentImage + "\" style=\"width: 97px; height: 72px; \">";
            html += "        </div>";
            html += "        <div style=\"margin-left: 105px; width: 280px\">";
            html += "            <div style=\"color: #000000; font-size: 16px; text-align: left; margin-right: 15px; font-family: Open Sans; font-weight: 600\">";
            html += title;
            html += "            </div>";
            html += "            <div style=\"margin-top: 19px; color: #53565A; font-size: 14px; text-align: left;\">";
            html += content;
            html += "            </div>";
            html += "            <div style=\"margin-top: 19px; color: #53565A; font-size: 14px; text-align: left;\">";
            html += eula;
            html += "            </div>";
            html += "        </div>";
            html += "    </div>";
            html += "   <div style=\"overflow: auto; padding: 20px;\">";
            html += "       <input id='btn-cancel' type=\"button\" value=\"" + _l("NO_THANKS") + "\" style=\"cursor: pointer; float: right; border: none; min-width: 111px; height: 36px; border: 1px solid #939598; background: #ffffff; border-radius: 2px; color: #53565A;  font-size: 13px; margin-left: 20px; \" \/>";
            html += "       <input id='btn-submit' type=\"button\" value=\"" + _l("YES_GET_IT") + "\" style=\"cursor:pointer; float: right; border: none; min-width: 111px; height: 36px; border: 1px solid #00AEEF; background: #00AEEF; border-radius: 2px; color: #ffffff; font-size: 13px; \" \/>";
            html += "   </div>";
            html += "</div>";

            var key = "MWB",
                infoStateCss = "info",
                dialog = new ui.CheckListDialog({
                    content: function () {
                        return {
                            html: html
                        };
                    }(),
                    dialogWidth: "432px"
                }),

                checkList = new ui.WebAdvisorCheckList({
                    message: {
                        text: _l("BANNER_LEFT_TEXT").format(_l("MCAFEE_WEB_BOOST")),
                        css: infoStateCss
                    },
                    state: {
                        template: _tmpl.defaultState({
                            text: _l("BANNER_RIGHT_TEXT"),
                            image: "wacore:mfw\\packages\\mwb\\wb-rocket-icon.png",
                            imageCss: "wa-state-img"
                        }, key, "MWB"),
                        css: infoStateCss
                    }
                })
                .closeClick(function (args, sender) {
                    var currentTimeInSeconds = new Date().getTime() / 1000;
                    _settings.set(wbLastShown, (Math.floor(currentTimeInSeconds)).toString(), "0");
                    if (!isInitial) {
                        _settings.set(wbShown, true, "0");
                    }

                    //Telemetry 3.0
                    var webboostUpsellCloseEvent = {
                        _event_name: "wa_webboost_upsell_interaction",
                        hit_label_19: isInitial ? "Close" : "CloseSecond",
                        hit_label_20: _instrument.getBrowserTypeCode(),
                    }
                    _instrument.sendAnalyticsEvent(webboostUpsellCloseEvent);

                    dialog.close(sender.close);
                })
                .closeComplete(function () {
                    _window.close();
                })
                .open(function () {
                    $("#wa-dialog").width(432);
                    dialog.open();
                    $("#wa-dialog-header").attr("id", "");
                    $("#wa-dialog-content").attr("id", "");
                    $("#wa-dialog").find("#btn-submit").on({
                        click: function () {            
                            var currentTimeInSeconds = new Date().getTime() / 1000;
                            _settings.set(wbLastShown, (Math.floor(currentTimeInSeconds)).toString(), "0");
                            _settings.set(wbShown, true, "0");

                            //Telemetry 3.0
                            var webboostUpsellAcceptEvent = {
                                _event_name: "wa_webboost_upsell_interaction",
                                hit_label_19: isInitial ? "Accept" : "AcceptSecond",
                                hit_label_20: _instrument.getBrowserTypeCode(),
                            }
                            _instrument.sendAnalyticsEvent(webboostUpsellAcceptEvent);

                            browser === "FF" ? self.installFirefoxWebBoost(installDir) : self.installChromeWebBoost();
                            dialog.close(checkList.close);
                        }
                    });
                    $("#wa-dialog").find("#btn-cancel").on({
                        click: function () {
                            var currentTimeInSeconds = new Date().getTime() / 1000;
                            _settings.set(wbLastShown, (Math.floor(currentTimeInSeconds)).toString(), "0");
                            if (!isInitial) {
                                _settings.set(wbShown, true, "0");
                            }

                            //Telemetry 3.0
                            var webboostUpsellRejectEvent = {
                                _event_name: "wa_webboost_upsell_interaction",
                                hit_label_19: isInitial ? "Reject" : "RejectSecond",
                                hit_label_20: _instrument.getBrowserTypeCode(),
                            }
                            _instrument.sendAnalyticsEvent(webboostUpsellRejectEvent);

                            dialog.close(checkList.close);
                        }
                    });
                });

            //Telemetry 3.0
            var webboostUpsellImpressionEvent = {
                _event_name: "wa_webboost_upsell_impression",
                hit_label_19: isInitial ? "Impression" : "ImpressionSecond",
                hit_label_20: _instrument.getBrowserTypeCode(),
            }
            _instrument.sendAnalyticsEvent(webboostUpsellImpressionEvent);

            _external.setKey(key);
            _window.show();
        };
    };
}(window.WebAdvisor = window.WebAdvisor || {}, jQuery));

$(function () {
    var controller = new WebAdvisor.UI.CheckListController();
    controller.update();
});

//7CD9AC8CA620C528F98B21A1CC5D78A43713A0957A2B7203F80B2FD0083BE909310FB8281842CC5075875163D727E0EF2B570746B99427C92EDB687385005C5C++