-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathmeet-calendar.js
1288 lines (1121 loc) · 38.6 KB
/
meet-calendar.js
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
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const BASE_DOMAIN = "meet.jit.si";
const BASE_URL = "https://" + BASE_DOMAIN + "/";
const APP_NAME = "Jitsi";
const NUMBER_RETRIEVE_SCRIPT = false;
const CONFERENCE_MAPPER_SCRIPT = false;
//A text to be used when adding info to the location field.
const LOCATION_TEXT = APP_NAME + ' Meeting';
let generateRoomNameAsDigits = false;
/**
* The event page we will be updating.
*/
class EventContainer {
constructor() {
// Numbers used to access the service, will be listed in the
// autogenerated description of the event when adding a meeting to it.
// {"US": ["+1xxx", "+1xxx"], "France": ["+33xxx"]}
this.numbers = {};
// used to implement autocreate meetings, this is done after all
// the needed information is retrieved as numbers, upon calling update
this.scheduleAutoCreateMeeting = false;
}
/**
* @returns {EventContainer}
*/
static getInstance() {
var eventEditPage = document.querySelector('#maincell #coverinner');
if (eventEditPage)
return new GEvent(eventEditPage);
else if (document.querySelector('body').dataset.viewfamily)
return new G2Event(document.querySelector('body'));
else
return new MSLiveEvent();
}
/**
* The description of the event.
* @abstract
* @returns {Description}
*/
get description() {}
/**
* The button container where we will add the jitsi button.
* @abstract
*/
get buttonContainer() {}
/**
* The location of the event.
* @abstract
* @returns {Location}
*/
get location() {}
/**
* The container element of the event edit page.
* @returns {*}
*/
get container(){
return this.containerElement;
};
set container(c){
this.containerElement = c;
};
/**
* Main entry point of the event modifictaions.
* @abstract
*/
update() {}
/**
* Checks for the button on current page
*/
isButtonPresent() {
return ($('#jitsi_button').length >= 1);
}
/**
* Clears instances.
*/
reset() {
this.descriptionInstance = null;
this.locationInstance = null;
}
/**
* Updates meetingId, if there is meetingId set it, if not generate it.
*/
updateMeetingId() {
if (!this.isButtonPresent()) {
// there is no button present we will add it, so we will clean
// the state of the EventContainer, so we can update all values.
// this clears the states between creating/editing different events
// we add the button
this.reset();
}
var inviteText;
var ix = -1;
// checking location
if (this.location && this.location.text) {
inviteText = this.location.text;
if (inviteText)
ix = inviteText.indexOf(BASE_URL);
}
// if nothing found let's check description
if (ix == -1) {
inviteText = this.description.value;
if (inviteText)
ix = inviteText.indexOf(BASE_URL);
}
var url;
if (ix != -1 && (url = inviteText.substring(ix)) && url.length > 0) {
let resMeetingId = url.substring(BASE_URL.length);
// there can be ',' after the meeting, normally added when adding
// physical rooms to the meeting
var regexp = /([a-zA-Z]+).*/g;
var match = regexp.exec(resMeetingId);
if (match && match.length > 1)
resMeetingId = match[1];
this.meetingId = resMeetingId;
}
else {
if (generateRoomNameAsDigits) {
this.meetingId = randomDigitString(10);
}
else
this.meetingId = generateRoomWithoutSeparator();
if(NUMBER_RETRIEVE_SCRIPT) {
// queries a predefined location for settings
$.getJSON(NUMBER_RETRIEVE_SCRIPT,
jsonobj => {
this.inviteTextTemplate = jsonobj.inviteTextTemplate;
// if there is a room name dictionary lets use it and
// generate new room name
if (jsonobj.roomNameDictionary) {
this.meetingId = generateRoomWithoutSeparator(
jsonobj.roomNameDictionary);
}
if(!jsonobj.numbersEnabled)
return;
this.numbers = jsonobj.numbers;
this.inviteNumbersTextTemplate
= jsonobj.inviteNumbersTextTemplate;
if (this.scheduleAutoCreateMeeting) {
this.description.clickAddMeeting(
false, this.location);
this.scheduleAutoCreateMeeting = false;
}
});
} else {
if (this.scheduleAutoCreateMeeting) {
this.description.clickAddMeeting(
false, this.location);
this.scheduleAutoCreateMeeting = false;
}
}
}
}
/**
* Adds the jitsi button in buttonContainer.
*/
addJitsiButton() {
var container = this.buttonContainer;
if (!container)
return;
var description = this.description;
container.addClass('button_container');
container.append(
'<div id="jitsi_button" ' +
'class="goog-inline-block jfk-button jfk-button-action ' +
'jfk-button-clear-outline">' +
'<a href="#" style="color: white"></a>' +
'</div>');
description.update(this.location);
}
}
/**
* Represents the location field.
*/
class Location {
/**
* The text in the location field.
* @abstract
*/
get text() {}
/**
* Adds location info.
* @abstract
* @param text
*/
addLocationText(text){}
}
/**
* Represents the description of the event.
*/
class Description {
constructor(event) {
this.event = event;
}
/**
* Updates the description and location field is not already updated.
* @param location
*/
update(location) {
var isDescriptionUpdated = false;
// checks whether description was updated.
if (this.element != undefined) {
var descriptionContainsURL =
(this.value
&& this.value.length >= 1
&& this.value.indexOf(BASE_URL) !== -1);
isDescriptionUpdated =
descriptionContainsURL
// checks whether there is the generated name in the location
// input if there is a location
|| (location != null
&& location.text
&& location.text.indexOf(LOCATION_TEXT) != -1);
}
if(isDescriptionUpdated) {
// update button url of event has all the data
this.updateButtonURL();
} else {
// update button as event description has no meeting set
this.updateInitialButtonURL(location);
}
}
/**
* Creates meeting, filling all needed fields.
* @param isDescriptionUpdated - whether description was already updated,
* true when we are editing event.
* @param the location to use to fill the meeting URL
*/
clickAddMeeting(isDescriptionUpdated, location) {
if (!isDescriptionUpdated) {
// Build the invitation content
if (CONFERENCE_MAPPER_SCRIPT) {
// queries a predefined location for settings
$.getJSON(CONFERENCE_MAPPER_SCRIPT
+ "?conference=" + this.event.meetingId + "@conference." + BASE_DOMAIN,
jsonobj => {
if (jsonobj.conference && jsonobj.id) {
this.addDescriptionText(
this.getInviteText(jsonobj.id));
}
else {
this.addDescriptionText(
this.getInviteText());
}
});
}
else {
this.addDescriptionText(this.getInviteText());
}
this.updateButtonURL();
if (location)
location.addLocationText(
LOCATION_TEXT + ' - ' + BASE_URL + this.event.meetingId);
} else {
this.updateButtonURL();
}
}
/**
* The description html element.
* @abstract
*/
get element() {}
/**
* The text value of the description of the event.
* @abstract
*/
get value() {}
/**
* Adds description text to the existing text.
* @abstract
* @param text
*/
addDescriptionText(text){}
/**
* Generates description text used for the invite.
* @param dialInID optional dial in id
* @returns {String}
*/
getInviteText(dialInID) {
let inviteText;
let hasTemplate = false;
if (this.event.inviteTextTemplate) {
inviteText = this.event.inviteTextTemplate;
hasTemplate = true;
} else {
inviteText =
"Click the following link to join the meeting " +
"from your computer: " + BASE_URL + this.event.meetingId;
}
if (this.event.numbers && Object.keys(this.event.numbers).length > 0) {
if (this.event.inviteNumbersTextTemplate) {
inviteText += this.event.inviteNumbersTextTemplate;
hasTemplate = true;
Object.keys(this.event.numbers).forEach(key => {
let value = this.event.numbers[key];
inviteText = inviteText.replace(
'{' + key + '}',
key + ": " + value);
});
} else {
inviteText += "\n\n=====";
inviteText +="\n\nJust want to dial in on your phone? ";
inviteText += " \n\nCall one of the following numbers: ";
Object.keys(this.event.numbers).forEach(key => {
let value = this.event.numbers[key];
inviteText += "\n" + key + ": " + value;
});
inviteText += "\n\nSay your conference name: '"
+ this.event.meetingId
+ "' and you will be connected!";
}
}
if (hasTemplate) {
inviteText = inviteText.replace(/\{BASE_URL\}/g, BASE_URL);
inviteText
= inviteText.replace(/\{MEETING_ID\}/g, this.event.meetingId);
if (dialInID) {
inviteText
= inviteText.replace(/\{DIALIN_ID\}/g, dialInID);
}
}
return inviteText;
}
/**
* Updates the initial button text and click handler when there is
* no meeting scheduled.
*/
updateInitialButtonURL(location) {
var button = $('#jitsi_button a');
button.html('Add a ' + LOCATION_TEXT);
button.attr('href', '#');
button.on('click', e => {
e.preventDefault();
this.clickAddMeeting(false, location);
});
}
/**
* Updates the url for the button.
*/
updateButtonURL() {
try {
var button = $('#jitsi_button a');
button.html("Join your " + LOCATION_TEXT + " now");
button.off('click');
button.attr('href', BASE_URL + this.event.meetingId);
button.attr('target', '_new');
} catch (e) {
console.log(e);
}
}
}
/**
* The google calendar specific implementation of the event page.
*/
class GEvent extends EventContainer {
constructor(eventEditPage) {
super();
this.container = eventEditPage;
}
/**
* Updates content (adds the button if is not there).
* This is the entry point for all page modifications.
*/
update() {
if ($('table.ep-dp-dt').is(":visible")) {
this.updateMeetingId();
if(!this.isButtonPresent())
this.addJitsiButton();
}
}
/**
* The event location.
* @returns {GLocation}
*/
get location() {
if (!this.locationInstance)
this.locationInstance = new GLocation();
return this.locationInstance;
}
/**
* The button container holding jitsi button.
* @returns {*}
*/
get buttonContainer() {
// we will create a new raw to place the button
// this row will be after the Video Call row
let neighbor = $(getNodeID('rtc-row'));
if(neighbor.length == 0)
return null;
let newRowID = getNodePrefix() + '.' + 'jitsi-rtc-row';
let newRow = $('<tr id="' + newRowID + '">' +
'<th class="ep-dp-dt-th"></th>' +
'<td class="ep-dp-dt-td"></td>' +
'</tr>');
newRow.insertAfter(neighbor);
return newRow.find('td');
}
/**
* The event description.
* @returns {GDescription}
*/
get description() {
if (!this.descriptionInstance)
this.descriptionInstance = new GDescription(this);
return this.descriptionInstance;
}
}
/**
* The google calendar specific implementation of the location field in the
* event page.
*/
class GLocation extends Location {
constructor() {
super();
this.elem = $('[id*=location].ep-dp-input input');
if (this.elem.length === 0) {
// this is the case where location is not editable
let element = $('[id*=location].ep-dp-input div > div')[0];
this.elem = element;
this.elem.val = function () {
return element.innerHTML;
}
}
}
/**
* The text from the location input field.
* @returns {*}
*/
get text() {
return this.elem.val();
}
/**
* Adds text to location input.
* @param text
*/
addLocationText(text){
// Set the location if there is content
var locationNode = this.elem[0];
if (!locationNode) {
// this is the case where location was not editable
// we click it to make it visible and then replace the element
// so we can actually edit it and add the text
this.elem.click();
this.elem = $('[id*=location].ep-dp-input input');
locationNode = this.elem[0];
}
if (locationNode) {
locationNode.dispatchEvent(getKeyboardEvent('keydown'));
locationNode.value = locationNode.value == '' ?
text : locationNode.value + ', ' + text;
locationNode.dispatchEvent(getKeyboardEvent('input'));
locationNode.dispatchEvent(getKeyboardEvent('keyup'));
var changeEvt2 = document.createEvent("HTMLEvents");
changeEvt2.initEvent('change', false, true);
locationNode.dispatchEvent(changeEvt2);
}
}
}
/**
* The google calendar specific implementation of the description textarea in
* the event page.
*/
class GDescription extends Description {
constructor(event) {
super(event);
var description = $(getNodeID('descript textarea'))[0];
var descriptionRow = $(getNodeID('descript-row'));
if (descriptionRow.find('textarea').length === 0) {
// this is the case where description is not editable
// when loading the event (no textarea)
description = $('[id*="descript"] div > div > div')[0];
description.value = description.innerHTML;
description.noTextArea = true;
}
this.element = description;
}
/**
* The html element.
* @returns {*}
*/
get element() {
return this.el;
}
set element(el) {
this.el = el;
}
/**
* The text value of the description.
*/
get value() {
return this.el.value;
}
/**
* Adds text to the description.
* @param text
*/
addDescriptionText(text){
if (this.el.noTextArea) {
// this is the case where description was not editable
// so we click on the element to make it editable
// and replace the elements do the actual edit can function
this.el.click();
this.element = $(getNodeID('descript textarea'))[0];
}
this.el.dispatchEvent(getKeyboardEvent('keydown'));
// if there is already text in the description append on new line
if (this.el.value)
this.el.value = this.el.value + '\n';
this.el.value = this.el.value + text;
this.el.dispatchEvent(getKeyboardEvent('input'));
this.el.dispatchEvent(getKeyboardEvent('keyup'));
var changeEvt1 = document.createEvent("HTMLEvents");
changeEvt1.initEvent('change', false, true);
this.el.dispatchEvent(changeEvt1);
}
}
/**
* The new google calendar specific implementation of the event page.
*/
class G2Event extends EventContainer {
constructor(eventEditPage) {
super();
this.container = eventEditPage;
}
/**
* Updates content (adds the button if is not there).
* This is the entry point for all page modifications.
*/
update() {
// we want to trigger all the logic only when we have enough elements
// on the page, as the new interface is loading live and some elements
// are missing when directly go the event edit page
// we require the notifications element and location or description
// element
if ($('#xNtList').length != 0 // notifications
&& (
$("#xLocIn").length != 0 // editable location
|| $('#xOnCal').length != 0 // readonly location
|| $('#xDescIn').length != 0 // editable description
|| $('#xDesc').length != 0 // readonly description
)
&& !this.isButtonPresent()) {
this.updateMeetingId();
this.addJitsiButton();
}
}
/**
* The event location.
* @returns {GLocation}
*/
get location() {
if (!this.locationInstance) {
this.locationInstance = new G2Location();
}
return this.locationInstance;
}
/**
* The button container holding jitsi button.
* @returns {*}
*/
get buttonContainer() {
// we will create a new raw to place the button
// this row will be before the notifications row
let neighbor = $('#xNtList').parent();
if(neighbor.length == 0){
return null;
}
let buttonContainer = $('#jitsi_button_container');
if (buttonContainer.length !== 0) {
return buttonContainer.find('content');
}
let newRow = $(
'<div class = "FrSOzf">\
<div class = "tzcF6">\
<div class = "DPvwYc jitsi_edit_page_icon"/>\
</div>\
<div class = "j3nyw">\
<div class = "BY5aAd">\
<div role = "button" \
class = "uArJ5e UQuaGc Y5sE8d" \
id="jitsi_button_container">\
<content class = "CwaK9">\
<span id="jitsi_button" \
class="RveJvd snByac">\
</span>\
</content>\
</div>\
</div>\
</div>\
</div>');
newRow.insertBefore(neighbor);
return newRow.find('content');
}
/**
* Adds the jitsi button in buttonContainer.
*/
addJitsiButton() {
var container = this.buttonContainer;
if (!container)
return false;
this.description.update(this.location);
}
/**
* The event description.
* @returns {G2Description}
*/
get description() {
if (!this.descriptionInstance)
this.descriptionInstance = new G2Description(this);
return this.descriptionInstance;
}
}
/**
* The google calendar specific implementation of the location field in the
* event page.
*/
class G2Location extends Location {
_getSelector() {
return $("#xLocIn input[jsname=YPqjbf][role=combobox]");
}
_getLocationElement() {
let elem = this._getSelector();
if (elem.length === 0) {
// this is the case where location is not editable
let element = $('#xOnCal')[0];
if (!element) {
return undefined;
}
elem = element;
elem.val = function () {
return element.innerHTML;
}
}
return elem;
}
/**
* The text from the location input field.
* @returns {*}
*/
get text() {
let e = this._getLocationElement();
if (e)
return e.val();
else
return undefined;
}
/**
* Adds text to location input.
* @param text
*/
addLocationText(text){
let elem = this._getSelector();
// in case this element is missing, means we cannot edit the text
if (elem.length === 0)
return;
// Set the location if there is content
let locationNode = elem[0];
if (locationNode) {
locationNode.focus(); // Focus needed to make a simulation of keying in.
elem.attr(
'value',
locationNode.value === '' ?
text : locationNode.value + ', ' + text);
locationNode.dispatchEvent(getKeyboardEvent('input'));
// tried many combinations and cannot make it reliably working
// in some cases hovering over the input will make it save,
// otherwise text is seen in the input but is not saved after
// clicking save
window.setTimeout(function(){
locationNode.focus();
elem.val(elem.val()+ " ");
locationNode.dispatchEvent(getKeyboardEvent('input'));
},1000);
}
}
}
/**
* The google calendar specific implementation of the description textarea in
* the event page.
*/
class G2Description extends Description {
/**
* The html element.
* @returns {*}
*/
get element() {
var description = $('#xDescIn > [role="textbox"]');
if (!description || description.length == 0) {
// maybe it is not editable
description = $('#xDesc > div');
description.notEditable = true;
}
return description;
}
/**
* The text value of the description.
*/
get value() {
return this.element.text();
}
/**
* Adds text to the description.
* @param text
*/
addDescriptionText(text){
let el = this.element;
if (el.notEditable)
return;
let descriptionNode = el[0];
descriptionNode.dispatchEvent(getKeyboardEvent('keydown'));
descriptionNode.dispatchEvent(getKeyboardEvent('keypress'));
// format new lines
let textToInsert = text.replace(/(?:\r\n|\r|\n)/g, '<br />');
// if there is already text in the description append on new line
if (el.text().length > 0) {
el.append('<br/><br/>');
}
el.append(textToInsert);
descriptionNode.dispatchEvent(getKeyboardEvent('input'));
descriptionNode.dispatchEvent(getKeyboardEvent('keyup'));
}
/**
* Updates the initial button text and click handler when there is
* no meeting scheduled.
*/
updateInitialButtonURL(location) {
let button = $('#jitsi_button');
button.html('Add a ' + LOCATION_TEXT);
let container = this.event.buttonContainer;
container.parent().off('click');
container.parent().on('click', e => {
e.preventDefault();
this.clickAddMeeting(false, location);
});
}
/**
* Updates the url for the button.
*/
updateButtonURL() {
try {
var button = $('#jitsi_button');
button.html("Join your " + LOCATION_TEXT + " now");
var container = this.event.buttonContainer;
container.parent().off('click');
container.parent().on('click', e => {
e.preventDefault();
// call updateMeetingId, the case where somebody edited location
// and then click join now before saving
this.event.updateMeetingId();
window.open(BASE_URL + this.event.meetingId, '_blank');
});
} catch (e) {
console.log(e);
}
}
}
/**
* The outlook live calendar specific implementation of the event page.
*/
class MSLiveEvent extends EventContainer {
constructor() {
super();
this.container = document.getElementsByTagName("BODY")[0];
}
/**
* Updates content (adds the button if is not there).
* This is the entry point for all page modifications.
*/
update() {
if ($("div[aria-label='Event compose form']").is(":visible")) {
if(!this.isButtonPresent()) {
this.updateMeetingId();
this.addJitsiButton();
}
}
}
/**
* The event location. Currently not supported.
* @returns {MSLiveLocation}
*/
get location() {
return null;
}
/**
* The button container holding jitsi button.
* @returns {*}
*/
get buttonContainer() {
var container = $("span[id='MeetingCompose.LocationInputLabel']")
.parent().parent();
if(container.length == 0)
return null;
return container;
}
/**
* The event description.
* @returns {MSLiveDescription}
*/
get description() {
if (!this.descriptionInstance)
this.descriptionInstance = new MSLiveDescription(this);
return this.descriptionInstance;
}
/**
* Adds the jitsi button in buttonContainer.
*/
addJitsiButton() {
var container = this.buttonContainer;
if (!container)
return;
var description = this.description;
let newRow = $(
'<li>\
<button type="button" class="_cx_q2 o365button">\
<button type="button" \
class="_cx_t2 _cx_r2 o365button" \
aria-labelledby="_ariaId_81"> \
<span class = "_fc_3 csimg owaimg jitsi_ms_button"></span> \
<span class = "_fc_4 _fc_2 ms-font-s ms-font-weight-semibold ms-font-color-themePrimary" \
id = "jitsi_button"></span> \
</button> \
</button> \
</li>'
);
newRow.insertAfter(container);
description.update(this.location);
}
}
/**
* The outlook live calendar specific implementation of the description textarea
* in the event page.
*/
class MSLiveDescription extends Description {
constructor(event) {
super(event);
var description = $("div[aria-label='Event body'] p:first-child");
if (description.length == 0)
return;
this.element = description;
}
/**
* The html element.
* @returns {*}
*/
get element() {
return this.el[0];
}
set element(el) {
this.el = el;
}
/**
* The text value of the description.
*/
get value() {
return this.el.text();
}
/**
* Adds text to the description.
* @param text
*/
addDescriptionText(text){
// format link
var urlRegex = /(https?:\/\/[^\s]+)/g;
let textToInsert = text.replace(urlRegex, function(url) {
return '<a href="' + url + '">' + url + '</a>';
});
// format new lines