File tree Expand file tree Collapse file tree 2 files changed +30
-27
lines changed
site/themes/s2b_hugo_theme/assets/js/cal Expand file tree Collapse file tree 2 files changed +30
-27
lines changed Original file line number Diff line number Diff line change 7171 }
7272 } ;
7373
74+ $ . fn . getAddToGoogleLink = function ( event ) {
75+ const googleCalUrl = new URL ( 'https://www.google.com/calendar/render' ) ;
76+
77+ const startDate = dayjs ( `${ event . date } ${ event . time } ` ) . toISOString ( ) ;
78+ const duration = event . duration ?? 60 ; // Google requires a duration and defaults to 60 minutes anyway
79+ const endDate = dayjs ( startDate ) . add ( dayjs . duration ( { 'minute' : duration } ) ) . toISOString ( ) ;
80+ /**
81+ * Matches anything that is not a word or whitespace
82+ * @example
83+ * "2025-05-21T16:30:00.000Z".replace(regex, '') // 20250521T163000000Z
84+ */
85+ const regex = / [ ^ \w \s ] / gi;
86+
87+ // Remove colons and periods for Google Calendar URL (2025-05-21T16:30:00.000Z => 20250521T163000000Z)
88+ const calendarDates = `${ startDate . replace ( regex , '' ) } /${ endDate . replace ( regex , '' ) } ` ;
89+
90+ googleCalUrl . search = new URLSearchParams ( {
91+ action : "TEMPLATE" ,
92+ text : `shift2Bikes: ${ event . title } ` ,
93+ location : event . address ,
94+ details : `${ event . details } \n\n${ event . shareable } ` ,
95+ dates : calendarDates ,
96+ sf : true , // ??
97+ output : 'xml'
98+ } ) ;
99+
100+ return googleCalUrl . toString ( ) ;
101+ } ;
102+
74103 $ . fn . compareTimes = function ( event1 , event2 ) {
75104 if ( event1 . time < event2 . time ) {
76105 return - 1 ;
Original file line number Diff line number Diff line change @@ -56,33 +56,7 @@ $(document).ready(function() {
5656 exportURL . searchParams . set ( 'id' , value . id ) ;
5757 value . exportlink = exportURL . toString ( ) ;
5858
59- /**
60- * Add To Google Calendar
61- */
62- const googleCalUrl = new URL ( 'https://www.google.com/calendar/render' )
63- const startDate = dayjs ( `${ value . date } ${ value . time } ` ) . toISOString ( )
64- const duration = value . duration ?? 60 // Google requires a duration and defaults to 60 minutes anyway
65- const endDate = dayjs ( startDate ) . add ( dayjs . duration ( { 'minute' : duration } ) ) . toISOString ( )
66- /**
67- * Matches anything that is not a word or whitespace
68- * @example
69- * "2025-05-21T16:30:00.000Z".replace(regex, '') // 20250521T163000000Z
70- */
71- const regex = / [ ^ \w \s ] / gi
72-
73- // Remove colons and periods for Google Calendar URL (2025-05-21T16:30:00.000Z => 20250521T163000000Z)
74- const calendarDates = `${ startDate . replace ( regex , '' ) } /${ endDate . replace ( regex , '' ) } `
75-
76- googleCalUrl . search = new URLSearchParams ( {
77- action : "TEMPLATE" ,
78- text : `shift2Bikes: ${ value . title } ` ,
79- location : value . address ,
80- details : `${ value . details } \n\n${ value . shareable } ` ,
81- dates : calendarDates ,
82- sf : true , // ??
83- output : 'xml'
84- } )
85- value . addToGoogleLink = googleCalUrl . toString ( )
59+ value . addToGoogleLink = container . getAddToGoogleLink ( value ) ;
8660
8761 groupedByDate [ date ] . events . push ( value ) ;
8862 } ) ;
You can’t perform that action at this time.
0 commit comments