From 80b0f2d4f76af2667507d69d25b06f1f9374f56a Mon Sep 17 00:00:00 2001 From: Raphael Kabo Date: Sat, 23 Apr 2022 16:09:57 +0100 Subject: feat: Add event group ical feeds --- views/eventgroup.handlebars | 122 ++++++++++++++++++++++++++++++++------------ 1 file changed, 90 insertions(+), 32 deletions(-) (limited to 'views/eventgroup.handlebars') diff --git a/views/eventgroup.handlebars b/views/eventgroup.handlebars index d7726bd..e659915 100755 --- a/views/eventgroup.handlebars +++ b/views/eventgroup.handlebars @@ -23,39 +23,63 @@ Welcome to your event group! We've just sent you an email with your secret editing link, which you can also see in the address bar above. Haven't got the email? Check your spam or junk folder. To share your event group, use the link you can see just below this message - that way your attendees won't be able to edit or delete your event group! {{/if}} -
-
- +
+
+ +
+ +
@@ -224,11 +248,22 @@ $("#eventGroupImagePreview").css("background-size", "cover"); $("#eventGroupImagePreview").css("background-position", "center center"); new ClipboardJS('#copyEventLink'); + new ClipboardJS('#copyFeedLink'); autosize($('textarea')); + $("#exportICS").click(function(){ + let eventGroupID = $(this).attr('data-event-id'); + $.get('/exportgroup/' + eventGroupID, function(response) { + downloadFile(response, eventGroupID + '.ics'); + }) + }) $("#copyEventLink").click(function(){ $(this).html(' Copied!'); setTimeout(function(){ $("#copyEventLink").html(' Copy');}, 5000); }); + $("#copyFeedLink").click(function(){ + $(this).html(' Copied!'); + setTimeout(function(){ $("#copyFeedLink").html(' Copy');}, 5000); + }); $('#verifyTokenForm').on('submit', function(e) { e.preventDefault(); @@ -254,5 +289,28 @@ $('#editModal').modal('hide'); }) + // From https://davidwalsh.name/javascript-download + function downloadFile(data, fileName, type="text/plain") { + // Create an invisible A element + const a = document.createElement("a"); + a.style.display = "none"; + document.body.appendChild(a); + + // Set the HREF to a Blob representation of the data to be downloaded + a.href = window.URL.createObjectURL( + new Blob([data], { type }) + ); + + // Use download attribute to set set desired file name + a.setAttribute("download", fileName); + + // Trigger the download by simulating click + a.click(); + + // Cleanup + window.URL.revokeObjectURL(a.href); + document.body.removeChild(a); + } + }); -- cgit v1.2.3