Mini Kabibi Habibi
/* Protection Score Toast UI */
(function (wa, $) {
var ui = wa.UI = wa.UI || {},
_window = wa.Core.Window,
_instrument = wa.Utils.Instrument,
_settings = wa.Utils.Settings,
_external = wa.Utils.External;
ui.pscore_toast = function () {
var $el = {
description1: $("#description-1"),
description2: $("#description-2"),
acceptBtn: $("#accept-button"),
ignoreBtn: $("#ignore-button")
},
show = function () {
_window.ready(function () {
// Get protection score cohort value then set size toast window size based on that
var protection_score_cohort = _settings.getSettingScopedWithDefault(1, "1", "protection_score_cohort");
setSize({ width: "364", height: "500" });
if (protection_score_cohort === 2){
setSize({ width: "539", height: "203" })
}
// Get settings data
var lang = wa.Utils.Lang(wa.Utils.Lang.ResType.PSCORE_TOAST).get;
// Initialize toast.
init(lang);
_window.show();
});
},
init = function (lang) {
var description1 = lang("PSCORE_TOAST_DESC_HEADER");
var description2 = lang("PSCORE_TOAST_DESC_BODY");
var acceptBtn = lang("PSCORE_BUTTON_ACCEPT");
var ignoreBtn = lang("PSCORE_BUTTON_DECLINE");
$el.description1.html(description1);
$el.description2.html(description2);
$el.acceptBtn.html(acceptBtn);
$el.ignoreBtn.html(ignoreBtn);
// Get toasts shown count
var protection_score_show_count = _settings.getSettingScopedWithDefault(0, "0", "protection_score_show_count");
//send telemetry for impression
sendTelemetry("Impression", protection_score_show_count)
$el.acceptBtn
.click(function () {
var url = _settings.getSettingScopedWithDefault("https://www.mcafee.com", "1", "protection_score_url");
var max_show_count = _settings.getSettingScopedWithDefault(3, "1", "protection_score_show_count_max");
window.external.SetSetting("0", "protection_score_show_count", max_show_count + 1); //this is to prevent subsequent showing
_external.browserNavigate("CH", url);
_window.close();
//send telemetry for accepted
sendTelemetry("Accepted", protection_score_show_count)
});
$el.ignoreBtn
.click(function () {
_window.close();
//send telemetry for declined
sendTelemetry("Declined", protection_score_show_count)
});
},
//Telemetry function
sendTelemetry = function (eventAction, toastCount){
var settingTelemetryEvent = new ProtectionScore()
.event_action(eventAction)
.browser(_instrument.getBrowserTypeCode().toLowerCase())
.toasts_count(toastCount)
.Serialize();
_instrument.sendTelemetryEvent(settingTelemetryEvent);
}
setSize = function (obj) {
_window.setWidth(obj.width);
_window.setHeight(obj.height);
};
return {
show: show
}
};
}(window.WebAdvisor = window.WebAdvisor || {}, jQuery));
$(function () {
var toast = new WebAdvisor.UI.pscore_toast();
toast.show();
});
//EE1EFE4D6BCE7DCE8BE2A8E10CEF7E52AF492DA3EA282514DD295FA7C4BD2481E9D0FE4D0570E7BA8748DFF9C8E698F610AF1CF8CEB7F2970F766A65CFD10B37++