1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
|
{{#if eventHasCoverImage}}
<div id="eventImageContainer" style="background-image: url(/events/{{eventData.image}});"></div>
{{else}}
<div id="genericEventImageContainer" style="background-image: url(/images/seigaiha.png);"></div>
{{/if}}
<div class="row">
<div class="col-lg">
<h3 id="eventName" data-event-id="{{eventData.id}}">{{eventData.name}}</h3>
</div>
<div class="col-lg-3 ml-2 edit-buttons">
{{#if editingEnabled}}
<button type="button" id="editEvent" class="btn btn-success" {{#if eventHasConcluded}}disabled{{/if}} data-event-id="{{eventData.id}}" data-toggle="modal" data-target="#editModal"><i class="fas fa-edit"></i> Edit event</button>
{{else}}
<button type="button" id="editEvent" class="btn btn-success" {{#if eventHasConcluded}}disabled{{/if}} data-event-id="{{eventData.id}}" data-toggle="modal" data-target="#editTokenModal"><i class="fas fa-edit"></i> Edit event</button>
{{/if}}
</div>
</div>
<div class="container my-4 pr-0">
<div class="row">
<div class="col-lg-9 card p-0">
<div class="card-body">
<ul class="fa-ul eventInformation">
<li>
<span class="fa-li">
<i class="fas fa-map-marker-alt"></i>
</span>
{{eventData.location}}
</li>
<li>
<span class="fa-li">
<i class="fas fa-fw fa-calendar-day"></i>
</span>
{{{displayDate}}}
<br>
<span class="text-muted">
{{#if eventHasBegun}}{{#unless eventHasConcluded}}Started {{else}}Ended {{/unless}}{{/if}}{{fromNow}}
</span>
</li>
{{#if eventHasHost}}
<li>
<span class="fa-li">
<i class="fas fa-fw fa-user-circle"></i>
</span>
<span class="text-muted">Hosted by</span> {{eventData.hostName}}
</li>
{{/if}}
{{#if eventData.eventGroup}}
<li>
<span class="fa-li">
<i class="fas fa-fw fa-calendar-alt"></i>
</span>
<span class="text-muted">Part of</span> <a href="/group/{{eventData.eventGroup.id}}">{{eventData.eventGroup.name}}</a>
</li>
{{/if}}
{{#if eventData.url}}
<li>
<span class="fa-li">
<i class="fas fa-fw fa-link"></i>
</span>
<a href="{{eventData.url}}">
{{eventData.url}}
</a>
</li>
{{/if}}
<li>
<span class="fa-li">
<i class="fas fa-fw fa-share-square"></i>
</span>
<a href="https://{{domain}}/{{eventData.id}}">{{domain}}/{{eventData.id}}</a>
<button type="button" id="copyEventLink" class="eventInformationAction btn btn-outline-secondary btn-sm" data-clipboard-text="https://{{domain}}/{{eventData.id}}">
<i class="fas fa-copy"></i> Copy
</button>
</li>
{{#if isFederated}}
<li>
<span class="fa-li">
<i class="fas fa-fw fa-share-square"></i>
</span>
@{{eventData.id}}@{{domain}}
<button type="button" id="copyAPLink" class="eventInformationAction btn btn-outline-secondary btn-sm" data-clipboard-text="@{{eventData.id}}@{{domain}}">
<i class="fas fa-copy"></i> Copy
</button>
</li>
{{/if}}
</ul>
</div>
</div>
<div class="col-lg-3" id="eventActions">
<aside class="btn-group-vertical d-flex" role="group" aria-label="Event actions">
<a href="http://www.google.com/calendar/event?action=TEMPLATE&dates={{parsedStart}}%2F{{parsedEnd}}&text={{escapedName}}&location={{parsedLocation}}&ctz={{timezone}}" class="btn btn-outline-secondary btn-sm">
<i class="far fa-calendar-plus"></i> Add to Google Calendar
</a>
<button type="button" id="exportICS" class="btn btn-outline-secondary btn-sm" data-event-id="{{eventData.id}}">
<i class="fas fa-download"></i> Export as ICS
</button>
<a target="_blank" href="http://maps.google.com/?q={{parsedLocation}}" class="btn btn-outline-secondary btn-sm">
<i class="fas fa-map-marked"></i> Show on Google Maps
</a>
<a target="_blank" href="https://www.openstreetmap.org/search?query={{parsedLocation}}" class="btn btn-outline-secondary btn-sm">
<i class="fas fa-map-marked"></i> Show on OpenStreetMap
</a>
</aside>
</div>
</div>
</div>
{{#if eventHasConcluded}}
<div class="alert alert-warning mb-4" role="alert">
This event has concluded. It can no longer be edited, and will be automatically deleted <span class="daysToDeletion"></span>.
</div>
{{/if}}
{{#if firstLoad}}
<div class="alert alert-success alert-dismissible fade show" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
Welcome to your event! 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, use the link you can see just above this message - that way your attendees won't be able to edit or delete your event!
</div>
{{/if}}
<div class="card mb-4" id="eventDescription">
<h5 class="card-header">About</h5>
<div class="card-body">
{{{parsedDescription}}}
</div>
</div>
{{#if eventData.usersCanAttend}}
<div class="card mb-4" id="eventAttendees">
<h5 class="card-header">Attendees {{#if eventAttendees}}({{eventAttendees.length}}){{/if}}
<div class="btn-group" role="group" aria-label="Attendance controls">
{{#unless noMoreSpots}}
<button type="button" id="attendEvent" class="btn btn-success" data-toggle="modal" data-target="#attendModal"><i class="fas fa-user-plus"></i> Add me</button>
{{/unless}}
<button type="button" id="unattendEvent" class="btn btn-secondary" data-toggle="modal" data-target="#unattendModal"><i class="fas fa-user-times"></i> Remove me</button>
</div>
</h5>
<div class="card-body">
{{#if eventData.maxAttendees}}
{{#if noMoreSpots}}
<div class="alert alert-warning text-center">This event is at capacity.</div>
{{else}}
<div class="alert alert-warning text-center">{{spotsRemaining}} {{plural spotsRemaining "spot(s)"}} remaining - add yourself now!</div>
{{/if}}
{{/if}}
{{#if eventAttendees}}
<ul class="attendeesList">
{{#each eventAttendees}}
<li{{#if ../editingEnabled}} data-attendee-name="{{this.name}}" data-attendee-id="{{this._id}}"{{/if}}>{{#if this.email}}<span class="attendee-name">{{this.name}}</span>{{else}}<a href="{{this.id}}"><span class="attendee-name">{{this.name}}</span></a>{{/if}}{{#if ../editingEnabled}} <a href="#" class="remove-attendee" data-toggle="modal" data-target="#removeAttendeeModal" title="Remove user from event"><i class="fas fa-user-times"></i></a>{{/if}}</li>
{{/each}}
</ul>
{{else}}
<p class="text-center text-muted mb-0">No attendees yet!</p>
{{/if}}
</div>
</div>
<div class="modal fade" id="attendModal" tabindex="-1" role="dialog" aria-labelledby="attendModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="attendModalLabel">Add yourself to '{{eventData.name}}'</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form id="attendEventForm" action="/attendevent/{{eventData.id}}" method="post">
<div class="modal-body">
<div class="form-group">
<label for="attendeeName">Your name</label>
<div class="form-group">
<input type="text" class="form-control" id="attendeeName" name="attendeeName" placeholder="Or an alias, perhaps..." data-validation="required length" data-validation-length="1-30">
</div>
</div>
<div class="form-group">
<label for="attendeeEmail">Your email (optional)</label>
<p class="form-text small">If you provide your email, you will receive updates to the event.</p>
<div class="form-group">
<input type="email" class="form-control" id="attendeeEmail" name="attendeeEmail" placeholder="We won't spam you <3" data-validation="email" data-validation-optional="true">
</div>
</div>
<div class="form-group">
<label for="removeAttendancePassword">Deletion password</label>
<p class="form-text small">You will need this password if you want to remove yourself from the list of event attendees. If you provided your email, you'll receive it by email. Otherwise, write it down now because it will <strong>not be shown again</strong>.</p>
<input type="text" class="form-control" readonly id="removeAttendancePassword" name="removeAttendancePassword">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Add myself</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" id="unattendModal" tabindex="-1" role="dialog" aria-labelledby="unattendModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="unattendModalLabel">Remove yourself from '{{eventData.name}}'</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form id="unattendEventForm" action="/unattendevent/{{eventData.id}}" method="post">
<div class="modal-body">
<div class="form-group">
<label for="removeAttendancePassword" class="form-label">Your deletion password</label>
<p class="form-text small">Lost your password? Get in touch with the event organiser.</p>
<input type="text" class="form-control" id="removeAttendancePassword" name="removeAttendancePassword">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Remove myself</button>
</div>
</form>
</div>
</div>
</div>
{{#if editingEnabled}}
<div class="modal fade" id="removeAttendeeModal" tabindex="-1" role="dialog" aria-labelledby="removeAttendeeModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="removeAttendeeModalLabel">Remove attendee from '{{eventData.name}}'</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form id="removeAttendeeForm" action="/removeattendee/{{eventData.id}}/" method="post">
<div class="modal-body">
<p>Are you sure you want to remove this attendee from the event? This action cannot be undone.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-danger">Remove attendee</button>
</div>
</form>
</div>
</div>
</div>
{{/if}}
{{/if}}
{{#if eventData.usersCanComment}}
<div class="card mb-4" id="eventComments">
<h5 class="card-header">Discussion</h5>
<div class="card-body">
<form id="commentForm" action="/post/comment/{{eventData.id}}/" method="post">
<div class="form-group">
<input type="text" class="form-control" id="commentAuthor" name="commentAuthor" placeholder="Your name" data-validation="required length" data-validation-length="1-60">
</div>
<div class="form-group">
<div class="input-group">
<textarea class="form-control" id="commentContent" name="commentContent" style="resize: none;" placeholder="What would you like to ask?" data-validation="required length" data-validation-length="1-280"></textarea>
<div class="input-group-append">
<button type="submit" class="btn btn-primary btn-block h-100" id="postComment">Send <i class="fas fa-chevron-right"></i></button>
</div>
</div>
</div>
</form>
{{#if eventData.comments}}
<hr style="border-style:dashed;">
<div class="container commentsList">
{{#each eventData.comments}}
<div class="comment">
<div class="row commentContainer">
<div class="col-lg commentText">
{{#if this.actorId}}
<p class="mb-0"><a href="{{this.actorId}}"><strong>{{this.author}}</strong></a> <a href="{{this.activityId}}"><small class="commentTimestamp text-muted">{{this.timestamp}}</small></a></p>
{{else}}
<p class="mb-0"><strong>{{this.author}}</strong> <small class="commentTimestamp text-muted">{{this.timestamp}}</small></p>
{{/if}}
<p>{{this.content}}</p>
{{#if this.replies}}
<hr>
<div class="repliesContainer">
{{#each this.replies}}
<p class="mb-0"><strong><i class="fas fa-reply text-muted"></i> {{this.author}}</strong> <small class="commentTimestamp text-muted">{{this.timestamp}}</small></p>
<p>{{this.content}}</p>
{{/each}}
</div>
{{/if}}
</div>
<div class="col-lg-3 commentMetadata text-right">
<button type="button" class="btn btn-outline-primary btn-sm openReplyBox">
<i class="fas fa-comment"></i> Reply
</button>
{{#if ../editingEnabled}}
<form class="d-inline" action="/deletecomment/{{../eventData.id}}/{{this._id}}/{{../eventData.editToken}}" method="post">
<button type="submit" class="btn btn-outline-danger btn-sm deleteComment">
<i class="fas fa-trash"></i> Delete
</button>
</form>
{{/if}}
</div>
</div>
<div class="row replyContainer">
<div class="col-md">
<form id="replyForm" action="/post/reply/{{../eventData.id}}/{{this._id}}" method="post">
<div class="form-group">
<input type="text" class="form-control form-control-sm" id="replyAuthor" name="replyAuthor" placeholder="Your name" data-validation="required length" data-validation-length="1-60">
</div>
<div class="form-group">
<div class="input-group">
<textarea class="form-control form-control-sm" id="replyContent" name="replyContent" style="resize: none;" placeholder="What would you like to reply?" data-validation="required length" data-validation-length="1-280"></textarea>
<div class="input-group-append">
<button type="submit" class="btn btn-primary btn-block h-100 btn-sm" id="postReply">Reply <i class="fas fa-chevron-right"></i></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
{{/each}}
</div>
{{/if}}
</div>
</div>
{{/if}}
<div class="modal fade" id="editTokenModal" tabindex="-1" role="dialog" aria-labelledby="editTokenModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editTokenModalLabel">Enter editing password</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form id="verifyTokenForm" action="/verifytoken/event/{{eventData.id}}" method="post">
<div class="modal-body">
<div class="form-group">
<p class="form-text small">Enter the editing password you received by email or were shown when the event was created.</p>
<div class="form-group">
<input type="text" class="form-control" id="editToken" name="editToken" placeholder="Get it right!" data-validation="required">
</div>
<div class="form-group">
<div class="alert alert-danger" style="display:none;"></div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Edit event</button>
</div>
</form>
</div>
</div>
</div>
{{#if editingEnabled}}
{{#unless eventHasConcluded}}
{{> editeventmodal }}
{{/unless}}
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteModalLabel">Delete '{{eventData.name}}'</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form id="deleteEventForm" action="/deleteevent/{{eventData.id}}" method="post">
<div class="modal-body">
<p>Are you sure you want to delete this event? This action cannot be undone.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-danger">Delete event</button>
</div>
</form>
</div>
</div>
</div>
{{/if}}
{{#unless eventHasConcluded}}
<script type="text/javascript" src="/js/generate-timezones.js"></script>
<script src='/js/niceware.js'></script>
{{/unless}}
<script>
$.validate({
lang: 'en',
errorElementClass: "is-invalid",
errorMessageClass: "text-danger",
successElementClass: "is-valid"
});
{{#if editingEnabled}}
$('#removeAttendeeModal').on('show.bs.modal', function (event) {
var listItem = $(event.relatedTarget).closest('li'); // List element enclosing button
var attendeeName = listItem.data('attendee-name');
var attendeeID = listItem.data('attendee-id');
var modal = $(this);
modal.find('.modal-title').text('Remove ' + attendeeName + ' from {{eventData.name}}')
modal.find('#removeAttendeeForm').attr('action', '/removeattendee/{{eventData.id}}/' + attendeeID);
})
{{#unless eventHasConcluded}}
$('#eventStart').datepicker({
language: 'en',
timepicker: true,
dateFormat: 'd MM yyyy',
dateTimeSeparator: ', ',
onSelect: function(formattedDate, rawDate){
$('#eventEnd').datepicker().data('datepicker').update('minDate', rawDate).clear();
}
});
$('#eventEnd').datepicker({
language: 'en',
timepicker: true,
dateFormat: 'd MM yyyy',
dateTimeSeparator: ', '
});
$("#timezone").val('{{eventData.timezone}}').trigger('change');
{{/unless}}
{{/if}}
$(".commentTimestamp").html(function(){
parsedDate = moment($(this).html()).fromNow();
return parsedDate;
});
$(".openReplyBox").click(function(){
// let replyID = $(this).attr("data-id");
$(this).closest(".comment").find(".replyContainer").slideToggle();
})
$(document).ready(function() {
// Save the editing token from the URL, if it is valid
const eventID = $('#eventName').attr('data-event-id');
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('e')) {
$.ajax({
type: "POST",
url: `/verifytoken/event/${eventID}`,
data: { editToken: urlParams.get('e') },
success: function(response, status, xhr) {
if (xhr.status === 200) {
addStoredToken(eventID, urlParams.get('e'));
}
},
error: function(response, status, xhr) {
// The editing token is wrong - remove it
removeStoredToken(eventID);
window.location = window.location.pathname;
}
});
} else if (getStoredToken(eventID)) {
const editToken = getStoredToken(eventID);
$.ajax({
type: "POST",
url: `/verifytoken/event/${eventID}`,
data: { editToken },
success: function(response, status, xhr) {
if (xhr.status === 200) {
window.location.search = `?e=${editToken}`;
}
},
error: function(response, status, xhr) {
// The editing token is wrong - remove it
removeStoredToken(eventID);
}
});
}
if (urlParams.has('show_edit')) {
$('#editModal').modal('show');
}
// 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);
}
$.uploadPreview({
input_field: "#image-upload",
preview_box: "#image-preview",
label_field: "#image-label",
label_default: "Choose file",
label_selected: "Change file",
no_label: false
});
$("#image-preview").css("background-image", "url('/events/{{eventData.image}}')");
$("#image-preview").css("background-size", "cover");
$("#image-preview").css("background-position", "center center");
{{#if editingEnabled}}
{{#unless eventHasConcluded}}
$('#eventStart').datepicker().data('datepicker').selectDate(moment('{{parsedStart}}', 'YYYYMMDD[T]HHmmss').toDate());
$('#eventEnd').datepicker().data('datepicker').selectDate(moment('{{parsedEnd}}', 'YYYYMMDD[T]HHmmss').toDate());
{{/unless}}
{{/if}}
new ClipboardJS('#copyEventLink');
autosize($('textarea'));
$("#exportICS").click(function(){
let eventID = $(this).attr('data-event-id');
$.get('/exportevent/' + eventID, function(response) {
downloadFile(response, eventID + '.ics');
})
})
$("#copyEventLink").click(function(){
$(this).html('<i class="fas fa-copy"></i> Copied!');
setTimeout(function(){ $("#copyEventLink").html('<i class="fas fa-copy"></i> Copy');}, 5000);
})
new ClipboardJS('#copyAPLink');
$("#copyAPLink").click(function(){
$(this).html('<i class="fas fa-copy"></i> Copied!');
setTimeout(function(){ $("#copyAPLink").html('<i class="fas fa-copy"></i> Copy');}, 5000);
})
$(".daysToDeletion").html(moment("{{eventEndISO}}").add(7, 'days').fromNow());
if ($("#joinCheckbox").is(':checked')){
$("#maxAttendeesCheckboxContainer").css("display","flex");
}
$("#maxAttendeesCheckbox").on("click", function() {
if ($(this).is(':checked')) {
$("#maxAttendeesContainer").slideDown('fast').css("display","flex");
$("#maxAttendees").attr("data-validation-optional","false");
}
else {
$("#maxAttendeesContainer").slideUp('fast');
$("#maxAttendees").attr("data-validation-optional","true").val("").removeClass('is-valid is-invalid');
}
});
$("#joinCheckbox").on("click", function() {
if ($(this).is(':checked')) {
$("#maxAttendeesCheckboxContainer").slideDown('fast').css("display","flex");
}
else {
$("#maxAttendeesCheckboxContainer").slideUp('fast');
$("#maxAttendeesCheckbox").prop("checked",false);
$("#maxAttendeesContainer").slideUp('fast');
$("#maxAttendees").attr("data-validation-optional","true").val("").removeClass('is-valid is-invalid');
}
});
$("#eventGroupCheckbox").on("click", function() {
if ($(this).is(':checked')) {
$("#eventGroupData").slideDown('fast');
$("#eventGroupID").removeAttr("data-validation-optional").attr("data-validation","required");
$("#eventGroupEditToken").removeAttr("data-validation-optional").attr("data-validation","required");
}
else {
$("#eventGroupData").slideUp('fast');
$("#eventGroupID").removeAttr("data-validation").attr("data-validation-optional","true").val("");
$("#eventGroupEditToken").removeAttr("data-validation").attr("data-validation-optional","true").val("");
}
});
$('#attendModal').on('show.bs.modal', function (event) {
var modal = $(this);
const passphrase = window.niceware.generatePassphrase(6).join('-');
modal.find('#removeAttendancePassword').val(passphrase);
});
$('#verifyTokenForm').on('submit', function(e) {
e.preventDefault();
let form = $(this);
$.ajax({
type: "POST",
url: form.attr('action'),
data: form.serialize(),
success: function(response, status, xhr) {
if (xhr.status === 200) {
// Save the token to localStorage for later
addStoredToken($('#eventName').attr('data-event-id'), new FormData(form[0]).get('editToken'));
window.location.search = `?e=${new FormData(form[0]).get('editToken')}&show_edit=true`;
}
},
error: function(response, status, xhr) {
form.find('.alert').text('That editing password is incorrect. Try again.').show();
}
});
});
$('#deleteEvent').on('click', function() {
$('#editModal').modal('hide');
})
});
</script>
|