Mini Kabibi Habibi
/* Accept Extension UI */
(function (wa, $) {
var ui = (wa.UI = wa.UI || {});
var _window = wa.Core.Window;
var _external = wa.Utils.External;
var _settings = wa.Utils.Settings;
var _instrument = wa.Utils.Instrument;
var browserCode = _instrument.getBrowserTypeCode();
ui.accept_extension = function () {
var $el = {
balloonCard: $("#balloon__card"),
headerText: $("#content__text-header"),
contentText: $("#content__text-description"),
acceptBtn: $("#content__actions-accept"),
declineBtn: $("#content__actions-decline"),
};
show = function () {
_window.ready(function () {
var payload = JSON.parse(_external.getArgument("overlay_data"));
init(payload);
_window.show();
});
},
init = function (payload) {
var lang = wa.Utils.Lang(wa.Utils.Lang.ResType.NEW_TAB_TOAST).get;
var toastCount = Number(payload["toast_count"]);
// Polyfill of isNaN for IE version < 12;
Number.isNaN = Number.isNaN || function isNaN(input) {
return typeof input === "number" && input !== input;
};
// Validate toastCount is valid;
if (Number.isNaN(toastCount)) {
_window.close();
return;
}
// Set window size
_window.setHeight("255");
_window.setWidth("505");
// Add overlay localized content
var headerLocale = "";
var contentLocale = "";
var acceptLocale = "";
var declineLocale = "";
if (toastCount === 0) {
headerLocale = lang("NEW_TAB_EXTENSION_HEADER_VARIANT_1");
contentLocale = lang("NEW_TAB_EXTENSION_TOAST_CONTENT_VARIANT_1");
acceptLocale = lang("NEW_TAB_EXTENSION_TOAST_ACCEPT");
declineLocale = lang("NEW_TAB_EXTENSION_TOAST_REMIND_LATER");
} else if (toastCount === 1) {
headerLocale = lang("NEW_TAB_EXTENSION_HEADER_VARIANT_2");
contentLocale = lang("NEW_TAB_EXTENSION_TOAST_CONTENT_VARIANT_2");
acceptLocale = lang("NEW_TAB_EXTENSION_TOAST_ACCEPT");
declineLocale = lang("NEW_TAB_EXTENSION_TOAST_DECLINE");
}
$el.contentText.html(contentLocale);
$el.headerText.html(headerLocale);
$el.acceptBtn.html(acceptLocale);
$el.declineBtn.html(declineLocale);
updateSettings(toastCount);
$el.acceptBtn.click(function () {
window.external.install_extension(2, "kanjcmmieblbpbihaafnedamppkhfadn", "");
_settings.set("new_tab_experience_complete", true, "1");
_window.close();
});
$el.declineBtn.click(function () {
updateSettings(toastCount);
_window.close();
});
},
updateSettings = function (toastCount) {
var currentTimeInSeconds = Math.round(new Date().getTime() / 1000);
_settings.set("new_tab_experience_last_shown", currentTimeInSeconds.toString(), "1");
_settings.set("new_tab_experience_toast_count", ++toastCount, "1");
if (toastCount > 1) {
_settings.set("new_tab_experience_complete", true, "1");
}
},
return {
show: show,
};
};
})((window.WebAdvisor = window.WebAdvisor || {}), jQuery);
$(function () {
var balloon = new WebAdvisor.UI.accept_extension();
balloon.show();
});
//389068BE787747C6D86882719F23ADAC92858165B76B80B9EB95D0421D028FF6C0B84F0FEA5EECCDA16870B1DD50865F97658B96F473BE581E9D31436B7474BF++