1function startFullCalendar(url, options) 2{ 3 options = options || {}; 4 if (options.headertoolbar == undefined) 5 { 6 options.headertoolbar = { 7 left: 'prev,next', 8 center: 'title', 9 right: 'today dayGridMonth,timeGridWeek,timeGridDay,listWeek' 10 }; 11 } 12// if (options.defaultView == undefined) 13// { 14// options.defaultView = $(window).width() < 768 ? "listWeek" : "dayGridMonth"; 15// options.defaultView = "listWeek"; 16// } 17 if (options.prenotOnline !== undefined) 18 { 19 if (options.prenotOnline === "calendar") 20 { 21 options.defaultView = "dayGridMonth"; 22 } 23 else 24 { 25 options.defaultView = "listWeek"; 26 } 27 } 28 else 29 { 30 if (options.defaultView === undefined) 31 { 32 options.defaultView = "listWeek"; 33 } 34 } 35 if (options.homepage == undefined) 36 { 37 options.homepage = false; 38 } 39 40 function parseTimeOnDate(baseDate, timeString) 41 { 42 if (!baseDate || !timeString) 43 { 44 return null; 45 } 46 47 var parts = String(timeString).split(':'); 48 if (parts.length < 2) 49 { 50 return null; 51 } 52 53 var result = new Date(baseDate.getTime()); 54 result.setHours(parseInt(parts[0], 10) || 0); 55 result.setMinutes(parseInt(parts[1], 10) || 0); 56 result.setSeconds(parseInt(parts[2], 10) || 0); 57 result.setMilliseconds(0); 58 59 return result; 60 } 61 62 function getEventStartDate(event) 63 { 64 if (!event) 65 { 66 return null; 67 } 68 69 if (event.start instanceof Date) 70 { 71 return event.start; 72 } 73 74 if (event.start) 75 { 76 var parsedStart = new Date(event.start); 77 if (!isNaN(parsedStart.getTime())) 78 { 79 return parsedStart; 80 } 81 } 82 83 return null; 84 } 85 86 function getEventEndDate(event) 87 { 88 if (!event) 89 { 90 return null; 91 } 92 93 if (event.end instanceof Date) 94 { 95 return event.end; 96 } 97 98 if (event.end) 99 { 100 var parsedEnd = new Date(event.end); 101 if (!isNaN(parsedEnd.getTime())) 102 { 103 return parsedEnd; 104 } 105 } 106 107 var startDate = getEventStartDate(event); 108 if (!startDate) 109 { 110 return null; 111 } 112 113 var oraStop = event.oraStop || event.ora_stop || (event.extendedProps ? (event.extendedProps.oraStop || event.extendedProps.ora_stop) : null); 114 var derivedEnd = parseTimeOnDate(startDate, oraStop); 115 116 if (derivedEnd) 117 { 118 return derivedEnd; 119 } 120 121 return startDate; 122 } 123 124 function normalizeAndSortEvents(events) 125 { 126 if (!Array.isArray(events)) 127 { 128 return events; 129 } 130 131 return events.map(function(event){ 132 if (!event || typeof event != 'object') 133 { 134 return event; 135 } 136 137 var normalized = $.extend(true, {}, event); 138 139 if (!normalized.end) 140 { 141 var derivedEnd = getEventEndDate(normalized); 142 if (derivedEnd) 143 { 144 normalized.end = derivedEnd.toISOString(); 145 } 146 } 147 148 return normalized; 149 }).sort(function(a, b){ 150 var startA = getEventStartDate(a); 151 var startB = getEventStartDate(b); 152 153 var startTimeA = startA ? startA.getTime() : 0; 154 var startTimeB = startB ? startB.getTime() : 0; 155 156 if (startTimeA != startTimeB) 157 { 158 return startTimeA - startTimeB; 159 } 160 161 var endA = getEventEndDate(a); 162 var endB = getEventEndDate(b); 163 164 var endTimeA = endA ? endA.getTime() : startTimeA; 165 var endTimeB = endB ? endB.getTime() : startTimeB; 166 167 if (endTimeA != endTimeB) 168 { 169 return endTimeA - endTimeB; 170 } 171 172 var titleA = (a.title || '').toString().toLowerCase(); 173 var titleB = (b.title || '').toString().toLowerCase(); 174 175 return titleA.localeCompare(titleB); 176 }); 177 } 178 179 var calendarEl = document.getElementById('fullcalendar'); 180 var calendar = new FullCalendar.Calendar(calendarEl, { 181 locale: $('html').attr('lang'), 182 height: "auto", 183 firstDay: 1, 184 allDayText: GlobalTranslationArray.tuttoilgiorno, 185 noEventsContent: GlobalTranslationArray.noeventi, 186 initialView: options.defaultView, 187 views: { 188 month: { 189 dayHeaderFormat: { 190 weekday: 'short' 191 } 192 } 193 }, 194 headerToolbar: options.headertoolbar, 195 eventOrderStrict: true, 196 eventOrder: 'start,end,title', 197 buttonText: 198 { 199 today: GlobalTranslationArray.oggi, 200 month: GlobalTranslationArray.mese, 201 week: GlobalTranslationArray.settimana,
202 day: GlobalTranslationArray.giorno, 203 list: GlobalTranslationArray.lista, 204 }, 205 events: function(info, successCallback) 206 { 207 var data = { 208 act : 'fullcalendar-feed', 209 cerca : $('#sp-cerca').length>0 ? $('#sp-cerca').val() : '', 210 filter_cal : getChecked('sp-filter-cal', options.homepage), 211 filter_spazi : getChecked('sp-filter-spazi', options.homepage), 212 filter_persone : getChecked('sp-filter-persone', options.homepage), 213 filter_evento : getChecked('sp-filter-evento', options.homepage), 214 filter_indirizzo: getChecked('pr-filter-indirizzi', options.homepage), 215 filter_plesso : getChecked('pr-filter-plessi', options.homepage), 216 filter_data : getInputValue('pr-filter-date', options.homepage), 217 filter_aula : getChecked('pr-filter-aule', options.homepage), 218 start : info.startStr, 219 end : info.endStr, 220 sede_codice : sede_codice 221 }; 222 ajaxRequest(url, data, function(risultato){ 223 successCallback(normalizeAndSortEvents(risultato)); 224 }); 225 }, 226 eventClick: function(info) 227 { 228 info.jsEvent.preventDefault(); 229 $('#sp-event-modal .modal-body').html(''); 230 var data = { 231 act : 'fullcalendar-event', 232 id : info.event.extendedProps.evento_id, 233 tipo : info.event.extendedProps.evento_tipo, 234 clicked : info.event.startStr, 235 modal : '', 236 sede_codice : sede_codice 237 }; 238 ajaxRequest(url, data, function(risultato){ 239 $('#sp-event-modal .modal-body').html(risultato); 240 $('#sp-event-modal').modal('show'); 241 }); 242 /*if (info.event.url) 243 { 244 window.open(info.event.url); 245 }*/ 246 }, 247 eventContent: function(event) 248 { 249 if (options.homepage && event.view.type=='dayGridMonth') 250 { 251 var dot = document.createElement('div'); 252 dot.style = "width:18px; height: 18px; margin-left:-10px; margin-top:-10px; z-index:2"; 253 dot.setAttribute('data-tooltip', "tooltip"); 254 dot.title = event.event.extendedProps.oraStart+' - '+event.event.extendedProps.oraStop+' '+event.event.title; 255 256 var arrayOfDomNodes = [ dot ]; 257 return { domNodes: arrayOfDomNodes }; 258 } 259 else 260 { 261 if (event.event.extendedProps.imageurl) 262 { 263 var immagine = document.createElement('img'); 264 immagine.src = event.event.extendedProps.imageurl; 265 immagine.style = "width:16px; height:16px; margin-right:10px; margin-left:5px;"; 266 immagine.setAttribute('data-tooltip', "tooltip"); 267 immagine.title = 'Calendario: '+event.event.extendedProps.description; 268 } 269 else 270 { 271 var immagine = document.createElement('i'); 272 immagine.className = 'far fa-calendar-alt'; 273 immagine.style = "margin-right:4px;"; 274 } 275 276 var testo = document.createElement('span'); 277 testo.innerHTML = event.event.title; 278 testo.setAttribute('data-tooltip', "tooltip"); 279 testo.title = event.event.extendedProps.oraStart+' - '+event.event.extendedProps.oraStop+' '+event.event.title; 280 281 if (event.view.type!='listWeek') 282 { 283 var paragraph = document.createElement("div"); 284 paragraph.style = "width:100%; height:100%; overflow: hidden; text-overflow: ellipsis;"; 285 paragraph.appendChild(immagine); 286 paragraph.appendChild(testo); 287 } 288 else 289 { 290 var paragraph = document.createElement("a"); 291 paragraph.href = event.event.url; 292 paragraph.appendChild(immagine); 293 paragraph.appendChild(testo); 294 } 295 296 var arrayOfDomNodes = [ paragraph ]; 297 return { domNodes: arrayOfDomNodes }; 298 } 299 }, 300 eventDidMount: function(info) 301 { 302 $('[data-tooltip="tooltip"]').tooltip(); 303 }, 304 loading: function (isLoading) 305 { 306 if (!options.homepage) 307 { 308 if (isLoading) 309 { 310 $('.sp-loading').removeClass('d-none').show(); 311 } 312 else 313 { 314 $('.sp-loading').addClass('d-none').hide(); 315 } 316 } 317 } 318 }); 319 calendar.render(); 320 321 if (options.homepage) 322 { 323 var date = calendar.getDate(); 324 var month_int = date.getMonth(); 325 $('.sp-title').html(month_int); 326 } 327 328 $('.sp-btn-filters').click(function(){ 329 calendar.refetchEvents(); 330 }); 331 332 $('.sp-changeview').change(function(){ 333 calendar.changeView($('select.sp-changeview').val()); 334 }); 335 336 $('#schoolplanner .selectpicker').on("changed.bs.select", function(e,
336clickedIndex, newValue) { 337 if (clickedIndex!==undefined && clickedIndex!=='' && clickedIndex!==null) 338 { 339 var attuale=$('#'+$(this).attr('id'))[0]; 340 var id=clickedIndex; //attuale.options[clickedIndex].value; 341 var etichetta= attuale.options[clickedIndex].getAttribute('data-content'); 342 if (newValue) 343 { 344 createFilterBox($(this).attr('id'), etichetta, id); 345 } 346 else 347 { 348 removeFilterBox($(this).attr('id'), id); 349 } 350 } 351 }); 352 353 $('#schoolplanner .bs-select-all').click(function(){ 354 var attuale=$(this); 355 var tipo_select=attuale.parents('.selectpicker').attr('id'); 356 $('#'+tipo_select+' option').each(function(){ 357 var id=$(this).index(); 358 var etichetta=$(this).attr('data-content'); 359 if (id!==undefined && id!=='' && id!==null) 360 { 361 createFilterBox(tipo_select, etichetta, id); 362 } 363 }); 364 }); 365 366 $('#schoolplanner .bs-deselect-all').click(function(){ 367 var attuale=$(this); 368 var tipo_select=attuale.parents('.selectpicker').attr('id'); 369 $('#'+tipo_select+' option').each(function(){ 370 var id=$(this).index(); 371 if (id!==undefined && id!=='' && id!==null) 372 { 373 removeFilterBox(tipo_select, id); 374 } 375 }); 376 }); 377 378 return calendar; 379} 380 381function getChecked(tipo, homepage) 382{ 383 if (!homepage) 384 { 385 var array_checkbox = $('select#'+tipo).val(); 386 if (array_checkbox != '' && array_checkbox != undefined) 387 { 388 if (!Array.isArray(array_checkbox)) 389 { 390 return array_checkbox; 391 } 392 else 393 { 394 return array_checkbox.join(','); 395 } 396 } 397 else 398 { 399 return ''; 400 } 401 } 402 else 403 { 404 return ''; 405 } 406} 407 408function getInputValue(tipo, homepage) 409{ 410 if (!homepage) 411 { 412 var valore_input = $('input#' + tipo).val(); 413 if (valore_input != '' && valore_input != undefined) 414 { 415 return valore_input; 416 } 417 else 418 { 419 return ''; 420 } 421 } 422 else 423 { 424 return ''; 425 } 426} 427 428function bindFilters() 429{ 430 $('.sp-filter-item-del').click(function(){ 431 var tipo_select = $(this).attr('data-select'); 432 var option_id = $(this).attr('data-option_id'); 433 $('#'+tipo_select)[0].options[option_id].selected = false; 434 var tmp1=$('#'+tipo_select).siblings('.dropdown-menu').find('.inner').attr('id'); 435 var tmp2=tmp1+'-'+option_id; 436 $('#'+tmp2).removeClass('selected').attr('aria-selected', 'false'); 437 $('#'+tmp2).parents('li').removeClass('selected'); 438 $('#'+tipo_select).selectpicker('render'); 439 removeFilterBox(tipo_select, option_id); 440 }); 441} 442 443function createFilterBox(tipo_select, option_value, option_id) 444{ 445 if ($('.sp-filter-item-del[data-select="'+tipo_select+'"][data-option_id="'+option_id+'"]').length<=0) 446 { 447 var contenitore = document.createElement('div'); 448 contenitore.setAttribute('class', 'sp-filter-item'); 449 450 var icona; 451 452 switch (tipo_select) 453 { 454 case 'sp-filter-cal': 455 icona = document.createElement('i'); 456 break; 457 458 case 'sp-filter-spazi': 459 icona = document.createElement('i'); 460 icona.setAttribute('class', 'fas fa-map-marker-alt sp-filter-icon'); 461 break; 462 463 case 'sp-filter-persone': 464 icona = document.createElement('i'); 465 icona.setAttribute('class', 'fas fa-user-alt sp-filter-icon'); 466 break; 467 468 case 'sp-filter-evento': 469 icona = document.createElement('i'); 470 icona.setAttribute('class', 'fas fa-calendar-alt sp-filter-icon'); 471 break; 472 } 473 474 var a_cancella = document.createElement('a'); 475 a_cancella.href = '#'; 476 a_cancella.setAttribute('class', 'sp-filter-item-del'); 477 a_cancella.innerHTML = '<i class="fas fa-times"></i>'; 478 a_cancella.setAttribute('data-select', tipo_select); 479 a_cancella.setAttribute('data-option_id', option_id); 480 481 var testo = document.createElement('span'); 482 testo.innerHTML = option_value; 483 484 contenitore.appendChild(icona); 485 contenitore.appendChild(testo); 486 contenitore.appendChild(a_cancella); 487 488 $('.sp-filters').append(contenitore); 489 bindFilters(); 490 } 491} 492 493function removeFilterBox(tipo_select, option_id) 494{ 495 $('a[data-select="'+tipo_select+'"][data-option_id="'+option_id+'"]').parents('.sp-filter-item').remove(); 496 bindFilters(); 497}
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.