https://www.psychoterapia-skawinska.pl/wp-content/plugins/bookly-e…/js/bookly-extension.js?ver=1.6.9
1 2var contentChanged=false; 3 4setInterval(function () { 5 if(document.querySelector('.bookly-search-form-container .bookly-search-form-right').querySelector('div[role="button"]') && document.querySelector('.bookly-search-form-container .bookly-search-form-right').querySelectorAll('div[role="button"]').length>0){ 6 mainFunction(); 7 } else{ 8 document.querySelector('.bookly-search-form-left .bookly-search-form-my-form-staff').querySelectorAll('select option').forEach(i=>{ 9 i.style.display="block"; 10 }); 11 contentChanged=true; 12 } 13}, 50); // 1s odstÄp czasowy sprawdzajÄ cy refresh 14 15function mainFunction(){ 16 if(document.querySelector('.bookly-search-form-container .bookly-search-form-right').querySelectorAll('div[role="button"]') && document.querySelector('.bookly-search-form-container .bookly-search-form-right').querySelectorAll('div[role="button"]').length>0 && contentChanged==true){ 17 18 let booklySearchFormItems = document.querySelector('.bookly-search-form-container .bookly-search-form-right').querySelectorAll('div[role="button"]'); 19 20 processBooklyItems(booklySearchFormItems); 21// -------------------------------------------------------------------------------------------------------------------------- 22 23 booklySearchFormItems.forEach(item=>{ 24 let staff_name = item.querySelector('div[slot=header-title] span').innerText; 25 jQuery.ajax({ 26 type: 'POST', 27 url: wdwmajax.ajaxurl, 28 cache: false, 29 data: { 30 "action":'bebwdwm_get_staf_info', 31 "staff_name" : staff_name 32 }, 33 success: function(response){ 34 let dane = JSON.parse(response); 35 let div = document.createElement("span"); 36 let img = document.createElement("img"); 37 let p = document.createElement("p"); 38 p.classList.add('staff_profile_desc'); 39 p.innerHTML = dane.excerpt; 40 img.src = dane.img; 41 img.classList.add("staff_profile_image"); 42 div.classList.add('bebwdwm_div'); 43 div.appendChild(img); 44 div.appendChild(p); 45 item.querySelector('div[slot=header-title]').appendChild(div); 46 }, 47 error: function (error) { 48 console.log(error); 49 } 50 }); 51 item.addEventListener("click",(event)=>{ 52 53 jQuery.ajax({ 54 type: 'POST', 55 url: wdwmajax.ajaxurl, 56 cache: false, 57 data: { 58 "action":'bebwdwm_get_staf_info', 59 "staff_name" : staff_name 60 }, 61 success: function(response){ 62 let dane = JSON.parse(response); 63 let div = document.createElement("span"); 64 let a = document.createElement("a"); 65 let img = document.createElement("img"); 66 let p = document.createElement("p"); 67 p.classList.add("staff_profile_desc"); 68 p.innerHTML = dane.excerpt; 69 img.src = dane.img; 70 img.classList.add("staff_profile_image"); 71 a.innerHTML = "Zobacz profil"; 72 a.href = dane.url; 73 a.target = "_blank"; 74 a.classList.add('staff_profile_link'); 75 div.classList.add('bebwdwm_modal_div'); 76 div.appendChild(img); 77 div.appendChild(p); 78 div.appendChild(a); 79 item.querySelector('div[slot=header-title]').appendChild(div); 80 (document.querySelector('.bookly-modal-header-mark'))?document.querySelector('.bookly-modal-header-mark').nextElementSibling.appendChild(div):""; 81 }, 82 error: function (error) { 83 console.log(error); 84 } 85 }); 86 }) 87 }) 88 showStaffToService(); 89 contentChanged=false; 90 } 91 function ajaxRequest(data) { 92 return new Promise((resolve, reject) => { 93 jQuery.ajax({ 94 type: 'POST', 95 url: wdwmajax.ajaxurl, 96 cache: false, 97 data: data, 98 success: resolve, 99 error: reject 100 }); 101 }); 102 } 103 async function processBooklyItems(booklySearchFormItems) { 104 105 let calendarDate = document.querySelector('.bookly-search-form-left .bookly-search-form-calendar .bookly-calendar-control
105s-mark .bookly-calendar-middle-button-mark span').innerHTML; 106 let position = calendarDate.search(" "); 107 let year = parseInt(calendarDate.slice(position + 1)); 108 let month = calendarDate.slice(0, position); 109 let day = parseInt(document.querySelector('.bookly-search-form-left .bookly-search-form-calendar .bookly-calendar-dates-mark .bg-bookly span').innerText); 110 111 112 for (let item of booklySearchFormItems) { 113 var index = 0; 114 let staff_name = item.querySelector('div[slot=header-title] span').innerText; 115 let service_name = item.querySelector('.bookly-service-title-mark span').innerText; 116 117 try { 118 let response = await ajaxRequest({ 119 action: 'bebwdwm_staff_schedule_items', 120 staff_name: staff_name, 121 service_name: service_name, 122 year: year, 123 month: month, 124 day: day 125 }); 126 127 let dane = JSON.parse(response); 128 let headerDiv = item.querySelector("div[slot=header-title]"); 129 if (headerDiv && headerDiv.firstChild && headerDiv.firstChild.nextElementSibling) { 130 let headerSpan = headerDiv.firstChild.nextElementSibling.querySelector("span"); 131 if (headerSpan && headerSpan.innerText == staff_name) { 132 let slot_length = (dane['appointments'])?parseInt((dane['appointments'][index]['slot_length'])):0; 133 let working_hours = []; 134 let temp_free_slots = []; 135 let temp_busy_slots = []; 136 let rest = 0; 137 138 let breaks = []; 139 if(dane['breaks']){ 140 dane['breaks'].forEach(b=>{ 141 for(let z=parseInt(b['start_time']); z<(parseInt(b['end_time'])); z++){ 142 breaks.push(z); 143 } 144 }) 145 breaks.sort((a, b) => a - b); 146 } 147 148 if(dane['working_hours']){ 149 if((parseInt(dane["working_hours"][0]["start_time"]))%100!=0){ 150 rest = (parseInt(dane["working_hours"][0]["start_time"])%100).toString(); 151 if(rest.length<2){ 152 rest=parseInt(rest+"0"); 153 } 154 rest=parseInt(rest); 155 } 156 for(let x=parseInt(dane["working_hours"][0]["start_time"]); x<=(parseInt(dane["working_hours"][0]["end_time"]));x++){ 157 working_hours.push(x); 158 } 159 } 160 161 for(let x=0; x<working_hours.length-1;x++){ 162 temp_free_slots = working_hours.filter(n => { 163 const dwieOstatnie = n % 100; 164 return dwieOstatnie < 60 || dwieOstatnie > 99; 165 }); 166 } 167 168 working_hours = working_hours.filter(value => !breaks.includes(value)); 169 temp_free_slots = temp_free_slots.filter(value => !breaks.includes(value)); 170 171 let appointments = []; 172 if(dane['appointments']){ 173 dane['appointments'].forEach(a=>{ 174 for(let y=parseInt((a['start_time'])); y<(parseInt((a['end_time']))); y++){ 175 if(y>=parseInt(dane["working_hours"][0]["start_time"]) && y<parseInt(dane["working_hours"][0]["end_time"])){ 176 appointments.push(y);
177 } 178 } 179 }) 180 appointments.sort((a, b) => a - b); 181 temp_free_slots = temp_free_slots.filter(value => !appointments.includes(value)); 182 temp_busy_slots = temp_busy_slots.concat(appointments); 183 } 184 185 temp_free_slots.sort((a, b) => a - b); 186 temp_busy_slots.sort((a, b) => a - b); 187 188 let temp_free_slots2 = temp_free_slots.filter(value => !temp_busy_slots.includes(value)); 189 190 let temp_busy_slots2 = []; 191 for(let x=0; x<temp_busy_slots.length-1;x++){ 192 temp_busy_slots2 = temp_busy_slots.filter(n => { 193 const dwieOstatnie = n % 100; 194 return dwieOstatnie < 60 || dwieOstatnie > 99; 195 }); 196 } 197 198 counter=0; 199 let slots=[]; 200 let free_slots=[]; 201 for(let z=0; z<=temp_free_slots2.length-1;z++){ 202 if( temp_free_slots2[z] == temp_free_slots2[z+1]-1 || z==temp_free_slots2.length-1 || (temp_free_slots2[z+1] && (temp_free_slots2[z]==temp_free_slots2[z+1]-41) || (temp_free_slots2[z]==temp_free_slots2[z+1]-141) || (temp_free_slots2[z]==temp_free_slots2[z+1]-241) || (temp_free_slots2[z]==temp_free_slots2[z+1]-341) || (temp_free_slots2[z]==temp_free_slots2[z+1]-441) || (temp_free_slots2[z]==temp_free_slots2[z+1]-541) || (temp_free_slots2[z]==temp_free_slots2[z+1]-641) || (temp_free_slots2[z]==temp_free_slots2[z+1]-741) || (temp_free_slots2[z]==temp_free_slots2[z+1]-841) || (temp_free_slots2[z]==temp_free_slots2[z+1]-101) || (temp_free_slots2[z]==temp_free_slots2[z+1]-201) || (temp_free_slots2[z]==temp_free_slots2[z+1]-301) || (temp_free_slots2[z]==temp_free_slots2[z+1]-401) || (temp_free_slots2[z]==temp_free_slots2[z+1]-501) || (temp_free_slots2[z]==temp_free_slots2[z+1]-601) || (temp_free_slots2[z]==temp_free_slots2[z+1]-701) || (temp_free_slots2[z]==temp_free_slots2[z+1]-801) || (temp_free_slots2[z]==temp_free_slots2[z+1]-901) || (temp_free_slots2[z]==temp_free_slots2[z+1]-1001)) ){ 203 slots.push(temp_free_slots2[z]); 204 } 205 if(slots.length>=slot_length){ 206 free_slots.push(slots[0]+"f"); 207 slots=[]; 208 } 209 counter++; 210 } 211 212 counter=0; 213 slots=[]; 214 let busy_slots=[]; 215 for(let z=0; z<=temp_busy_slots2.length-1;z++){ 216 if( temp_busy_slots2[z] == temp_busy_slots2[z+1]-1 || z==temp_busy_slots2.length-1 || (temp_busy_slots2[z+1] && (temp_busy_slots2[z]==temp_busy_slots2[z+1]-41) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-141) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-241) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-341) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-441) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-541) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-641) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-741) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-841) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-101) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-201) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-301) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-401) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-501) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-601) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-701) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-801) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-901) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-1001) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-1101) || (temp_busy_slots2[z]==temp_busy_slots2[z+1]-1201)) ){ 217 slots.push(temp_busy_slots2[z]); 218 } 219 if(slots.length>=slot_length){ 220 busy_slots.push(slots[0]+"b"); 221 slots=[]; 222 } 223 counter++; 224 } 225 226 const result = free_slots.concat(busy_slots); 227 228 result.sort((a, b) => { 229 let numA = parseInt(a); 230 let numB = parseInt(b); 231 return numA - numB; 232 }); 233 234 let p = document.createElement("p"); 235 p.classList.add('bebwdwm_p'); 236 result.forEach(r=>{ 237 let s = document.createElement("span"); 238 if (r.includes("f")) { 239 r = r.replace("f", ""); 240 if(r.length<4){ 241 r = r.substring(0, 1) + ":" + r.substring(1); 242 }else{ 243 r = r.substring(0, 2) + ":" + r.substring(2); 244 } 245 s.classList.add('bebwdwm_f'); 246 } else if (r.includes("b")) { 247 r = r.replace("b", ""); 248 if(r.length<4){ 249 r = r.substring(0, 1) + ":" + r.substring(1); 250 }else{ 251 r = r.substring(0, 2) + ":" + r.substring(2); 252 } 253 s.classList.add('bebwdwm_b'); 254 } 255 s.innerText=r; 256 p.appendChild(s); 257 }) 258 item.querySelector('.bookly-card-body-mark div[slot="body-content"]').appendChild(p); 259 if(staff_name=="Lek. Olga Waligórska"){ 260 let paragraph = document.createElement("p"); 261 paragraph.classList.add('bebwdwm_p'); 262 paragraph.classList.add('additional-info'); 263 paragraph.innerText="Lekarz przyjmuje na ul. Brożka 1"; 264 item.querySelector('.bookly-card-body-mark div[slot="body-content"]').appendChild(paragraph); 265 } 266 } 267 } 268 index++; 269 } catch (error) { 270 console.error("AJAX error for staff_name: ", staff_name, error); 271 } 272 } 273 } 274 275} 276 277addEventListener('DOMContentLoaded',()=>{ 278 setTimeout(addOptionsToServices, 250); 279 function addOptionsToServices(){ 280 if(document.querySelector('.bookly-search-form-left .bookly-search-form-my-form-services')){ 281 const selectServices = document.querySelector('.bookly-search-form-left .bookly-search-form-my-form-services').querySelector('select'); 282 const serviceOptions = selectServices.querySelectorAll('option'); 283 let i=0; 284 let j=0; 285 serviceOptions.forEach(o=>{ 286 const newOption = document.createElement('option'); 287 newOption.value = ""; 288 newOption.disabled=true; 289 newOption.textContent=""; 290 if(o.innerText=="Psychoterapia indywidualna"){ 291 newOption.textContent = 'Psychoterapia/pomoc psychologiczna dla dorosÅych'; 292 }else if(o.innerText=="Psychoterapia online"){ 293 newOption.textContent = 'Psychoterapia online'; 294 }else if(o.innerText=="Psychoterapia dzieci"){ 295 newOption.textContent = 'Psychoterapia/pomoc psychologiczna dla dzieci i mÅodzieży'; 296 }else if(o.innerText=="Psychoterapia par"){ 297 newOption.textContent = 'Psychoterapia par'; 298 }else if(o.innerText=="Psychoterapia par"){ 299 newOption.textContent = 'Psychoterapia par'; 300 }else if(o.innerText=="Konsultacja rodzicielska"){ 301 newOption.textContent = 'Konsultacja rodzicielska'; 302 }else if(o.innerText=="Psychoterapia rodzin"){ 303 newOption.textContent = 'Psychoterapia rodzin'; 304 }else if(o.innerText=="Konsultacja psychiatryczna (pierwsza wizyta)"){ 305 newOption.textContent = 'Psychiatra'; 306 } 307 if(newOption.textContent!=""){ 308 selectServices.insertBefore(newOption,selectServices.options[i+j]); 309 j++; 310 } 311 i++; 312 }) 313 } 314 } 315 316}) 317function showStaffToService(){ 318 const serviceSelect = document.querySelector('.bookly-search-form-left .bookly-search-form-my-form-services').querySelector('select'); 319 const serviceSelectOptions = serviceSelect.querySelectorAll('option'); 320 let serviceID = 0; 321 serviceSelectOptions.forEach(o=>{ 322 if(o.selected==1){ 323 serviceID=o.value; 324 } 325 }) 326 if(serviceID==0){ 327 document.querySelector('.bookly-search-form-left .bookly-search-form-my-form-staff').querySelectorAll('select option').forEach(i=>
327{ 328 i.style.display="block"; 329 }) 330 return; 331 } 332 jQuery.ajax({ 333 type: 'POST', 334 url: wdwmajax.ajaxurl, 335 cache: false, 336 data: { 337 "action":'bebwdwm_show_staff_to_service', 338 "serviceid" : serviceID 339 }, 340 success: function(response){ 341 let dane = JSON.parse(response); 342 let x=0; 343 if(dane.length>0 && response!="error"){ 344 document.querySelector('.bookly-search-form-left .bookly-search-form-my-form-staff').querySelectorAll('select option').forEach(i=>{ 345 if(x!=0){ 346 i.style.display="none"; 347 } 348 if(dane.includes(i.value)){ 349 i.style.display="block"; 350 } 351 x++; 352 }) 353 } 354 }, 355 error: function (error) { 356 console.log(error); 357 } 358 }); 359}
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.