Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion site/themes/s2b_hugo_theme/assets/js/cal/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@
// Remove colons and periods for Google Calendar URL (2025-05-21T16:30:00.000Z => 20250521T163000000Z)
const calendarDates = `${startDate.replace(regex, '')}/${endDate.replace(regex, '')}`;

const descr = $.fn.truncateString(event.details, 500) + `\n\n${event.shareable}`;

googleCalUrl.search = new URLSearchParams({
action: "TEMPLATE",
text: `shift2Bikes: ${event.title}`,
location: event.address,
details: `${event.details}\n\n${event.shareable}`,
details: descr,
dates: calendarDates,
sf: true, // ??
output: 'xml'
Expand All @@ -100,6 +102,15 @@
return googleCalUrl.toString();
};

$.fn.truncateString = function ( str, maxLength=250 ) {
let text = str.substring(0,maxLength);
if (str.length > maxLength) {
// replace the last character with an ellipsis
text = text.slice(0, -1) + "…";
}
return text;
};

$.fn.compareTimes = function ( event1, event2 ) {
if ( event1.time < event2.time ) {
return -1;
Expand Down
6 changes: 1 addition & 5 deletions site/themes/s2b_hugo_theme/assets/js/cal/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ $(document).ready(function() {
if (event.printdescr) {
$('meta[property="og:description"]')[0].setAttribute("content", event.printdescr);
} else {
var descr = event.details.substring(0,250);
if (event.details.length > 250) {
// replace the last character with an ellipsis
descr = descr.slice(0, -1) + "…";
}
let descr = container.truncateString(event.details, 250);
$('meta[property="og:description"]')[0].setAttribute("content", descr);
}
document.title = event.title + " - Calendar - " + SITE_TITLE;
Expand Down