1BX.namespace("BX.MIBOK"); 2 3if (typeof(BX.MIBOK.USERCONSENT) === "undefined") { 4 BX.MIBOK.USERCONSENT = function() { 5 this._settings = {}; 6 } 7 8 BX.MIBOK.USERCONSENT.prototype = { 9 initialize: function(config) { 10 this._settings = config ? config : {}; 11 12 const btnId = BX(this.getSetting('btnId', false)); 13 if (!!btnId) { 14 BX.bind( 15 btnId, 16 "click", 17 BX.delegate(this.handleClickButton, this) 18 ); 19 }; 20 }, 21 22 getSetting: function(name, defaultval) { 23 return typeof(this._settings[name]) != 'undefined' && !!this._settings[name] ? this._settings[name] : defaultval; 24 }, 25 26 setSetting: function(name, value) { 27 this._settings[name] = value; 28 }, 29 30 setCookie: function(name, value, options) { 31 options = options || {}; 32 33 let expires = options.expires; 34 35 if (!!expires) { 36 if (typeof expires == "number") { 37 let d = new Date(); 38 d.setTime(d.getTime() + expires * 1000); 39 expires = options.expires = d; 40 } 41 if (expires.toUTCString) { 42 options.expires = expires.toUTCString(); 43 } 44 } 45 46 value = encodeURIComponent(value); 47 48 let updatedCookie = name + "=" + value; 49 50 for (const propName in options) { 51 updatedCookie += "; " + propName; 52 let propValue = options[propName]; 53 if (propValue !== true) { 54 updatedCookie += "=" + propValue; 55 } 56 } 57 58 document.cookie = updatedCookie; 59 }, 60 61 handleClickButton: function(e) { 62 e.preventDefault(); 63 64 const elBtn = e.currentTarget, 65 nameComponent = this.getSetting('component', false), 66 nameAction = this.getSetting('action', false); 67 68 elBtn.setAttribute('disabled', 'disabled'); 69 70 /** Error, required settings are not set */ 71 if (!nameComponent || !nameAction) { 72 if (!!BX.debugEnableFlag) { 73 console.error('Error! Required settings are not set'); 74 console.log(nameComponent, nameAction); 75 } 76 return false; 77 } 78 79 let thisObject = this, 80 sendData = { 81 'id': this.getSetting('id', 0), 82 'sec': this.getSetting('sec', ''), 83 'url': window.location.href, 84 'action': this.getSetting('action', ''), 85 'sessid': BX.bitrix_sessid(), 86 }; 87 88 BX.ajax({ 89 url: this.getSetting('actionUrl', ''), 90 method: 'POST', 91 data: sendData, 92 timeout: 10, 93 dataType: 'json', 94 processData: true, 95 onsuccess: BX.proxy(function(response){ 96 response = response || {}; 97 98 if (!response.error) { 99 thisObject.setCookie('MIBOK_COOKIE_PRIVACY', 'Y', {expires:(3600 * 24 * 365), path : '/'}); 100 101 if (thisObject.getSetting('containerId', '') != '') { 102 const elContainer = BX(thisObject.getSetting('containerId', '')); 103 104 if (!!elContainer) { 105 elContainer.classList.add('no'); 106 } 107 } 108 } else { 109 if (!!BX.debugEnableFlag) { 110 console.error('Error add consent'); 111 console.log(response); 112 } 113 } 114 }, this), 115 onfailure: BX.proxy(function(){ 116 let response = {'error': true, 'text': ''}; 117 118 if (!!BX.debugEnableFlag) { 119 console.error('Error add consent'); 120 console.log(response); 121 } 122 }, this) 123 }); 124 125 } 126 } 127 128 BX.MIBOK.USERCONSENT.create = function(config) { 129 let self = new BX.MIBOK.USERCONSENT(); 130 self.initialize(config); 131 return self; 132 } 133}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.