1class DZMContainerPlus{ 2 constructor(uid) { 3 this.container = ""; 4 this.uid = uid; 5 this.cookieId = "" 6 this.closeButton = "" 7 this.remember = false 8 this.rememberDays = 0 9 this.allowClose = false 10 this.showOnExit = false 11 this.showAfterSeconds = 0 12 this.selectors={ 13 containerSelector:'[data-dzm-cp-container="'+uid+'"]', 14 closeButtonSelector:'[data-dzm-cp-closebutton="'+uid+'"]' 15 16 } 17 } 18 19 /* 20 21 */ 22 init(options){ 23 this.container = document.querySelector(this.selectors.containerSelector) 24 if(this.container == null){ 25 console.warn('no container plus found') 26 return 27 } 28 if(options){ 29 30 if(typeof options.allowClose !== 'undefined'){ 31 this.allowClose = options.allowClose 32 if(this.allowClose){ 33 this.closeButton = this.container.querySelector(this.selectors.closeButtonSelector) 34 this.closeButton.addEventListener("click",(e) => { 35 this.hide(e,this) 36 }) 37 } 38 39 } 40 if(typeof options.remember !== 'undefined'){ 41 this.remember = options.remember 42 } 43 if(typeof options.rememberDays !== 'undefined'){ 44 this.rememberDays = options.rememberDays 45 } 46 if(typeof options.showAfterSeconds !== 'undefined'){ 47 this.showAfterSeconds = options.showAfterSeconds 48 } 49 if(typeof options.showOnExit !== 'undefined'){ 50 this.showOnExit = options.showOnExit 51 } 52 } 53 54 if(this.getCookie(this.uid) === ""){ 55 console.log('no cookie for ',this.uid) 56 57 if(this.showAfterSeconds > 0){ 58 console.log('showAfterSeconds set to ', this.showAfterSeconds) 59 setTimeout(()=>{ 60 this.container.classList.remove('d-none') 61 62 },this.showAfterSeconds * 1000) 63 return 64 } 65 66 if(this.showOnExit){ 67 console.log('showOnExit set to ', this.showOnExit) 68 69 document.addEventListener('mouseout',e=>{ 70 if(this.getCookie(this.uid) === ""){ 71 if (!e.toElement && !e.relatedTarget) 72 { 73 this.container.classList.remove('d-none') 74 } 75 } 76 77 }) 78 }else{ 79 console.log('remove d-none ', this.container) 80 this.container.classList.remove('d-none') 81 82 } 83 }else{ 84 console.log(' cookie for ',this.uid) 85 } 86 } 87 88 hide(e, instance){ 89 instance.container.classList.add('d-none') 90 if(instance.remember){ 91 instance.setCookie(instance.uid,1,instance.rememberDays) 92 } 93 } 94 95 getCookie(cname) { 96 let name = cname + "="; 97 let decodedCookie = decodeURIComponent(document.cookie); 98 let ca = decodedCookie.split(';'); 99 for(let i = 0; i <ca.length; i++) { 100 let c = ca[i]; 101 while (c.charAt(0) === ' ') { 102 c = c.substring(1); 103 } 104 105 if (c.indexOf(name) === 0) { 106 return c.substring(name.length, c.length); 107 } 108 } 109 return ""; 110 } 111 setCookie(cname, cvalue, exdays) { 112 const d = new Date(); 113 let expires = '' 114 if(exdays > 0){ 115 d.setTime(d.getTime() + (exdays*24*60*60*1000)); 116 expires = "expires="+ d.toUTCString() + ';'; 117 } 118 119 120 document.cookie = cname + "=" + cvalue + ";" + expires + "path=/"; 121 } 122 123 124}
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.