File tree Expand file tree Collapse file tree
site/themes/s2b_hugo_theme/assets/js/cal Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8484 const startString = startDate . format ( googleFormat ) ;
8585 const endString = endDate . format ( googleFormat ) ;
8686 const calendarDates = `${ startString } /${ endString } ` ;
87-
87+
88+ const descr = $ . fn . truncateString ( event . details , 500 ) + `\n\n${ event . shareable } ` ;
89+
8890 googleCalUrl . search = new URLSearchParams ( {
8991 action : "TEMPLATE" ,
9092 text : `shift2Bikes: ${ event . title } ` ,
9193 location : event . address ,
92- details : ` ${ event . details } \n\n ${ event . shareable } ` ,
94+ details : descr ,
9395 dates : calendarDates ,
9496 // FIX: this seems better than timezoneless but probably should be configurable.
9597 ctz : `America/Los_Angeles`
98100 return googleCalUrl . toString ( ) ;
99101 } ;
100102
103+ $ . fn . truncateString = function ( str , maxLength = 250 ) {
104+ let text = str . substring ( 0 , maxLength ) ;
105+ if ( str . length > maxLength ) {
106+ // replace the last character with an ellipsis
107+ text = text . slice ( 0 , - 1 ) + "…" ;
108+ }
109+ return text ;
110+ } ;
111+
101112 $ . fn . compareTimes = function ( event1 , event2 ) {
102113 if ( event1 . time < event2 . time ) {
103114 return - 1 ;
Original file line number Diff line number Diff line change @@ -69,11 +69,7 @@ $(document).ready(function() {
6969 if ( event . printdescr ) {
7070 $ ( 'meta[property="og:description"]' ) [ 0 ] . setAttribute ( "content" , event . printdescr ) ;
7171 } else {
72- var descr = event . details . substring ( 0 , 250 ) ;
73- if ( event . details . length > 250 ) {
74- // replace the last character with an ellipsis
75- descr = descr . slice ( 0 , - 1 ) + "…" ;
76- }
72+ let descr = container . truncateString ( event . details , 250 ) ;
7773 $ ( 'meta[property="og:description"]' ) [ 0 ] . setAttribute ( "content" , descr ) ;
7874 }
7975 document . title = event . title + " - Calendar - " + SITE_TITLE ;
You can’t perform that action at this time.
0 commit comments