(function(opts){ var head = document.getElementsByTagName('head')[0], query = {}, widgets = [], createLoader = loader(); if (location.search) { var items = location.search.substring(1).split('&'); for (var i = 0; i < items.length; i++) { var p = items[i].split('='); query[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); } if ('partner' in query) { var date = new Date(new Date().getTime() + (60 * 1000) * 60 * 24 * 365); document.cookie = "_rg_partner="+query['partner']+"; path=/; expires=" + date.toUTCString(); } } function load() { widgets = document.querySelectorAll('[data-rg-widget]'); for (var i = 0; i < widgets.length; i++) { renderWidget(widgets[i]); } } if (document.readyState == 'loading') { document.addEventListener("DOMContentLoaded", load); } else { // document.readyState is interactive or complete // can interact with page load(); } function evalSnippets(widget) { var nodes = widget.querySelectorAll('script:not([src])'); for (var i = 0; i < nodes.length; i++) { eval(nodes[i].innerHTML); } incStatus(widget); } function renderWidget(widget) { var name = widget.getAttribute('data-rg-widget'); if (name in opts.except) { incStatus(widget, 2); return; } var loader = createLoader(); widget.appendChild(loader); var content = document.createElement('div'); content.style.display = 'none'; widget.appendChild(content); var params = widget.getAttribute('data-params'); if (params) { params = JSON.parse(params); for (var k in params) { if (!(k in query)) { query[k] = params[k]; } } } query['r'] = '/' + name; var queryStr = Object.keys(query).map(function(k) { return k + '=' + encodeURIComponent(query[k]); }).join('&'); var request = new XMLHttpRequest(); request.open('GET', opts.sn + '?' + queryStr, true); request.setRequestHeader("X-Requested-With", "XMLHttpRequest"); request.onload = function() { if (request.status == 200) { content.innerHTML = this.responseText; processCss(widget, loader, content); processJs(widget); } }; request.send(); } function processCss(widget, loader, content) { var sheets = widget.querySelectorAll('link[href][rel=stylesheet],style'), ready = function() { loader.style.display = 'none'; content.style.display = 'block'; incStatus(widget); }; if (sheets.length) { var k = 0; for (var i = 0; i < sheets.length; i++) { sheets[i].onload = function() { if (sheets.length == ++k) { ready(); } } } } else { ready(); } } function processJs(widget) { var scripts = widget.querySelectorAll('script[src]'); var k = 0; if (scripts.length) { for (var i = 0; i < scripts.length; i++) { var script = document.createElement('script'); script.src = scripts[i].getAttribute('src'); script.async = false; script.onload = function() { if (scripts.length == ++k) { evalSnippets(widget); } }; head.appendChild(script); } } else { evalSnippets(widget); } } function incStatus(widget, step) { widget.status = widget.status || 0; widget.status += (step || 1); } function loader() { var css = 'div[data-rg-widget] {position:relative} ' + 'div[data-rg=loader]' + '{width: 40px; height: 40px; background-color: #333; border-radius: 100%; -webkit-animation: sk-scaleout 1.0s infinite ease-in-out; animation: sk-scaleout 1.0s infinite ease-in-out; } ' + '@-webkit-keyframes sk-scaleout { 0% { -webkit-transform: scale(0) } 100% { -webkit-transform: scale(1.0); opacity: 0; } } ' + '@keyframes sk-scaleout { 0% { -webkit-transform: scale(0); transform: scale(0); } 100% {-webkit-transform: scale(1.0);transform: scale(1.0);opacity: 0;}}' + 'div[data-rg-widget=form] div[data-rg=loader], ' + 'div[data-rg-widget=preview] div[data-rg=loader], ' + 'div[data-rg-widget=prices] div[data-rg=loader], ' + 'div[data-rg-widget=priceCalc] div[data-rg=loader], ' + 'div[data-rg-widget=referenceGenerator] div[data-rg=loader], ' + 'div[data-rg-widget=terms] div[data-rg=loader] ' + '{position: absolute; left: 50%; top: 120px; margin-left: -20px}'; var style = document.createElement('style'); style.appendChild(document.createTextNode(css)); head.appendChild(style); return function() { var element = document.createElement('div'); element.setAttribute('data-rg', 'loader'); return element; }; } var interval = setInterval(function() { for (var i = 0; i < widgets.length; i++) { if (widgets[i].status != 2) { return; } } clearInterval(interval); }, 100); if (document.cookie.indexOf("_rg_labels=") == -1) { var currentUrl = location.pathname + location.search; document.cookie = "_rg_labels=" + currentUrl + "; path=/"; } })({"sn":"/wp-content/special/rg-middleware-proxy.php","query":{"ver":"6.1.1"},"except":{"termsPopup":1}});