(function(window,document,undefined) { var helper = { loadJS: function(url, callbackFunction) { var scriptTag = document.createElement('script'); scriptTag.src = url; if(callbackFunction) { scriptTag.onload = callbackFunction; scriptTag.onreadystatechange = callbackFunction; } var headTag = document.getElementsByTagName('head')[0]; headTag.appendChild(scriptTag); } }; /* Główny obiekt */ var silnetLoader = function() { this.Vue = null; this.VueComponents = {}; this.VueMountPoint = null; this.baseUrl = '//global.silnet.pl'; this.customerId = 'jvb2PF2p17TQ'; this.customerModules = {"cookies":true,"show_numbers":true,"push_notifications":true,"privacy_policy":{"popup":true,"widget_type":"Zostaw kt\u00f3r\u0105\u015b z warto\u015bci bar|popup|both lub zostaw puste","template":"privacy-policy-default-pl","title":"Polityka prywatno\u015bci","customer":{"name":"Silnet Media Sp. z o.o. sp. k.","www":"onepage.demo.silnet.pl","url":"https:\/\/onepage.demo.silnet.pl","email_main":"info@silnet.pl","email_iodo":"info@silnet.pl","nip":"6412546510","regon":"382875283","address":{"city":"Ruda \u015al\u0105ska","street":"Pocztowa 5"}},"forms":{"contact":true,"register_user":true,"shop":true,"newsletter":false,"rating":false,"job_advertisement":false},"used_services":{"tawkto":true,"callpage":true,"google_signals":false},"javascript":{"document_selector":"privacy_policy"}}}; } silnetLoader.prototype = { execute: function() { this.initVueLibrary(); this.loadCMP(); this.loadPrivacyPolicy(); this.mountVueComponents(); }, /** * Obsługa biblioteki vue.js - rejestrowanie komponnetów typu single files **/ registerVueComponent: function(componentName,mount,mountParameters) { componentName = componentName.replace(/^(.*\/?)?([^\/]+)(\.vue.*)$/i, '$2'); this.VueComponents[componentName] = httpVueLoader(this.baseUrl+'/media/js/vue/'+componentName+'.vue'); Vue.component(componentName,this.VueComponents[componentName]); if(mount===true) { var newComponent = document.createElement(componentName); if(mountParameters && Array.isArray(Object.keys(mountParameters))) { for(var k in mountParameters) { newComponent.setAttribute(k, mountParameters[k]); } } this.VueMountPoint.appendChild(newComponent); //this.VueMountPoint.innerHTML += newComponent.outerHTML; } }, /** * Obsługa biblioteki vue.js - przygotowanie środowiska i kontenera na komponenty (nie może być to 'BODY') **/ initVueLibrary: function () { this.Vue = null; this.VueMountPoint = document.createElement('div'); this.VueMountPoint.id = 'sil-global-vue-'+(new Date()).getTime(); var bodyTag = document.getElementsByTagName('body')[0]; //this.VueMountPoint.setAttribute('show-intro', this.customerModules.privacy_policy.show_intro||false); bodyTag.appendChild(this.VueMountPoint); //this.registerVueComponent('silnet-test', true); }, /** * Obsługa biblioteki vue.js - montowanie tagów vue **/ mountVueComponents: function () { this.Vue = new Vue({ el: '#'+this.VueMountPoint.id //, //components: this.VueComponents }); }, loadPrivacyPolicy: function() { if(this.customerModules.privacy_policy.javascript.document_selector) { this.registerVueComponent('silnet-privacy-policy-popup',false); this.registerVueComponent('silnet-privacy-policy', true, { 'container-selector': this.customerModules.privacy_policy.javascript.document_selector, 'content-url': this.baseUrl+'/js/customer/'+this.customerId+'/privacy-policy', 'cmp': (this.customerModules.cookies && this.customerModules.cookies.cmp) ? this.customerModules.cookies.cmp : null, 'cmp-id': (this.customerModules.cookies && this.customerModules.cookies.id) ? this.customerModules.cookies.id : null, 'show-popup':this.customerModules.privacy_policy.popup, 'widget-type':this.customerModules.privacy_policy.widget_type||'popup' }); if(this.customerModules.cookies && Object.keys(this.customerModules.cookies).length && this.customerModules.cookies.cmp == 'cookie-script') { var privacyPolicyNode = document.querySelectorAll(this.customerModules.privacy_policy.javascript.document_selector)[0]; if(privacyPolicyNode) { privacyPolicyNode.insertAdjacentHTML('afterend', ''); privacyPolicyNode.insertAdjacentHTML('afterend', '
'); // var script = document.createElement('script'); // script.type = 'text/javascript'; // script.charset = 'UTF-8'; // script.dataset.cookiescriptreport = 'report'; // script.src = 'https://report.cookie-script.com/r/'+this.customerModules.cookies.id+'.js'; // privacyPolicyNode.parentNode.appendChild(script); } } } }, loadCMP: function() { if(this.customerModules.cookies && Object.keys(this.customerModules.cookies).length && this.customerModules.cookies.cmp == 'cookie-script') { var id = this.customerModules.cookies.id; helper.loadJS('https://cdn.cookie-script.com/s/'+id+'.js'); } } } /** * Funkcja główna osadzająca skonfigurowane dokumenty **/ function main() { var loader = new silnetLoader(); loader.execute(); } /** * Osadzane komponenty są oparte o vue.js, więc trzeba załadować odpowiednie biblioteki (Vue+vue-http-loader+axios do obsługi ajax) * Pomoc: https://www.npmjs.com/package/http-vue-loader **/ //Fixes // var tmpUrl = (!window.Promise) ? 'https://cdn.jsdelivr.net/combine/npm/es6-promise@4/dist/es6-promise.min.js,npm/es6-promise@4/dist/es6-promise.auto.min.js,npm/axios@0.18.0/dist/axios.min.js,npm/vue@2.5.17/dist/vue.min.js,npm/http-vue-loader@1.3.5/src/httpVueLoader.min.js' : 'https://cdn.jsdelivr.net/combine/npm/axios@0.18.0/dist/axios.min.js,npm/vue@2.5.17/dist/vue.min.js,npm/http-vue-loader@1.3.5/src/httpVueLoader.min.js'; var tmpUrl = (!window.Promise) ? 'https://global.silnet.pl/media/js/vue-with-polyfill.js' : 'https://global.silnet.pl/media/js/vue.js'; helper.loadJS(tmpUrl,function(){ Vue.config.devtools = false; /*setTimeout(main,2000);*/ main(); }); /*** var $ = window.jQuery; $(document).ready(function($){ var customerId = 'jvb2PF2p17TQ'; console.log('popup!!!!'); ; if($('privacy_policy').length) { $('privacy_policy').load('//global.silnet.pl/js/customer/jvb2PF2p17TQ/privacy-policy'); } }); ***/ })(window, window.document);