-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentWithCards.js
More file actions
4241 lines (3670 loc) · 171 KB
/
contentWithCards.js
File metadata and controls
4241 lines (3670 loc) · 171 KB
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
/* content
* - Given a Blackboard page containing a content item with
HTML generated from Mammoth
* - Implement a variety of transformations
* esversion: 6
*/
// Default dates
var TERM = "3191", YEAR = 2019;
const DEFAULT_CARD_LABEL="Module";
// Default reviewed/mark reviewed labels
var MARK_REVIEWED = "Mark Reviewed";
var REVIEWED = "Reviewed";
var DEFAULT_CSS = "https://s3.amazonaws.com/filebucketdave/banner.js/gu_study.css";
var tweak_bb_active_url_pattern = "listContent.jsp";
// Wrap arounds for various types of activity
var READING = `<div class="readingImage"></div>`;
var ACTIVITY = `<div class="activityImage"></div>`;
var NOTE = `<div class="noteImage"></div>`;
//
var EXPAND_COLLAPSE_BUTTON_HTML = `<div class="accordion-expand-holder">
<button class="gu_content_open" style="padding:0.3em 1.2em;margin:0 0.3em 0.3em 0;border-radius:2em;border:2px solid;box-sizing: border-box;text-decoration:none;text-align:center">Expand all</button>
<button class="gu_content_close" style="padding:0.3em 1.2em;margin:0 0.3em 0.3em 0;border-radius:2em;border:2px solid;box-sizing: border-box;text-decoration:none;text-align:center">Collapse all</button>
</div>`;
// simple definition for using pure.css tables
// TODO need to replace this.
var TABLE_CLASS = 'table stripe-row-odd';
// Define way to insert a checkbox that can be clicked
var CHECKBOX = `<input type="checkbox" name="gu_dummy" />`;
// specify Bb links to ensure external links open in new window
var BLAED_LINK = 'bblearn-blaed.griffith.edu.au';
var LMS_LINK = 'bblearn.griffith.edu.au';
var PARAMS = {};
// new global kludges for Cards
var LOCATION = location.href.indexOf("listContent.jsp");
var MODULE_NUM;
var ITEM_LINK_PARAMETERS = {
'Content Document': {
'element': 'wordDocElement',
'item': 'wordDoc'
},
'Film Watching Flow': {
'element': 'filmWatchingOptionsElement',
'item': 'filmWatchingOptionsFlowURL',
},
'cssURL': {
'element': 'cssURLElement',
'item': 'cssURL'
}
};
/****************************************************************************/
/* Main function
* - called from the tweak
*/
function contentInterface($) {
// redefine contains so that it is case insensitive
// Used to match the Blackboard headings
$.expr[":"].contains = $.expr.createPseudo(function (arg) {
return function (elem) {
arg = arg.replace(/\u2013|\u2014/g, "-");
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
/* define variables based on Bb page type */
/* used to identify important components in html */
var tweak_bb_active_url_pattern = "listContent.jsp";
window.tweak_bb = {
display_view: (location.href.indexOf(tweak_bb_active_url_pattern) > 0),
page_id: "#content_listContainer",
row_element: "li"
};
// Add to jQuery a function that will be used to find BbItems that
// match a given title
jQuery.expr[':'].textEquals = jQuery.expr[':'].textEquals || jQuery.expr.createPseudo(function (arg) {
return function (elem) {
arg = arg.replace(/\u2013|\u2014/g, "-");
// Convert emdash type chars to ASCII equivalents
elemText = elem.textContent.trim();
elemText = elemText.replace(/\u2013|\u2014/g, "-");
arg = arg.replace(/[\u201c\u201d]/g, "\"");
elemText = elemText.replace(/[\u201c\u201d]/g, "\"");
//console.log("Compre arg **" + arg + "** with **" + elemText + "**");
return elemText.localeCompare(arg, undefined, {
sensitivity: 'base'
}) === 0;
};
});
// Find the item in which the content is contained
var contentInterface = jQuery(tweak_bb.page_id + " > " + tweak_bb.row_element).find(
".item h3").filter(':contains("Content Interface")').eq(0);
var contentInterface = jQuery(tweak_bb.page_id + " > " + tweak_bb.row_element).find(".item h3").filter( function(x) {
return this.innerText.toLowerCase().includes("content interface");
}
).eq(0);
// Find any Word Document link that's been added
var wordDoc = jQuery(tweak_bb.page_id + " > " + tweak_bb.row_element).find(".item h3").filter(':contains("Content Document")').eq(0);
calculateTerm();
params = checkParams(contentInterface, wordDoc);
// kludge for jQuery each functions
PARAMS = params;
setUpEdit(contentInterface, params);
// check parameters passed in
// Hide the tweak if we're not editing
if (location.href.indexOf("listContent.jsp") > 0) {
$(".gutweak").parents("li").hide();
contentInterface.parents("div.item").hide();
jQuery(wordDoc).hide();
// hide all the items found for ITEM_LINK_PARAMETERS
for (var paramKey in ITEM_LINK_PARAMETERS) {
let elem = ITEM_LINK_PARAMETERS[paramKey].element;
// if we found an item for this param, hide it
if (elem in params) {
jQuery(params[elem]).parents("li").hide();
}
}
} else {
// add the cards for documentation
addCSS(CARDS_CSS);
addJS(FONT_AWESOME_JS);
}
// do nothing if we couldn't find the contentInterface item
if (contentInterface.length === 0) {
return false;
}
// the if isn't required
if ("cssURL" in params) {
addCSS(params.cssURL);
}
changeJqueryTheme( "smoothness");
if ("theme" in params ) {
changeJqueryTheme( params.theme);
}
cleanUpPlaceHolder();
// remove the vtbegenerated class as it's screwing with CSS in the content
// PROBLEM if you do this all the normal styles e.g. <LI> revert to
// an almost empty setting from an earlier Blackboard style sheet.
/*ci = jQuery("#GU_ContentInterface");
vtb = jQuery(ci).parent().parent();//".vtbegenerated");
jQuery(vtb).removeClass("vtbegenerated");*/
// that incldues content from the actual footnote (minus some extra HTML)
handleFootNotes();
jQuery("div.filmWatchingOptions").each(handleFilmWatchingOptions);
// handle the integration of any blackboard headings/items into the
// content interface
jQuery("h1.blackboard").each(handleBlackboardItem);
jQuery("h2.blackboard").each(handleBlackboardItem);
jQuery("span.blackboardContentLink").each(handleBlackboardContentLink);
jQuery("span.blackboardMenuLink").each(handleBlackboardMenuLink);
jQuery("span.universityDate").each(handleUniversityDate);
// Add a <div> </div> around all the content following H1s
jQuery('#GU_ContentInterface h1').each(function () {
// Kludge test for changing colour
title = jQuery(this).text();
jQuery(this).nextUntil('h1').addBack().wrapAll('<div class="accordion_top"></div>');
jQuery(this).nextUntil('h1').wrapAll('<div class="gu-accordion-h1-body"></div>');
});
// Add divs around the h2 headings, until h2 or h1
jQuery('#GU_ContentInterface h2').each(function () {
// console.log( "Heading text " + jQuery(this).html());
jQuery(this).nextUntil('h1,h2').addBack().wrapAll('<div class="accordion"></div>');
jQuery(this).nextUntil('h1,h2').wrapAll('<div class="gu-accordion-h2-body"></div>');
});
// handle footnotes
// - find each footnote reference and replace with a tooltipster element
handleBlackboardCards();
//jQuery("div.bbCard").each( handleBlackboardCards );
// Update all the readings and activities
jQuery("div.activity").prepend(ACTIVITY);
jQuery("div.reading").prepend(READING);
jQuery("div.ael-note").prepend(NOTE);
//updateReadings(contentInterface);
// Handle the blackboard items
// Convert the videos - handled by embed now
//doVideo();
// convert the embed code
var embeds = jQuery(".embed");
embeds.each(function (idx) {
var embed = jQuery(this).html();
var decoded = jQuery("<div/>").html(embed).text();
jQuery(this).html(decoded);
});
// Find all the div.picture and add a <p> </p> around
// text after the image
jQuery("#GU_ContentInterface div.picture").each(function (idx) {
jQuery(this).children('img').after('<br />');
//console.log("Picture found " + jQuery(this).text()) ;
//console.log("Picture found after text " + jQuery(afterImage));
});
jQuery("#GU_ContentInterface div.pictureRight").each(function (idx) {
jQuery(this).children('img').after('<br />');
//console.log("Picture found " + jQuery(this).text()) ;
//console.log("Picture found after text " + jQuery(afterImage));
});
// convert all tables in the content to TABLE_CLASS
// - TODO only add TABLE_CLASS if it doesn't have and div#tableHeading
// or otheers within it
jQuery("#GU_ContentInterface table").addClass(TABLE_CLASS);
// center contents of table cells that contain span class strongCentered
jQuery("#GU_ContentInterface span.strongCentered").each(function (idx) {
if (jQuery(this).parent().parent().is("td")) {
jQuery(this).parent().parent().css('text-align', 'center');
}
});
jQuery("#GU_ContentInterface span.centered").each(function (idx) {
if (jQuery(this).parent().parent().is("td")) {
jQuery(this).parent().parent().css('text-align', 'center');
}
});
// check for any spans class checkbox and replace with checkbox
jQuery("#GU_ContentInterface span.checkbox").each(function (idx) {
//console.log(idx + " found checkbox " + jQuery(this).html());
jQuery(this).html(CHECKBOX);
});
// convert all external links to open in another window
// Also convert blaed links to normal bblean links
jQuery("#GU_ContentInterface a").each(function (idx) {
// check if it's a blackboard link
// but ignore any with class gu-bb-review, these are added for
// review status
linkClass = jQuery(this).attr("class");
if (linkClass === "gu-bb-review") {
return;
}
var theLink = jQuery(this).attr('href');
if (typeof theLink !== 'undefined') {
// replace blaed links with normal links
if (theLink.match(BLAED_LINK) !== null) {
theLink = theLink.replace(BLAED_LINK, LMS_LINK);
jQuery(this).attr('href', theLink);
}
// open external links in a new window i.e. links that don't
// match the LMS or don't have a host portion at the start
if (theLink.match(LMS_LINK) === null && theLink.match(/^\//) === null && theLink.match(/^javascript:mark/) === null) {
jQuery(this).attr('target', '_blank');
// turn off the Blackboard onclick "stuff"
jQuery(this).prop("onclick", null).off("click");
}
}
});
addExpandPrintButtons();
// Apply the jQuery accordion
accordionDisabled = false;
if (params.noAccordion === true) {
// This actually greys out the accordion, rather than not
// using it
//accordionDisabled = true;
}
// check if there is actually an accordion, if not don't go any further
// add and handle the accordion
jQuery(".accordion,.accordion_top").accordion({
collapsible: true,
active: 1,
disabled: accordionDisabled,
navigation: true,
//autoHeight:true
heightStyle: 'content',
activate: function (event, ui) {
if (!$.isEmptyObject(ui.newHeader.offset())) {
$('html:not(:animated), body:not(:animated)').animate({ scrollTop: ui.newHeader.offset().top }, 'slow');
// send resize to ensure that h5p iframe appears correct
// size
window.dispatchEvent(new Event('resize'));
}
}
});
// TODO move this to a string and make it look prettier
var icons = jQuery(".accordion").accordion("option", "icons");
// define the click function for the expand all
jQuery('.gu_content_open').click(function (event) {
event.preventDefault();
jQuery('.ui-accordion-header').removeClass('ui-corner-all').addClass('ui-accordion-header-active ui-state-active ui-corner-top').attr({
'aria-selected': 'true',
'tabindex': '0'
});
jQuery('.ui-accordion-header-icon').removeClass(icons.header).addClass(icons.headerSelected);
jQuery('.ui-accordion-content').addClass('ui-accordion-content-active').attr({
'aria-expanded': 'true',
'aria-hidden': 'false'
}).show();
jQuery(this).attr("disabled", "disabled");
jQuery('.gu_content_close').removeAttr("disabled");
});
// define the click functio for the collapse all
jQuery('.gu_content_close').click(function () {
event.preventDefault();
jQuery('.ui-accordion-header').removeClass('ui-accordion-header-active ui-state-active ui-corner-top').addClass('ui-corner-all').attr({
'aria-selected': 'false',
'tabindex': '-1'
});
jQuery('.ui-accordion-header-icon').removeClass(icons.headerSelected).addClass(icons.header);
jQuery('.ui-accordion-content').removeClass('ui-accordion-content-active').attr({
'aria-expanded': 'false',
'aria-hidden': 'true'
}).hide();
jQuery(this).attr("disabled", "disabled");
jQuery('.gu_content_open').removeAttr("disabled");
});
jQuery('.ui-accordion-header').click(function () {
// if active is true, then we're opening an accordion
// thus save which one it is
let active = this.classList.contains("ui-state-active");
if (active) {
let hrefId = getHrefId( window.location.href );
window.localStorage.setItem(hrefId, this.id);
}
jQuery('.gu_content_open').removeAttr("disabled");
jQuery('.gu_content_close').removeAttr("disabled");
//console.log('click header ' + jQuery(this).html());
});
// figure out which accordion to open
// - by default it is the first 0
// - if an integer is used as a link e.g. #1 or #5
// then open accordion matching that number
// - if paramsObj.collapseAll == true - then none
var start = window.location.hash.substring(1);
var end;
numAccordions = jQuery('.accordion_top').length;
start = parseInt(start, 10) - 1;
if ((!Number.isInteger(start)) || (start > numAccordions - 1)) {
start = 0;
end = 1;
if ( params.scrollTo ){
openWhereYouLeftOff();
}
} else {
end = start + 1;
}
// want all expanded, figure out num accordions and set end appropriately
if (params.expandAll === true) {
start = 0;
end = jQuery('#GU_ContentInterface h1').length;
} else if (params.collapseAll === true) {
start = 0;
end = 0;
} else if (params.expand > 0) {
if (params.expand < jQuery('#GU_ContentInterface h1').length) {
start = params.expand - 1;
end = start + 1;
} else {
console.log("ERROR - expand value (" + params.expand + ") larger than number of heading 1s ");
}
}
//jQuery("#globalNavPageNavArea").scrollTop(0);
if (params.scrollTo) {
jQuery('.accordion_top').slice(start, end).accordion("option", "active", 0);
}
//if ( start === 0 && end === 1) {
//}
// Remove the Content Interface from the vtbegenerated div so that
// Bb CSS doesn't override embedded Card CSS
var journey = jQuery(contentInterface).parent().next('div.details').children('.vtbegenerated');
var child = jQuery(journey).children("#html");
jQuery(child).unwrap();
}
/************************************************************************
* getHrefId( href )
* Given a URL extract the blackboard course and content id and combine
* them into an id (concatentate with a _)
* Return that id.
* Return href
*/
function getHrefId( href ) {
let courseId,contentId;
// get the courseId
m = href.match(/^.*course_id=(_[0-9_]+).*$/);
if ( ! m ){
return href;
}
courseId = m[1];
// get the contentId
m = href.match(/^.*content_id=(_[0-9_]+).*$/);
if ( ! m ){
return href;
}
contentId = m[1];
return courseId + "/" + contentId;
}
/*********************************************************
* openWhereYouLeftOff()
* - check local storage, if we've been here before open the
* accordion that was open last time
*/
function openWhereYouLeftOff() {
// Check to see if
let hrefId = getHrefId( window.location.href );
let storageStart = window.localStorage.getItem(hrefId);
if (typeof storageStart !== 'undefined') {
// want to find the H1 or H2 that has the id in m[1]
let heading = jQuery("h1#" + storageStart + ",h2#" + storageStart);
// do we need to do something different for h2?
// Maybe open the h1 element and then the h2 element?
// but then we want to find the something or other that wraps it
if (heading.length === 1) {
let accord;
let tagName = heading[0].tagName;
if (tagName === 'H1') {
accord = jQuery(heading[0]).parent();
jQuery(accord).accordion("option", "active", 0);
} else {
// if H2, then open the H1 accordion
let p1 = jQuery(heading).parents("div.accordion_top"); // the top level DIV for h1
jQuery(p1).accordion("option", "active", 0);
// now open the H2 accordion
let accordP = jQuery(heading).parent();
jQuery(accordP).accordion("option", "active", 0);
}
}
}
}
//********************************************* */
// handle footnotes
// - find each footnote reference and replace with a tooltipster element
// that incldues content from the actual footnote (minus some extra HTML)
function handleFootNotes() {
const footnote_re = /<a href="#footnote-ref-[0-9]*">.<\/a>/g;
var footnotes = jQuery('#GU_ContentInterface a[id^="footnote-ref-"');
var firstFootNote = '';
footnotes.each(function () {
// get the <sup> item wrapped around footnote
var supItem = jQuery(this).parent();
// get the id for the footnote content (at end of doc)
// footnote-ref-?? becomes
// footnote-??
var footnoteId = jQuery(this).attr("id");
var footnote = "li# " + footnoteId.replace('-ref', '');
footnote = footnote.replace(' ', '');
footnoteContent = jQuery(footnote).html();
if (firstFootNote === '') {
firstFootNote = footnote;
}
// need to remove the return link to the footnote in footnoteContent
var footnoteContent = footnoteContent.replace(footnote_re, '');
// need to remove the link on the footnote reference
var refHtml = jQuery(this).html();
jQuery(this).remove("a");
jQuery(supItem).html(refHtml);
// set the attributes for tooltipster to work
supItem.attr('footNoteId', footnoteId);
supItem.attr('class', 'ci-tooltip');
supItem.attr('data-tooltip-content', footnoteContent);
});
// if there were footnotes, then
if (footnotes.length) {
// add a <h3>Footnotes</h3> heading just before the list of footnote content
var footNoteList = jQuery(firstFootNote).parent();
jQuery(footNoteList).before("<h1>Footnotes</h1>");
//remove the return anchor TODO replace it with something that works
var footNoteListHtml = jQuery(footNoteList).html().replace(footnote_re, '');
jQuery(footNoteList).html(footNoteListHtml);
// add tooltipster if there are footnotes
jQuery("head").append(
"<link id='tooltipstercss' href='https://cdn.jsdelivr.net/npm/tooltipster@4.2.8/dist/css/tooltipster.bundle.min.css' type='text/css' rel='stylesheet' />");
jQuery.getScript(
//"https://cdn.jsdelivr.net/npm/tooltipster@4.2.8/dist/js/tooltipster.bundle.js",
"https://cdn.jsdelivr.net/npm/tooltipster@4.2.8/dist/js/tooltipster.bundle.min.js",
function () {
docWidth = Math.floor(jQuery(document).width() / 2);
jQuery('.ci-tooltip').tooltipster({ 'maxWidth': docWidth });
});
}
}
/***************************************************
* setUpEdit
* - Set up the edit/update process
*/
var HOW_TO = "";
const DOCUMENTATION_LINKS = {
// Getting started
'whatWhy': 'https://djplaner.github.io/Content-Interface-Tweak/background/whatWhy/',
'setUp': 'https://djplaner.github.io/Content-Interface-Tweak/using/setup/',
'createModify': 'https://djplaner.github.io/Content-Interface-Tweak/using/createAndModify/',
// create text
'createText': 'https://djplaner.github.io/Content-Interface-Tweak/creating/textualContent/',
'normalText': 'https://djplaner.github.io/Content-Interface-Tweak/creating/textualContent/#normal-and-the-default-text-style',
'headings': 'https://djplaner.github.io/Content-Interface-Tweak/creating/textualContent/#headings-and-the-accordion-heading-1-style',
'tables': 'https://djplaner.github.io/Content-Interface-Tweak/creating/textualContent/#tables',
'quotes': 'https://djplaner.github.io/Content-Interface-Tweak/creating/textualContent/#quotes',
'referenceLists': 'https://djplaner.github.io/Content-Interface-Tweak/creating/textualContent/#bibliographyreference-lists',
'footnotes': 'https://djplaner.github.io/Content-Interface-Tweak/creating/textualContent/#footnotes',
// create web content
'createWeb': 'https://djplaner.github.io/Content-Interface-Tweak/creating/webContent/',
'images': 'https://djplaner.github.io/Content-Interface-Tweak/creating/webContent/#images',
'links': 'https://djplaner.github.io/Content-Interface-Tweak/creating/webContent/#links',
'embeds': 'https://djplaner.github.io/Content-Interface-Tweak/creating/webContent/#embedding-youtube-videos-and-beyond',
// create university content
'createUniversity': 'https://djplaner.github.io/Content-Interface-Tweak/creating/universityContent/',
'activities': 'https://djplaner.github.io/Content-Interface-Tweak/creating/universityContent/#activities',
'notes': 'https://djplaner.github.io/Content-Interface-Tweak/creating/universityContent/#notes',
'readings': 'https://djplaner.github.io/Content-Interface-Tweak/creating/universityContent/#readings',
'universityDates': 'https://djplaner.github.io/Content-Interface-Tweak/creating/universityContent/#university-dates',
'filmWatching': 'https://djplaner.github.io/Content-Interface-Tweak/creating/universityContent/#film-watch-options',
// create/use Blackboard content
'createBlackboard': 'https://djplaner.github.io/Content-Interface-Tweak/creating/blackboardContent/',
'menuItem': 'https://djplaner.github.io/Content-Interface-Tweak/creating/blackboardContent/#indirect-link-to-a-menu-item-blackboard-menu-link',
'contentItem': 'https://djplaner.github.io/Content-Interface-Tweak/creating/blackboardContent/#indirect-link-to-content-item-blackboard-content-link',
'reviewStatus': 'https://djplaner.github.io/Content-Interface-Tweak/creating/blackboardContent/#integrating-the-blackboard-review-status-feature',
'adaptiveRelease': 'https://djplaner.github.io/Content-Interface-Tweak/creating/blackboardContent/#using-the-adaptive-release-function',
// customise
'accordionOpen': 'https://djplaner.github.io/Content-Interface-Tweak/customising/accordionOpening/',
'accordionAppearance': 'https://djplaner.github.io/Content-Interface-Tweak/customising/accordionAppearance/',
'contentAppearance': 'https://djplaner.github.io/Content-Interface-Tweak/customising/contentAppearance/'
}
var UPDATE_HTML = () => `
<style>
#gu_nopadding{
padding-left: 1em;
margin-top: 0;
}
</style>
<div class="mx-auto border-none box-content px-4 py-2">
<div class="flex flex-wrap -mx-1 lg:-mx-4 p-0">
<div class="my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3">
<article class="overlow-hidden rounded-lg shadow-lg h-full">
<header class="flex items-center justify-between leading-tight p-2 md:p-4 border-b">
<h1 class="text-lg">
How to update the content
</h1>
</header>
<div class="p-2 md:p-4">
${HOW_TO}
</div>
</article>
</div>
<div class="my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3">
<article class="overlow-hidden rounded-lg shadow-lg h-full">
<header class="flex items-center justify-between leading-tight p-2 md:p-4 border-b">
<h1 class="text-lg">
<i class="fa fa-exclamation-triangle text-red"></i>
No changes to this item
</h1>
</header>
<div class="p-2 md:p-4">
<p>Any changes to this item will stop the Content Interface from working.</p>
</div>
</article>
</div>
<div class="my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3">
<article class="overlow-hidden rounded-lg shadow-lg h-full">
<header class="flex items-center justify-between leading-tight p-2 md:p-4 border-b">
<h1 class="text-lg">
<i class="fa fa-exclamation-triangle text-red"></i>
Do not hide this item
</h1>
</header>
<div class="p-2 md:p-4">
<p>If you make this item unavailable to students, the Content Interface will not work for them.</p>
<p>This item is only visible when <a href="https://elearn.southampton.ac.uk/blackboard/quickedit/">Edit Mode</a> is on. i.e. typically only visible to teaching staff.</p>
</div>
</article>
</div>
</div>
</div>
`;
var WORD_DOC_PRESENT = `
<ol>
<li> Make any changes to the Content document, either <a id="gu_doc" target="_blank" href="http://griffith.edu.au">online</a> or directly.</li>
<li> Click the green button to <button style="background-color: #4CAF50; border: none; color: white; padding: 5px 5px; text-align: center; text-decoration: none; display: inline-block; border-radius: 12px" type="button" id="guUpdate">Update Content Interface</button> </li>
</ol>
`;
var WORD_DOC_NOT_PRESENT = `<ol>
<li>Make any change in the matching Word document.</li>
<li><a href="https://djon.es/gu/mammoth.js/browser-demo/" target="_blank" rel="noreferrer noopener">Convert the Word document into HTML</a>.</li>
<li>Copy and paste the HTML into {EDIT_CONTENT_ITEM}. <br />
<p>See this <a href="http://www.bu.edu/tech/services/teaching/lms/blackboard/how-to/copypaste-into-blackboard-learn/">explanation on how to copy and paste HTML</a> into Blackboard content items.</p>
</li>
</ol>
<p>To semi-automate this process, you can:</p>
<ol>
<li> Share the Word document via OneDrive or Sharepoint and copy the share URL.<br />(<a href="https://support.office.com/en-us/article/share-a-document-using-sharepoint-or-onedrive-807de6cf-1ece-41b9-a2b3-250d9a48f1e8">How to share a document using SharePoint or OneDrive</a>) </li>
<li> Create a <em>Web Link</em> item on this page using the name <em>Content Document</em> and the URL as the shared URL created in the first step.<br />(<a href="https://help.blackboard.com/Learn/Instructor/Course_Content/Create_Content/Create_Course_Materials/Link_to_Websites">How to create a Web Link item in Blackboard</a>) </li>
</ol>
`;
var CONTENT_INTERFACE_NOT_PRESENT = `
<h3>Missing Content Interface item</h3>
<p>Unable to find a content item on this page with <strong>Content Interface</strong> in the title.</p>
<p>Such a content item is required before the Content Interface tweak can function.</p>
`;
var OLD_INSTRUCTIONS = `
<h3>Detailed documentation</h3>
<p>See <a href="https://griffitheduau-my.sharepoint.com/:w:/g/personal/d_jones6_griffith_edu_au/EUbAQvhxLW1MicRKf9Hof3sBIoS2EyJP_SfkYbqZ7c3qhw?e=2S9k3Y" target="_blank" rel="noreferrer noopener">this Word document</a> for more detailed documentation on creating and changing content.</p>
`;
var INSTRUCTIONS = `
<h3>How do I...</h3>
<div class="box-content mx-auto border-none h-auto py-0 px-4 m-0">
<div class="flex flex-wrap -mx-1 lg:-mx-4">
<div class="my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3">
<article class="overlow-hidden rounded-lg shadow-lg h-full">
<header class="flex items-center justify-between leading-tight p-2 md:p-4 border-b">
<h1 class="text-lg">
Get started
</h1>
</header>
<div class="p-2 md:p-4">
<p><a target="_blank" href="${DOCUMENTATION_LINKS.whatWhy}">
Content Interface: what and why</a></p>
<p>How to...</p>
<ul id="gu_nopadding">
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.setUp}">
set it up in Blackboard</a> </li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.createModify}">
create and modify content</a> (an overview) </li>
</ul>
</div>
</article>
</div>
<div class="my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3">
<article class="overlow-hidden rounded-lg shadow-lg h-full">
<header class="flex items-center justify-between leading-tight p-2 md:p-4 border-b">
<h1 class="text-lg">
Create <a href="${DOCUMENTATION_LINKS.createText}">
text content</a>
</h1>
</header>
<div class="p-2 md:p-4">
<ul id="gu_nopadding">
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.normalText}">
normal text content</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.headings}">
headings</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.tables}">
tables</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.quotes}">
quotes</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.referenceLists}">
reference lists</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.footnotes}">
footnotes</a>
</li>
</ul>
</div>
</article>
</div>
<div class="my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3">
<article class="overlow-hidden rounded-lg shadow-lg h-full">
<header class="flex items-center justify-between leading-tight p-2 md:p-4 border-b">
<h1 class="text-lg">
Create <a href="${DOCUMENTATION_LINKS.createWeb}">web content</a>
</h1>
</header>
<div class="p-2 md:p-4">
<ul id="gu_nopadding">
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.images}">
Images
</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.links}">
Links
</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.embeds}">
Embedding videos and more
</a>
</li>
</li>
</ul>
</div>
</article>
</div>
<div class="my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3">
<article class="overlow-hidden rounded-lg shadow-lg h-full">
<header class="flex items-center justify-between leading-tight p-2 md:p-4 border-b">
<h1 class="text-lg">
Create University content
</h1>
</header>
<div class="p-2 md:p-4">
<ul id="gu_nopadding">
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.activities}">
Activities
</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.notes}">
Notes
</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.readings}">
Readings
</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.universityDates}">
Trimester (university) dates
</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.filmWatching}">
Film Watching Options
</a>
</li>
</ul>
</div>
</article>
</div>
<div class="my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3">
<article class="overlow-hidden rounded-lg shadow-lg h-full">
<header class="flex items-center justify-between leading-tight p-2 md:p-4 border-b">
<h1 class="text-lg">
Use Blackboard items and features
</h1>
</header>
<div class="p-2 md:p-4">
How do you...
<ul id="gu_nopadding">
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.menuItem}">
link to a Blackboard Menu item
</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.contentItem}">
link to a Blackboard content item
</a>
</li>
<li>
use <a target="_blank" href="${DOCUMENTATION_LINKS.reviewStatus}">
review status</a>
</li>
<li>
use <a target="_blank" href="${DOCUMENTATION_LINKS.adaptiveRelease}">
adaptive release</a>
</li>
</ul>
</div>
</article>
</div>
<div class="my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3">
<article class="overlow-hidden rounded-lg shadow-lg h-full">
<header class="flex items-center justify-between leading-tight p-2 md:p-4 border-b">
<h1 class="text-lg">
Customise the interface
</h1>
</header>
<div class="p-2 md:p-4">
How do you customise...
<ul id="gu_nopadding">
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.accordionOpen}">
which accordion opens first
</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.accordionAppearance}">
the accordion theme
</a>
</li>
<li> <a target="_blank" href="${DOCUMENTATION_LINKS.contentAppearance}">
appearance of the content
</a>
</li>
</ul>
</div>
</article>
</div>
</div>
</div>
</div> <!-- end gu_ci_instructions -->
`;
var CHANGE_TEMPLATE = `
<h3>Choosing a different template</h3>
<p>Different templates are available to change the look and feel of the Content Interface.</p>
<p>There is a two step process:</p>
<ol>
<li> Select one of the available style templates from the following list.</p>
<select name="styleSelector" id="styleSelector">
<option value="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">Base</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/start/jquery-ui.css">Start</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css" selected="selected">Smoothness</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/redmond/jquery-ui.css">Redmond</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/sunny/jquery-ui.css">Sunny</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/overcast/jquery-ui.css">Overcast</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/flick/jquery-ui.css">Flick</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/pepper-grinder/jquery-ui.css">Pepper Grinder</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/ui-lightness/jquery-ui.css">UI Lightness</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/ui-darkness/jquery-ui.css">UI Darkness</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/le-frog/jquery-ui.css">Le Frog</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/eggplant/jquery-ui.css">Eggplant</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/dark-hive/jquery-ui.css">Dark Hive</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/cupertino/jquery-ui.css">Cupertino</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/blitzer/jquery-ui.css">Blitzer</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/south-street/jquery-ui.css">South Street</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/humanity/jquery-ui.css">Humanity</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/hot-sneaks/jquery-ui.css">Hot Sneaks</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/excite-bike/jquery-ui.css">Excite Bike</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/vader/jquery-ui.css">Vader</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/black-tie/jquery-ui.css">Black Tie</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/trontastic/jquery-ui.css">Trontastic</option>
<option value="https://code.jquery.com/ui/1.12.1/themes/swanky-purse/jquery-ui.css">Swanky Purse</option>
</select>
</li>
<li> Modify the tweak code to use the selected template.
<p>To do this you need to:</p>
<ol>
<li> Edit this item. </li>
<li> Hit the HTML button on the Blackboard editor.</li>
<li>Find the following line (bold added)
<p><link rel="<span class=" mceitemhiddenspellword="" /><p><link rel="stylesheet" id="gu_jqueryStyle" href="<strong>//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css</strong>" /></p></p>
</li>
<li>Replace the bold string with <strong><span id="gu_stylePath">https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css</span></strong></li>
<li> Save the changes. </li>
</ol>
`;
function setUpEdit(ci, params) {
//------------------------------------------------
// Check to see if the Content Interface item contains details
// about the Word document
// - NO - show a message without update button
// - YES - add the update button
// does ci contain a path
// -- currently implemented as a span with id gu_WordDocument that
// will contain a simple path (probably only works for me)
// -- eventually should be a link that works for all with access
current = window.location.href;
var courseId;
var contentId;
m = current.match(/^.*course_id=(_[^&#]*).*$/);
if (m) {
courseId = m[1];
}
//console.log("course id " + courseId);
// get the content id
contentId = jQuery(ci).parent().attr("id");
// if no content id then change display
if (typeof contentId === 'undefined') {
jQuery('#gu_update').html(CONTENT_INTERFACE_NOT_PRESENT);
return;
}
// Has a link to the word doc been shared
var path = params.wordDoc;
if (typeof path === 'undefined') {
// Word document is not defined
HOW_TO = WORD_DOC_NOT_PRESENT;
let html = UPDATE_HTML() + INSTRUCTIONS;
// add in link to edit the content item
var editContent = 'into the <a href="https://bblearn-blaed.griffith.edu.au/webapps/blackboard/execute/manageCourseItem?content_id=' + contentId + '&course_id=' + courseId + '&dispatch=edit">Content Interface content item</a>';
html = html.replace("{EDIT_CONTENT_ITEM}", editContent);
// console.log("edit content item is " + editContent);
jQuery('#gu_update').html(html);
return;
}
//jQuery(".gu_docNotPresent").hide();
HOW_TO = WORD_DOC_PRESENT;
let updateHtml = UPDATE_HTML() + INSTRUCTIONS;
if (jQuery('#gu_jqueryStyle').length) {
updateHtml = updateHtml + CHANGE_TEMPLATE;
}
jQuery('#gu_update').html(updateHtml);
jQuery("#gu_doc").attr("href", path);
// remove #6 type links from end of path (breaks conversion)
//console.log( "path was " + path );
path = path.replace(/#[0-9]*$/, '');
// console.log( "path is " + path );
// encode path ready for going via URLs
path = "u!" + btoa(path).replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, '');
//---------------------------------------------------