Dettaglio Evento
Breadcrumb
Asset Publisher
An error occurred while processing the template.
Java method "com.liferay.portal.kernel.util.DateUtil_IW.parseDate(String, String, Locale)" threw an exception when invoked on com.liferay.portal.kernel.util.DateUtil_IW object "com.liferay.portal.kernel.util.DateUtil_IW@5c0c7bb6"; see cause exception in the Java stack trace. ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign Data_DateObj = dateUtil.parse... [in template "20097#20123#41366" at line 307, column 13] ----
1<#--Evento Template -->
2
3<#assign assetEntryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryLocalService")>
4<#assign journalArticleResourceLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleResourceLocalService") />
5<#assign journalArticleId = .vars['reserved-article-id'].data />
6<#assign articleResourcePrimaryKey = journalArticleResourceLocalService.getArticleResourcePrimKey(themeDisplay.getScopeGroupId(), journalArticleId) />
7<#assign assetEntry = assetEntryLocalService.getEntry("com.liferay.journal.model.JournalArticle", articleResourcePrimaryKey) />
8<#assign escapeUtil = serviceLocator.findService("com.liferay.portal.kernel.util.HtmlUtil")/>
9<#assign categories = assetEntry.getCategories() />
10<#assign dlFileEntryService = serviceLocator.findService('com.liferay.document.library.kernel.service.DLFileEntryService') />
11
12<#assign publish_date = languageUtil.get(locale, "agora-publish-date") />
13<#assign share = languageUtil.get(locale, "agora-share") />
14<#assign arg = languageUtil.get(locale, "agora-arguments") />
15<#assign index = languageUtil.get(locale, "agora-index") />
16<#assign description_title = languageUtil.get(locale, "agora-description") />
17<#assign documents_title = languageUtil.get(locale, "agora-documents") />
18<#assign links_title = languageUtil.get(locale, "agora-links") />
19<#assign others_title = languageUtil.get(locale, "agora-others-info") />
20<#assign go = languageUtil.get(locale, "agora-go") />
21<#assign back = languageUtil.get(locale, "agora-back") />
22<#assign close = languageUtil.get(locale, "agora-close") />
23<#assign addCalendar = languageUtil.get(locale, "agora-add-calendar") />
24<#assign description_event = languageUtil.get(locale, "agora-event-description") />
25<#assign from = languageUtil.get(locale, "agora-date-from") />
26<#assign to = languageUtil.get(locale, "agora-date-to") />
27<#assign hour = languageUtil.get(locale, "agora-hour") />
28
29
30
31<#assign title = .vars['reserved-article-title'].data />
32<#assign data_pubblicazione = .vars['reserved-article-display-date'].data>
33
34<#assign urlBanner = ""/>
35<#assign NumeroBannerNews = 0/>
36<#assign ariaLabelBanner = ""/>
37<#if (Banner.getData())?? && Banner.getData() != "">
38 <#assign altBanner = Banner.getAttribute("alt")/>
39 <#assign titleBanner = Banner.getAttribute("title")/>
40 <#assign urlBanner = Banner.getData()/>
41 <#assign ariaLabelBanner = "Immagine news " + titleBanner/>
42</#if>
43
44<#assign numeroDescrizioni = 0 />
45<#assign descrizione = "" />
46<#if (Descrizione.getData())?? >
47 <#assign descrizione = Descrizione.getData()/>
48 <#assign numeroDescrizioni = numeroDescrizioni + 1 />
49</#if>
50
51
52<#assign numeroDocumenti = 0/>
53<#if Documenti.getSiblings()?has_content>
54 <#list Documenti.getSiblings() as documento>
55 <#if documento?? && documento.getData()?? && documento.getData() != "" && documento.getData()?length gt 0>
56 <#assign numeroDocumenti = numeroDocumenti + 1/>
57 </#if>
58 </#list>
59</#if>
60
61
62<#assign numeroCategorie = 0 />
63<#list categories as category>
64 <#if category?? && category?has_content>
65 <#assign numeroCategorie = numeroCategorie + 1/>
66 </#if>
67</#list>
68
69<#assign numeroUlterioriInformazioni = 0/>
70<#assign ulterioriInformazioni = ""/>
71<#if (UlterioriInformazioni.getData())??>
72 <#if UlterioriInformazioni.getData() != "">
73 <#assign ulterioriInformazioni = UlterioriInformazioni.getData()/>
74 <#assign numeroUlterioriInformazioni = numeroUlterioriInformazioni + 1 />
75 </#if>
76</#if>
77
78<#assign numeroContenutiTotale = numeroDescrizioni + numeroDocumenti + numeroUlterioriInformazioni/>
79
80<#if (DataInizioEvento.getData())?? && DataInizioEvento.getData() != "">
81 <#assign date_format="dd MMMM yyyy"/>
82 <#assign data_inizio_evento = DataInizioEvento.getData() />
83 <#if data_inizio_evento != "">
84 <#assign Data_DateObj = dateUtil.parseDate("yyyy-MM-dd", data_inizio_evento?string, locale)>
85 <#assign data_inizio_evento = dateUtil.getDate(Data_DateObj, date_format, locale)?lower_case />
86 </#if>
87</#if>
88
89
90<#if (DataFineEvento.getData())?? && DataFineEvento.getData() != "">
91 <#assign date_format="dd MMMM yyyy"/>
92 <#assign data_fine_evento = DataFineEvento.getData() />
93 <#if data_fine_evento != "">
94 <#assign Data_DateObj = dateUtil.parseDate("yyyy-MM-dd", data_fine_evento?string, locale)>
95 <#assign data_fine_evento = dateUtil.getDate(Data_DateObj, date_format, locale)?lower_case />
96 </#if>
97</#if>
98
99
100<#assign ora_inizio_evento = "" />
101<#if (OraInizioEvento.getData())?? && OraInizioEvento.getData() != "">
102 <#assign ora_inizio_evento = OraInizioEvento.getData() />
103</#if>
104
105
106<#assign ora_fine_evento = "" />
107<#if (OraFineEvento.getData())?? && OraFineEvento.getData() != "">
108 <#assign ora_fine_evento = OraFineEvento.getData() />
109</#if>
110
111
112<#assign indirizzo_evento = "" />
113<#if (Indirizzo.getData())?? && Indirizzo.getData() != "">
114 <#assign indirizzo_evento = Indirizzo.getData() />
115</#if>
116
117
118<#assign luogo_evento = "" />
119<#if (Luogo.getData())?? && Luogo.getData() != "">
120 <#assign luogo_evento = Luogo.getData() />
121</#if>
122
123
124<#assign data_evento = ""/>
125<#if DataInizioEvento.getData()?? && DataInizioEvento.getData() != "">
126 <#if DataFineEvento.getData()?? && DataFineEvento.getData() != "">
127 <#if data_inizio_evento?string != "" && data_fine_evento?string != "" && data_inizio_evento?string != data_fine_evento?string>
128 <#assign data_evento = from?capitalize + " " + data_inizio_evento?string + " " + to + " " + data_fine_evento?string/>
129 <#else>
130 <#if data_inizio_evento?string != "">
131 <#assign data_evento = data_inizio_evento/>
132 </#if>
133 </#if>
134 <#else>
135 <#if data_inizio_evento?string != "">
136 <#assign data_evento = data_inizio_evento/>
137 </#if>
138 </#if>
139</#if>
140
141<#if ora_inizio_evento?string != "" && ora_fine_evento?string != "">
142 <#assign data_evento = data_evento + " " + hour + " " + ora_inizio_evento?string + " | " + ora_fine_evento?string/>
143<#else>
144 <#if ora_inizio_evento?string != "">
145 <#assign data_evento = data_evento + " " + hour + " " + ora_inizio_evento?string />
146 <#else>
147 <#assign data_evento = data_evento + " " + hour + " " + ora_fine_evento?string />
148 </#if>
149</#if>
150
151
152
153
154<#-- URL GOOGLE per la condivisione -->
155
156<#assign googleURL="https://calendar.google.com/calendar/r/eventedit?action=TEMPLATE" />
157<#assign titoloURL = "&text=" + escapeUtil.escapeURL(title) />
158
159<#assign Data_Data_Inizio=getterUtil.getString(DataInizioEvento.getData())>
160<#assign Data_Data_Fine=getterUtil.getString(DataFineEvento.getData())>
161
162<#assign dataURLInizio="" />
163<#if validator.isNotNull(Data_Data_Inizio)>
164 <#assign Data_DateObj = Data_Data_Inizio?date("yyyy-MM-dd")>
165 <#assign dataURLInizio=dateUtil.getDate(Data_DateObj, "yyyyMMdd" , locale)?string />
166</#if>
167
168<#assign dataURLFine="" />
169<#if validator.isNotNull(Data_Data_Fine)>
170 <#assign Data_DateObj_Fine = Data_Data_Fine?date("yyyy-MM-dd")>
171 <#assign dataURLFine=dateUtil.getDate(Data_DateObj_Fine, "yyyyMMdd" , locale)?string />
172</#if>
173
174<#assign oraInizioURL="" />
175<#if ora_inizio_evento?has_content>
176 <#assign oraInizioURL="T" />
177 <#if ora_inizio_evento?length==1>
178 <#assign oraInizioURL=oraInizioURL + "0" />
179 </#if>
180 <#assign oraInizioURL=oraInizioURL + ora_inizio_evento?replace(":", "") + "00" />
181</#if>
182
183<#assign oraFineURL="" />
184<#if ora_fine_evento?has_content>
185 <#assign oraFineURL="T" />
186 <#if ora_fine_evento?length==1>
187 <#assign oraFineURL=oraFineURL + "0" />
188 </#if>
189 <#assign oraFineURL=oraFineURL + ora_fine_evento?replace(":", "") + "00" />
190</#if>
191
192<#assign descrizioneURL = "&details=" + escapeUtil.escapeURL(description_event) />
193
194<#--<#assign descrizioneURL="" />
195<#if descrizione?has_content && descrizione?has_content>
196 <#assign descrizioneURL="&details=" + descrizione?replace('<[^>]+>','','r')?replace(" ", " +") />
197</#if> -->
198
199<#assign locationURL="" />
200<#if indirizzo_evento?has_content && luogo_evento?has_content>
201<#-- <#assign locationURL="&location=" + indirizzoCompleto?replace(" ", " +") + ",+" + citta?replace(" ", " +") /> -->
202<#assign locationURL="&location=" + escapeUtil.escapeURL(indirizzo_evento) + " " + escapeUtil.escapeURL(luogo_evento) />
203</#if>
204
205<#assign googleURL=googleURL + titoloURL + "&dates=" + dataURLInizio + oraInizioURL + "/" + dataURLFine + oraFineURL + descrizioneURL + locationURL />
206
207
208<#-- URL OUTLOOK per la condivisione -->
209<#assign sysTimeOffset = .now?iso("Europe/Rome")?string?split("+")[1]>
210
211<#assign Data_Data_Inizio=getterUtil.getString(DataInizioEvento.getData())>
212<#assign Data_Data_Fine=getterUtil.getString(DataFineEvento.getData())>
213
214<#assign outlookURL="https://outlook.live.com/owa/?path=/calendar/action/compose&rru=addevent&subject=" />
215<#assign titoloURL= escapeUtil.escapeURL(title) />
216<#assign descrizioneURL = "&body=" + escapeUtil.escapeURL(description_event) />
217
218<#assign locationURL="" />
219<#if indirizzo_evento?has_content && luogo_evento?has_content>
220 <#assign locationURL="&location=" + escapeUtil.escapeURL(indirizzo_evento) + " " + escapeUtil.escapeURL(luogo_evento) />
221</#if>
222
223<#assign dataURLInizio="" />
224<#if validator.isNotNull(Data_Data_Inizio)>
225 <#assign Data_DateObj = Data_Data_Inizio?date("yyyy-MM-dd")>
226 <#assign dataURLInizio=dateUtil.getDate(Data_DateObj, "yyyyMMdd" , locale)?string />
227</#if>
228<#assign dataURLFine="" />
229<#if validator.isNotNull(Data_Data_Fine)>
230 <#assign Data_DateObj_Fine = Data_Data_Fine?date("yyyy-MM-dd")>
231 <#assign dataURLFine=dateUtil.getDate(Data_DateObj_Fine, "yyyyMMdd" , locale)?string />
232</#if>
233
234
235<#assign oraInizioURL="&startdt=" + dataURLInizio />
236<#if ora_inizio_evento?has_content>
237 <#assign oraInizioURL=oraInizioURL + "T" />
238 <#if ora_inizio_evento?length==1>
239 <#assign oraInizioURL=oraInizioURL + "0" />
240 </#if>
241 <#assign oraInizioURL=oraInizioURL + ora_inizio_evento + ":00" + "+" + sysTimeOffset/>
242
243</#if>
244<#assign oraFineURL="&enddt=" + dataURLFine />
245<#if ora_fine_evento?has_content>
246 <#assign oraFineURL=oraFineURL + "T" />
247 <#if ora_fine_evento?length==1>
248 <#assign oraFineURL=oraFineURL + "0" />
249 </#if>
250 <#assign oraFineURL=oraFineURL + ora_fine_evento + ":00" + "+" + sysTimeOffset/>
251</#if>
252<#assign outlookURL=outlookURL + titoloURL + descrizioneURL + locationURL + oraInizioURL + oraFineURL />
253
254
255<#-- CAMPI APPLE per file .ics -->
256<p id="titoloEvento" style="display: none;">${title}</p>
257<p id="luogoEvento" style="display: none;">${luogo_evento}</p>
258<p id="indirizzoEvento" style="display: none;">${indirizzo_evento}</p>
259
260<#if validator.isNotNull(Data_Data_Inizio)>
261 <#assign Data_DateObj = Data_Data_Inizio?date("yyyy-MM-dd")>
262 <#assign dataURLInizioApple=dateUtil.getDate(Data_DateObj, "yyyy/MM/dd" , locale)?string />
263</#if>
264
265<#if validator.isNotNull(Data_Data_Fine)>
266 <#assign Data_DateObj = Data_Data_Fine?date("yyyy-MM-dd")>
267 <#assign dataURLFineApple=dateUtil.getDate(Data_DateObj, "yyyy/MM/dd" , locale)?string />
268</#if>
269<#assign dataInizioURLApple=dataURLInizioApple + " " + ora_inizio_evento + ":00" />
270<#assign dataFineURLApple=dataURLFineApple + " " + ora_fine_evento + ":00" />
271
272
273<p id="dataInizioForApple" style="display: none;">${dataInizioURLApple}</p>
274<p id="dataFineForApple" style="display: none;">${dataFineURLApple}</p>
275<p id="descrEvento" style="display: none;">${description_event}</p>
276
277
278<div class="eventi-agora full-page" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
279 <div class="px-4 pb-3 custom-shadow">
280 <div class="container">
281 <div class="row">
282 <div class="col-12 col-sm-12 col-md-9 col-lg-9">
283 <div class="title">
284 <h2>${title}</h2>
285 </div>
286 </div>
287
288 <div class="col-12 col-sm-12 col-md-3 col-lg-3 link-laterali">
289 <#if numeroCategorie gt 0>
290 <div class="argomenti">
291 <p>${arg}</p>
292 <#list categories as category>
293 <div class="chip chip-simple chip-primary">
294 <span class="chip-label">${category.getTitle(locale)}</span>
295 </div>
296 </#list>
297 </div>
298 </#if>
299 </div>
300 </div>
301 <#if validator.isNotNull(data_pubblicazione)>
302 <div class="data">
303 <span>${publish_date}</span>
304
305
306
307 <#assign Data_DateObj = dateUtil.parseDate("EEE, dd MMM yyyy HH:mm:ssZ", data_pubblicazione?string, locale)>
308
309 <#assign date = dateUtil.getDate(Data_DateObj, "dd MMM yyyy ", locale)?lower_case />
310
311 <p class="data-detail mb-0">${date?capitalize}</p>
312
313
314 </div>
315 </#if>
316 </div>
317 </div>
318
319 <div class="contenuti custom-background-white">
320 <#if urlBanner != "" && urlBanner?has_content>
321 <div class="banner d-flex justify-content-end align-items-center" style="background-image: url('${urlBanner})'">
322 <div class="dettagli-evento">
323 <#if data_evento?? && data_evento?has_content && data_evento?length gt 0>
324 <div class="dettagli-evento-data">
325 ${data_evento}
326 </div>
327 </#if>
328 <#if luogo_evento?has_content || indirizzo_evento?has_content>
329 <div class="dettagli-evento-indirizzo">
330 <div class="row">
331 <div class="col-1 d-flex justify-content-center">
332 <span class="maps-place">
333 <span class="fas fa-map-marker-alt"></span>
334 </span>
335 </div>
336 <div class="col-10 d-flex flex-column">
337 <#if luogo_evento?has_content>
338 <p class="mb-0 font-weight-normal">${luogo_evento}</p>
339 </#if>
340 <#if indirizzo_evento?has_content>
341 <p class="mb-0 font-weight-normal">${indirizzo_evento}</p>
342 </#if>
343 </div>
344 </div>
345 </div>
346 </#if>
347 </div>
348 </div>
349 </#if>
350
351 <#if numeroContenutiTotale gt 0>
352 <div class="container px-4 sezione-contenuti pt-4">
353 <div class="row border-top row-column-border row-column-menu-left mt-0">
354 <aside class="col-lg-4 col-md-12 col-sm-12 col-12">
355 <div class="sticky-wrapper navbar-wrapper">
356 <nav class="navbar it-navscroll-wrapper it-top-navscroll navbar-expand-lg indice">
357 <button class="custom-navbar-toggler" type="button" aria-controls="navbarNav"
358 aria-expanded="false" aria-label="Toggle navigation" data-target="#navbarNav">
359 <span class="it-list"></span>${index}
360 </button>
361 <div class="navbar-collapsable" id="navbarNav">
362 <div class="overlay"></div>
363 <div class="close-div sr-only">
364 <button class="btn close-menu" type="button">
365 <span class="it-close"></span>${close}
366 </button>
367 </div>
368 <a class="it-back-button" href="#">
369 <span class="fas fa-chevron-left"></span>
370 <span>${back}</span>
371 </a>
372 <div class="menu-wrapper">
373 <div class="link-list-wrapper">
374 <h3 class="no_toc pt-3">${index?upper_case}</h3>
375 <ul class="link-list indice-sezioni">
376 <li class="nav-item active">
377 <a class="nav-link active" href="#descrizione">
378 <span>${description_title?capitalize}</span>
379 </a>
380 </li>
381 <#if numeroDocumenti gt 0>
382 <li class="nav-item">
383 <a class="nav-link" href="#documenti">
384 <span>${documents_title?capitalize}</span>
385 </a>
386 </li>
387 </#if>
388 <#if numeroUlterioriInformazioni gt 0>
389 <li class="nav-item">
390 <a class="nav-link" href="#ulteriori-informazioni">
391 <span>${others_title?capitalize}</span>
392 </a>
393 </li>
394 </#if>
395 </ul>
396 </div>
397 </div>
398 </div>
399 </nav>
400 </div>
401 </aside>
402
403 <section class="col-lg-8 col-md-12 col-sm-12 col-12 it-page-sections-container">
404 <#--<#if (DataInizioEvento.getData()?? && DataInizioEvento.getData() != "") && ((DataFineEvento.getData())?? && DataFineEvento.getData() != "")>
405 <div class="share-calendar d-flex align-items-center justify-content-end">
406 ${addCalendar}
407 <button class="share-button" type="button" data-toggle="modal" data-target="#modalCalendar" onclick="openModalCalendar('${googleURL}', '${outlookURL}')">
408 <span class="fas fa-calendar-alt"></span>
409 </button>
410 </div>
411 </#if>-->
412
413 <#if numeroDescrizioni gt 0>
414 <article id="descrizione" class="it-page-section anchor-offset contenuti-testo">
415 ${descrizione}
416 </article>
417 </#if>
418
419 <#if numeroDocumenti gt 0>
420 <article id="documenti" class="it-page-section anchor-offset contenuti-testo contenuti-box">
421 <#if Documenti.getSiblings()?has_content>
422 <h3>${documents_title?capitalize}</h3>
423 <#list Documenti.getSiblings() as documento>
424 <#if documento.getData() != "" && documento.getData()?length gt 0 && documento.getData()?has_content>
425 <#assign splitter = documento.getData()?split("/")/>
426 <#attempt>
427 <#assign file = dlFileEntryService.getFileEntryByUuidAndGroupId(splitter[5]?split("?")[0], splitter[2]?number) />
428 <#assign dlFileEntry=assetEntryLocalService.getEntry("com.liferay.document.library.kernel.model.DLFileEntry", file.fileEntryId) />
429 <#assign assetRenderer=dlFileEntry.assetRenderer />
430 <#assign docUrl=assetRenderer.getURLDownload(themeDisplay) />
431 <#assign categories_file = dlFileEntry.getCategories()/>
432
433 <div class="descrizione-documento <#if !documento?is_first> pt-4 </#if>">
434 <div class="row">
435 <div class="col-12 col-sm-12 col-md-10 col-lg-10">
436 <p class="file-title font-weight-bold h4">${file.fileName}</p>
437 ${file.getDescription()}
438 </div>
439
440 <div class="col-12 col-sm-12 col-md-2 col-lg-2 doc-download-icon d-flex justify-content-center align-items-center my-5">
441 <a href="${docUrl}" download title="${file.fileName}">
442 <span class="download">
443 <span class="fas fa-file-download fa-2x"></span>
444 </span>
445 </a>
446 </div>
447 </div>
448 <div class="row">
449 <div class="col-12 col-sm-12 col-md-12 col-lg-12">
450 <#list categories_file as category>
451 <div class="chip chip-simple chip-primary">
452 <span class="chip-label">${category.getTitle(locale)}</span>
453 </div>
454 </#list>
455 </div>
456 </div>
457 </div>
458 <#recover>
459 </#attempt>
460 </#if>
461 </#list>
462 </#if>
463 </article>
464 </#if>
465
466 <#if numeroUlterioriInformazioni gt 0>
467 <div id="ulteriori-informazioni" class="ulteriori-informazioni contenuti-box">
468 <h3>${others_title?capitalize}</h3>
469 <div>
470 <div id="descrizione" class="contenuti-testo">
471 ${ulterioriInformazioni}
472 </div>
473 </div>
474 </div>
475 </#if>
476 </section>
477 </div>
478 </div>
479 </#if>
480 </div>
481</div>
482
483
484
485<#-- MODALE CALENDARIO EVENTO -->
486<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="modalCalendar" aria-hidden="true" id="modalCalendar" style="display: none;">
487 <div class="modal-dialog modal-lg modal-dialog-centered">
488 <div class="modal-content">
489 <div class="modal-header align-items-center">
490 <h5 class="modal-title text-transform-unset">Aggiungi al calendario</h5>
491 <button class="close m-0 p-0" type="button" data-dismiss="modal" aria-label="Close">
492 <svg class="icon">
493 <use xlink:href="/o/agora-theme/svg/sprite.svg#it-close"></use>
494 </svg>
495 </button>
496 </div>
497 <div class="modal-body">
498 <div class="row">
499 <div class="col-md-4 text-center">
500 <button id="btAppleCal" class="bt-share">
501 <img id="imgBtApple" src="/documents/20121/46821/AppleIcon.png" height="43px">
502 <!-- <i class="fab fa-apple icon-copy-link"></i> -->
503 </button>
504 <p class="link-subtitle">Apple Calendar</p>
505 </div>
506 <div class="col-md-4 text-center">
507 <a id="btGoogleCal" href="#" target="_blank">
508 <img id="imgBtGoogle" src="/documents/20121/46821/GoogleCalendarIcon.png" height="45px">
509 </a>
510 <p class="link-subtitle">Google Calendar</p>
511 </div>
512 <div class="col-md-4 text-center">
513 <a id="btOutlookCal" href="#" target="_blank">
514 <img id="imgBtOutlook" src="/documents/20121/46821/OutlookIcon.png" height="45px">
515 </a>
516 <p class="link-subtitle">Outlook Calendar</p>
517 </div>
518 </div>
519 </div>
520 <div class="modal-footer">
521 <#--<button class="btn btn-outline-primary btn-sm" type="button" data-dismiss="modal">Cancel</button>
522 <button class="btn btn-primary btn-sm" type="button">Action 1</button>-->
523 </div>
524 </div>
525 </div>
526</div>
527
528<script>
529
530function openModalCalendar(googleURL, outlookURL) {
531 console.log("open modal");
532 $('#modalCalendar').modal('show');
533
534 $('#btGoogleCal').attr('href', googleURL);
535
536 $('#btOutlookCal').attr('href', outlookURL);
537
538 $("#btAppleCal").prop("onclick", null).off("click");
539 $('#btAppleCal').click(function() {
540 appleCal();
541 });
542
543
544 function appleCal() {
545 console.log("appleCal")
546 var titolo = $('#titoloEvento').html();
547 var luogo = $('#luogoEvento').html();
548 var ind = $('#indirizzoEvento').html();
549 var dataIn = $('#dataInizioForApple').html();
550 var dataFine = $('#dataFineForApple').html();
551 var descr = $('#descrEvento').html();
552 var calEntry = icsFormatter();
553
554 calEntry.addEvent(titolo, descr, ind + ", " + luogo, dataIn, dataFine);
555 calEntry.download(titolo.replace(/ /g, ''));
556}
557
558var icsFormatter = function() {
559 console.log("icsFormatter");
560 'use strict';
561
562 if (navigator.userAgent.indexOf('MSIE') > -1 && navigator.userAgent.indexOf('MSIE 10') == -1) {
563 console.log('Unsupported Browser');
564 return;
565 }
566
567 var SEPARATOR = (navigator.appVersion.indexOf('Win') !== -1) ? '\r\n' : '\n';
568 var calendarEvents = [];
569 var calendarStart = [
570 'BEGIN:VCALENDAR',
571 'VERSION:2.0'
572 ].join(SEPARATOR);
573 var calendarEnd = SEPARATOR + 'END:VCALENDAR';
574
575 return {
576 /**
577 * Returns events array
578 * @return {array} Events
579 */
580 'events': function() {
581 return calendarEvents;
582 },
583
584 /**
585 * Returns calendar
586 * @return {string} Calendar in iCalendar format
587 */
588 'calendar': function() {
589 return calendarStart + SEPARATOR + calendarEvents.join(SEPARATOR) + calendarEnd;
590 },
591
592 /**
593 * Add event to the calendar
594 * @param {string} subject Subject/Title of event
595 * @param {string} description Description of event
596 * @param {string} location Location of event
597 * @param {string} begin Beginning date of event
598 * @param {string} stop Ending date of event
599 */
600 'addEvent': function(subject, description, location, begin, stop) {
601 // I'm not in the mood to make these optional... So they are all required
602 if (typeof subject === 'undefined' ||
603 typeof description === 'undefined' ||
604 typeof location === 'undefined' ||
605 typeof begin === 'undefined' ||
606 typeof stop === 'undefined'
607 ) {
608 return false;
609 }
610
611 //TODO add time and time zone? use moment to format?
612 var start_date = new Date(begin);
613 var end_date = new Date(stop);
614
615 var start_year = ("0000" + (start_date.getFullYear().toString())).slice(-4);
616 var start_month = ("00" + ((start_date.getMonth() + 1).toString())).slice(-2);
617 var start_day = ("00" + ((start_date.getDate()).toString())).slice(-2);
618 var start_hours = ("00" + (start_date.getHours().toString())).slice(-2);
619 var start_minutes = ("00" + (start_date.getMinutes().toString())).slice(-2);
620 var start_seconds = ("00" + (start_date.getMinutes().toString())).slice(-2);
621
622 var end_year = ("0000" + (end_date.getFullYear().toString())).slice(-4);
623 var end_month = ("00" + ((end_date.getMonth() + 1).toString())).slice(-2);
624 var end_day = ("00" + ((end_date.getDate()).toString())).slice(-2);
625 var end_hours = ("00" + (end_date.getHours().toString())).slice(-2);
626 var end_minutes = ("00" + (end_date.getMinutes().toString())).slice(-2);
627 var end_seconds = ("00" + (end_date.getMinutes().toString())).slice(-2);
628
629 // Since some calendars don't add 0 second events, we need to remove time if there is none...
630 var start_time = '';
631 var end_time = '';
632 if (start_minutes + start_seconds + end_minutes + end_seconds !== 0) {
633 start_time = 'T' + start_hours + start_minutes + start_seconds;
634 end_time = 'T' + end_hours + end_minutes + end_seconds;
635 }
636
637 var start = start_year + start_month + start_day + start_time;
638 var end = end_year + end_month + end_day + end_time;
639
640 var calendarEvent = [
641 'BEGIN:VEVENT',
642 'CLASS:PUBLIC',
643 'DESCRIPTION:' + description,
644 'DTSTART;VALUE=DATE:' + start,
645 'DTEND;VALUE=DATE:' + end,
646 'LOCATION:' + location,
647 'SUMMARY;LANGUAGE=en-us:' + subject,
648 'TRANSP:TRANSPARENT',
649 'END:VEVENT'
650 ].join(SEPARATOR);
651
652 calendarEvents.push(calendarEvent);
653 return calendarEvent;
654 },
655
656 /**
657 * Download calendar using the saveAs function from filesave.js
658 * @param {string} filename Filename
659 * @param {string} ext Extention
660 */
661 'download': function(filename, ext) {
662 if (calendarEvents.length < 1) {
663 return false;
664 }
665
666 ext = (typeof ext !== 'undefined') ? ext : '.ics';
667 filename = (typeof filename !== 'undefined') ? filename : 'calendar';
668 var calendar = calendarStart + SEPARATOR + calendarEvents.join(SEPARATOR) + calendarEnd;
669 window.open("data:text/calendar;charset=utf8," + escape(calendar));
670 }
671 };
672};
673
674if (typeof define === "function" && define.amd) {
675 /* AMD Format */
676 define("icsFormatter", [], function() {
677 return icsFormatter();
678 });
679} else if (typeof module === "object" && module.exports) {
680 /* CommonJS Format */
681 module.exports = icsFormatter();
682} else {
683 /* Plain Browser Support */
684 this.myModule = icsFormatter();
685}
686}
687
688</script>
689
690<style>
691 .eventi-agora .nav-item .nav-link span:hover {
692 color: #212529 !important;
693 }
694
695 /*.eventi-agora .share-calendar {
696 color: #222222;
697 padding-bottom: 2rem;
698 }
699 .eventi-agora .share-calendar span {
700 font-size: 30px;
701 color: #B40507;
702 }
703
704 .eventi-agora .share-calendar .share-button {
705 border: none;
706 background-color: transparent;
707 }
708
709 #modalCalendar .modal-content .modal-title {
710 text-transform: unset;
711 text-align: center;
712 color: #000000;
713 }
714
715 #modalCalendar .modal-content .modal-body #btAppleCal {
716 border: none;
717 background-color: transparent;
718 }
719
720#modalCalendar .modal-content .modal-footer {
721 padding: 24px 24px;
722}*/
723
724</style>