(function (document) { var queueVarName = '_mnisubq'; function createXHR() { if (window.XMLHttpRequest) try { return new XMLHttpRequest(); } catch (e) { } if (window.ActiveXObject) { try { return new ActiveXObject("MSXML2.XMLHTTP"); } catch (e) { } try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } function getScriptTagData() { var scripts = document.getElementsByTagName('script'); for (var i = 0; i < scripts.length; i++) { var script = scripts[i], match = script.src.match(/^((https?:)?\/\/([^/]+))\/.+\/publicwidgets\/subscriptions\.(min\.)?js/i); if (match) { return { protocol: match[2] || window.location.protocol, origin: match[1] || window.location.origin, domain: match[3] || window.location.host }; } } return { protocol: window.location.protocol, origin: window.location.origin, domain: window.location.host }; } function getUrl() { var l = getScriptTagData(); return 'https://' + l.domain + '/ap/Subscription'; } function getWidgetDetailsUrl() { return `//${getScriptTagData().domain}/api/widget/subscriptions`; } function post(url, data, callback) { let xhr = createXHR(); xhr.open('POST', url, true); xhr.withCredentials = true; //xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.setRequestHeader('Accept', 'application/json, text/javascript, */*'); xhr.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) callback(JSON.parse(this.responseText)); }; xhr.send(data); } function get(url) { let xhr = createXHR(); xhr.open('GET', url, false); xhr.send(); if (xhr.readyState == 4 && xhr.status == 200) { return JSON.parse(xhr.responseText); } } function getGroupDetails(groups) { let groupStr = groups.join(','); var response = get(getWidgetDetailsUrl() + "?groups=" + groupStr); return response["GroupNames"]; } function isListSelectionEnabled(params) { return params["allowListSelection"] && params["groups"].length > 1 } var widgets = window[queueVarName].reduce(function (o,k) { var params = k[0].split('.'); var id = params[0]; var arg = params[1]; if(!o[id]) o[id] = {}; if (!o[id].loaded) o[id][arg] = k[1]; return o; }, {}); Object.keys(widgets).forEach(function (k) { Init(k, widgets[k]); }); function render(params) { let listSelectionHtml = ''; if (isListSelectionEnabled(params)) { let groups = getGroupDetails(params["groups"]); listSelectionHtml += '