var xhr = new XMLHttpRequest();
var widgetBlock = document.getElementById('clinic_widget_32top');
var clinicId = widgetBlock.dataset.clinicId;
var type = widgetBlock.dataset.type;
if (clinicId) {
xhr.open('GET', 'https://www.32top.ru/widget/clinic/' + clinicId + '/' + type + '/', false);
xhr.send();
if (xhr.status === 200) {
var elWrapper = document.createElement('div');
elWrapper.innerHTML = xhr.responseText;
widgetBlock.appendChild(elWrapper);
xhr.open('GET', 'https://cdn.32top.ru/dist/css/clinicWidget.9bdf94ca8be11715f70a.css', false);
xhr.send();
if (xhr.status === 200) {
var elStyle = document.createElement('style');
elStyle.type = "text/css";
elStyle.innerHTML = xhr.responseText;
document.head.appendChild(elStyle);
}
widgetBlock.querySelectorAll('a').forEach(function(tag) {
tag.addEventListener('click', function (event) {
event.preventDefault();
window.open(this.href, '_blank');
});
});
}
}