1var retryLimitGlobal = 3; 2 3function getSelectedComune() { 4 5 return doGetSelectedComune(retryLimitGlobal); 6 7} 8 9function getServicesForSelectedComune() { 10 11 return doGetServicesForSelectedComune(retryLimitGlobal); 12 13} 14 15function doGetSelectedComune(retryLimit) { 16 17 var result; 18 19 var ajaxSettings = { 20 type: 'GET', 21 headers: { 22 'Content-Type' : 'application/json' 23 }, 24 url: "/o/filter-gruppoHera/getSelectedComune", 25 async: false, 26 retryLimit : retryLimit 27 }; 28 29 $.ajax(ajaxSettings).done(function(data) { 30 console.log('Ajax getSelectedComune success') 31 result = data; 32 sessionStorage.setItem('selectedComune', JSON.stringify(data)); 33 }) 34 .fail(function(xhr, textStatus, errorThrown) { 35 console.error( 'Ajax getSelectedComune error' ); 36 if (xhr.status == 403) { 37 console.log("handle 403"); 38 retryLimit--; 39 if (retryLimit > 0) { 40 console.log("retry"); 41 return doGetSelectedComune(retryLimit); 42 } 43 44 } else { 45 result = JSON.parse(xhr.responseText); 46 } 47 }); 48 49 return result; 50} 51 52function doSaveSelectedComune(selectedComune, retryLimit) { 53 var result; 54 55 var ajaxSettings ={ 56 type: 'POST', 57 headers: { 58 'Content-Type' : 'application/json' 59 }, 60 data: JSON.stringify({selectedComune : selectedComune}), 61 url: "/o/filter-gruppoHera/saveSelectedComune", 62 async: false, 63 }; 64 $.ajax(ajaxSettings).done(function(data) { 65 console.log( 'Ajax save successful' ); 66 result = data; 67 }) 68 .fail(function(xhr, textStatus, errorThrown) { 69 console.log( 'Ajax save error' ); 70 if (xhr.status == 403) { 71 console.log("handle 403"); 72 retryLimit--; 73 if (retryLimit > 0) { 74 console.log("retry"); 75 //try again 76 result = doSaveSelectedComune(selectedComune, retryLimit) 77 } 78 } else { 79 //handle error 80 result = JSON.parse(xhr.responseText); 81 } 82 }); 83 return result; 84} 85 86 87function saveSelectedComune(selectedComune) { 88 doSaveSelectedComune(selectedComune, retryLimitGlobal); 89} 90 91 92function doGetServicesForSelectedComune(retryLimit) { 93 94 var result; 95 var ajaxSettings = { 96 type: 'GET', 97 headers: { 98 'Content-Type' : 'application/json' 99 }, 100 url: "/o/filter-gruppoHera/getServicesForSelectedComune", 101 retryLimit : retryLimit, 102 async: false 103 }; 104 105 $.ajax(ajaxSettings).done(function(data) { 106 console.log('Ajax getServicesFoSelectedComune success') 107 result = data; 108 sessionStorage.setItem('selectedComuneServices', JSON.stringify(data)) 109 }) 110 .fail(function(xhr, textStatus, errorThrown) { 111 console.error('Ajax getServicesFoSelectedComune error') 112 if (xhr.status == 403) { 113 console.log("handle 403"); 114 retryLimit--; 115 if (retryLimit > 0) { 116 console.log("retry"); 117 //try again 118 result = doGetServicesForSelectedComune(retryLimit); 119 } 120 121 } else { 122 //handle error 123 result = JSON.parse(xhr.responseText); 124 } 125 }); 126 127 return result; 128} 129 130 131var retryLimitGlobal = 3; 132 133function getSelectedComuneAAA() { 134 135 return doGetSelectedComuneAAA(retryLimitGlobal); 136 137} 138 139function getServicesForSelectedComuneAAA() { 140 141 return doGetServicesForSelectedComuneAAA(retryLimitGlobal); 142 143} 144 145function doGetSelectedComuneAAA(retryLimit) { 146 var result; 147 148 var ajaxSettings = { 149 type: 'GET', 150 headers: { 151 'Content-Type' : 'application/json' 152 }, 153 url: "/o/filter-acegas/getSelectedComune", 154 async: false, 155 retryLimit : retryLimit 156 }; 157 158 $.ajax(ajaxSettings).done(function(data) { 159 console.log('Ajax getSelectedComuneAAA success') 160 result = data; 161 }) 162 .fail(function(xhr, textStatus, errorThrown) { 163 console.error( 'Ajax getSelectedComuneAAA error' ); 164 if (xhr.status == 403) { 165 console.log("handle 403"); 166 retryLimit--; 167 if (retryLimit > 0) { 168 console.log("retry"); 169 //try again 170 result = doGetSelectedComuneAAA(retryLimit); 171 } 172 173 } else { 174 result = JSON.parse(xhr.responseText); 175 } 176 }); 177 178 return result; 179} 180 181function doSaveSelectedComuneAAA(selectedComune, retryLimit) { 182 var result; 183 184 var ajaxSettings ={ 185 type: 'POST', 186 headers: { 187 'Content-Type' : 'application/json' 188 }, 189 data: JSON.stringify({selectedComune : selectedComune}), 190 url: "/o/filter-acegas/saveSelectedComune", 191 async: false, 192 }; 193 $.ajax(ajaxSettings).done(function(data) {
194 console.log( 'Ajax save successful' ); 195 result = data; 196 }) 197 .fail(function(xhr, textStatus, errorThrown) { 198 console.log( 'Ajax AAA save error' ); 199 if (xhr.status == 403) { 200 console.log("handle 403"); 201 retryLimit--; 202 if (retryLimit > 0) { 203 console.log("retry"); 204 //try again 205 result = doSaveSelectedComuneAAA(retryLimit, selectedComune); 206 } 207 } else { 208 //handle error 209 result = JSON.parse(xhr.responseText); 210 } 211 }); 212 return result; 213} 214 215 216function saveSelectedComuneAAA(selectedComune) { 217 doSaveSelectedComuneAAA(selectedComune, retryLimitGlobal); 218} 219 220 221function doGetServicesForSelectedComuneAAA(retryLimit) { 222 223 var result; 224 var ajaxSettings = { 225 type: 'GET', 226 headers: { 227 'Content-Type' : 'application/json' 228 }, 229 url: "/o/filter-acegas/getServicesForSelectedComune", 230 retryLimit : retryLimit, 231 async: false 232 }; 233 234 $.ajax(ajaxSettings).done(function(data) { 235 console.log('Ajax getServicesFoSelectedComuneAAA success') 236 result = data; 237 }) 238 .fail(function(xhr, textStatus, errorThrown) { 239 console.error('Ajax getServicesFoSelectedComuneAAA error') 240 if (xhr.status == 403) { 241 console.log("handle 403"); 242 retryLimit--; 243 if (retryLimit > 0) { 244 console.log("retry"); 245 //try again 246 result = doGetServicesForSelectedComuneAAA(retryLimit); 247 } 248 249 } else { 250 //handle error 251 result = JSON.parse(xhr.responseText); 252 } 253 }); 254 255 return result; 256} 257 258 259 260/* --- keyboard nav detection --- */ 261document.addEventListener('keydown', function(e) { 262 if (e.key === 'Tab') { 263 document.body.classList.add('keyboard-nav'); 264 } 265}); 266document.addEventListener('mousedown', function() { 267 document.body.classList.remove('keyboard-nav'); 268}); 269 270 function setCookieVHera(name, value, hours) { 271 const date = new Date(); 272 date.setTime(date.getTime() + hours * 60 * 60 * 1000); 273 document.cookie = name + "=" + value + ";expires=" + date.toUTCString() + ";path=/"; 274 } 275 276 function getCookieVHera(name) { 277 const nameEQ = name + "="; 278 const ca = document.cookie.split(";"); 279 for (let i = 0; i < ca.length; i++) { 280 let c = ca[i]; 281 while (c.charAt(0) === " ") c = c.substring(1, c.length); 282 if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length); 283 } 284 return null; 285 } 286 287 let vheraTutorialKeydownHandler = null; 288let vheraLastFocusedElement = null; 289 290function getVHeraTutorialFocusables(overlay, chatBtn) { 291 const selector = ` 292 a[href], 293 button:not([disabled]), 294 textarea, 295 input:not([disabled]), 296 select, 297 [tabindex]:not([tabindex="-1"]) 298 `; 299 const inside = Array.from(overlay.querySelectorAll(selector)) 300 .filter(el => !el.hasAttribute('disabled') && el.offsetParent !== null); 301 302 const list = inside.slice(); 303 if (chatBtn) list.push(chatBtn); // include il bottone chat 304 305 return list; 306} 307 308function activateVHeraTutorialTrap(overlay, chatBtn) { 309 const focusables = getVHeraTutorialFocusables(overlay, chatBtn); 310 if (!focusables.length) return; 311 312 const first = focusables[0]; 313 const last = focusables[focusables.length - 1]; 314 315 vheraLastFocusedElement = document.activeElement; 316 first.focus(); 317 318 vheraTutorialKeydownHandler = function (e) { 319 if (e.key !== 'Tab') return; 320 321 const active = document.activeElement; 322 323 if (e.shiftKey) { 324 if (active === first) { 325 e.preventDefault(); 326 last.focus(); 327 } 328 } else { 329 if (active === last) { 330 e.preventDefault(); 331 first.focus(); 332 } 333 } 334 }; 335 336 document.addEventListener('keydown', vheraTutorialKeydownHandler, true); 337} 338 339function releaseVHeraTutorialTrap() { 340 if (vheraTutorialKeydownHandler) { 341 document.removeEventListener('keydown', vheraTutorialKeydownHandler, true); 342 vheraTutorialKeydownHandler = null; 343 } 344 345 const chatBtn = document.getElementById('open-chat-assistant-btn'); 346 347 if (chatBtn) { 348 chatBtn.focus(); 349 } else if (vheraLastFocusedElement && typeof vheraLastFocusedElement.focus === 'function') { 350 vheraLastFocusedElement.focus(); 351 } 352 353 vheraLastFocusedElement = null; 354} 355 356 357 window.addEventListener('DOMContentLoaded', () => { 358 359 // const path = window.location.pathname || ''; 360 361 // const isHomePage = (path === '/' || path === '/home' || path === '/web/ai.gruppohera.it' || path === '/web/ai.gruppohera.it/home' || path==="/web/gruppohera" || path==="/web/gruppohera/"); 362
363 const overlay = document.getElementById('chat-tutorial-overlay'); 364 const laterBtn = document.getElementById('chat-tutorial-later-btn'); 365 const chatBtn = document.getElementById('open-chat-assistant-btn'); 366 const handElement = document.getElementById('chatOverlayTutorialHandElement'); 367 368 369 if ( !overlay || !laterBtn || !chatBtn) { 370 return; 371 } 372 373 const TUTORIAL_DELAY = 'vheraTutorialDelay'; 374 const TUTORIAL_HIDE = 'vheraTutorialHide'; 375 376 const hasDelay = getCookieVHera(TUTORIAL_DELAY); 377 const hasHide = getCookieVHera(TUTORIAL_HIDE); 378 379 380 if (hasHide === '1') { 381 chatBtn.classList.remove('chat-btn--highlight'); 382 handElement.style.display = 'none'; 383 return; 384 } 385 386 if (hasDelay === '1') { 387 chatBtn.classList.remove('chat-btn--highlight'); 388 handElement.style.display = 'none'; 389 return; 390 } 391 if (sessionStorage.getItem('isChatAssistantClose') === 'true') { 392 chatBtn.classList.remove('chat-btn--highlight'); 393 handElement.style.display = 'none'; 394 return; 395 } 396 397 overlay.style.display = 'block'; 398 overlay.setAttribute('aria-hidden', 'false'); 399 chatBtn.classList.add('chat-btn--highlight'); 400 if (handElement) handElement.style.display = 'block'; 401 activateVHeraTutorialTrap(overlay, chatBtn); 402 403 laterBtn.addEventListener('click', () => { 404 setCookieVHera(TUTORIAL_DELAY, '1', 24); 405 overlay.style.display = 'none'; 406 handElement.style.display = 'none'; 407 overlay.setAttribute('aria-hidden', 'true'); 408 chatBtn.classList.remove('chat-btn--highlight'); 409 releaseVHeraTutorialTrap(); 410 411 }); 412 413 chatBtn.addEventListener('click', () => { 414 setCookieVHera(TUTORIAL_HIDE, '1', 24 * 365); 415 overlay.style.display = 'none'; 416 handElement.style.display = 'none'; 417 overlay.setAttribute('aria-hidden', 'true'); 418 chatBtn.classList.remove('chat-btn--highlight'); 419 releaseVHeraTutorialTrap(); 420 }); 421 }); 422
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.