Mini Kabibi Habibi
/* SecureSearch Toast UI */
(function (wa, $) {
var ui = (wa.UI = wa.UI || {}),
_instrument = wa.Utils.Instrument,
_settings = wa.Utils.Settings,
_window = wa.Core.Window,
_external = wa.Utils.External;
var TOGGLE_COUNT = "toggle_count";
ui.SecureSearchToast = function () {
var $el = {
cardImage: $(".card__image"),
cardContent: $(".card__content"),
contentInfoTitle: $("#info-title"),
contentInfoText: $("#info-text"),
checkboxQuestion: $("#checkbox-question"),
checkboxInput: $("#set-secure-search-checkbox"),
checkboxChecked: $("#checkbox-checked"),
checkboxUnchecked: $("#checkbox-unchecked"),
setSecureSearchLabel: $("#set-secure-search-label"),
doneButton: $("#done"),
},
isCheckboxChecked = function () {
var isChecked = false;
if ($el.checkboxChecked.css('display') === 'block'
&& $el.checkboxUnchecked.css('display') === 'none') {
isChecked = true;
}
return isChecked;
},
initComponents = function () {
$el.checkboxInput.click(function () {
_settings.increment_setting(TOGGLE_COUNT, "0");
// switch the checkbox
if (isCheckboxChecked()) {
$el.checkboxChecked.attr("class", "invisible");
$el.checkboxUnchecked.attr("class", "visible");
}
else {
$el.checkboxChecked.attr("class", "visible");
$el.checkboxUnchecked.attr("class", "invisible");
}
});
},
fillText = function (lang, variantType) {
$el.contentInfoTitle.html(lang("TOAST_VARIANT_TITLE_FINISH_SETUP"));
$el.contentInfoText.html(lang("TOAST_VARIANT_2_INFO"));
$el.checkboxQuestion.html(lang("TOAST_VARIANT_QUESTION"));
$el.doneButton.html(lang("TOAST_VARIANT_BUTTON"));
if (variantType === 4) {
$el.setSecureSearchLabel.html(lang("TOAST_VARIANT_CHECKLIST"));
}
else if (variantType === 5) {
// Making checkbox label about option compliant with Yahoo search engine
var ssToastLang = wa.Utils.Lang(wa.Utils.Lang.ResType.SSTOAST).get;
var payload = JSON.parse(_external.getArgument("toast_data"));
var label = null;
var search_name_id = _settings.get("SECURE_SEARCH_PROVIDER_NAME_ID", "0");
var search_engine_name = ssToastLang(search_name_id);
if ("string" != typeof search_engine_name || 0 == search_engine_name.length) {
search_engine_name = ssToastLang("SEARCH_TOAST_ENGINE");
}
label = ssToastLang("SEARCH_TOAST_OPTION_COMPLIANT").format(
search_engine_name
);
var chromeCompliantDisabled = _settings.get(
"chrome_search_compliance_disabled"
);
var extension_push = false;
if (payload.extension_push != undefined) {
extension_push = payload.extension_push;
}
var browserCode = _instrument.getBrowserTypeCode();
var search_state_ed = _settings.get("search_state_ed");
if (browserCode == "CH" && (chromeCompliantDisabled || extension_push) || (browserCode == 'ED' && 2 == search_state_ed)) {
label = ssToastLang("SEARCH_TOAST_OPTION");
}
$el.setSecureSearchLabel.html(label);
$el.setSecureSearchLabel.css("margin-left", "15px");
}
},
init = function (lang, variantType, toastType) {
initComponents();
fillText(lang, variantType);
_window.setWidth("555");
_window.setHeight("340");
$el.doneButton.click(function () {
var isChecked = isCheckboxChecked();
var tc = _settings.getSettingScopedWithDefault(-1, "0", TOGGLE_COUNT);
var tc_str = tc.toString();
if (isChecked) {
// Send telemetry for Secure Search Acceptance
_instrument.sendSecureSearchToastEvent("Accepted", _instrument.getBrowserTypeCode(), _instrument.getSecureSearchProvider(), toastType, "default", tc_str);
wa.Core.SecureSearch.enable();
}
else {
// Send telemetry for Secure Search Decline
_instrument.sendSecureSearchToastEvent("Declined", _instrument.getBrowserTypeCode(), _instrument.getSecureSearchProvider(), toastType, "default", tc_str);
wa.Core.SecureSearch.disable();
}
_window.close();
});
},
show = function () {
_window.ready(function () {
var payload = JSON.parse(_external.getArgument("toast_data"));
var variantType = payload["secure_search_toast_variation"];
Number.isNaN =
Number.isNaN ||
function isNaN(input) {
return typeof input === "number" && input !== input;
};
// Validate variantType is valid
if (Number.isNaN(variantType) || variantType < 4 || variantType > 5) {
variantType = 4;
}
var lang = wa.Utils.Lang(wa.Utils.Lang.ResType.SS_TOAST_VARIANTS).get;
_settings.increment_setting("toast_variation_phase_2_show_count", "0");
var toastType = "green_search_extension_toast";
if (variantType === 5) {
toastType = "green_search_extension_default_toast";
}
init(lang, variantType, toastType);
_window.show();
// Send telemetry for Impression
_instrument.sendSecureSearchToastEvent("Impression", _instrument.getBrowserTypeCode(), _instrument.getSecureSearchProvider(), toastType);
});
};
return {
show: show,
};
};
})((window.WebAdvisor = window.WebAdvisor || {}), jQuery);
$(function () {
var toast = new WebAdvisor.UI.SecureSearchToast();
toast.show();
});
//1550EE3CEAEDEBEB5B268A3312B13162EDD0F14DC6E6C8350C92C6D8E6AE593A5B429CD2203579EABB2654F74D80EAA8B0B2974E33F1E2D8CE5D572B044B7735++