From 8caf424c5ea5267c733ab90bc4ac24119639bead Mon Sep 17 00:00:00 2001 From: Ken Irwin Date: Tue, 30 Aug 2022 16:28:29 -0400 Subject: [PATCH 1/8] add libcal-sorter.js --- LibCal/JS/libcal-sorter.js | 91 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 LibCal/JS/libcal-sorter.js diff --git a/LibCal/JS/libcal-sorter.js b/LibCal/JS/libcal-sorter.js new file mode 100644 index 0000000..e5a7186 --- /dev/null +++ b/LibCal/JS/libcal-sorter.js @@ -0,0 +1,91 @@ +/* + * This script adds a button to certain LibCal equipment pages. + * The button will sort the display of availability so that items + * with more availability float to the top. + * Note: this does NOT sort the left-hand column (items) so this method + * is only suitable when all the items are the same (e.g. a pool of software + * licenses). It will not work if the items are unique (such as study rooms) + * or if the items are subdivided into groups (also like study rooms in some + * cases. + * + * Currently, this is only used for Software Checkout. + */ + +$(document).ready(function () { + /* Section 0: Configuration */ + // urls for pages on which to show the sort button + + let urlsShowSort = [ + 'equipment/item/105059', // Final Cut + 'equipment/item/115969', // Logic Pro + 'equipment/item/61121', // Adobe Creative Cloud + 'equipment/item/141114', // test page + '?lid=8370', // all Library Software Checkout pages + 'lid=16728', // test page + ]; + + /* Section 1: set showSort based on url matching */ + + showSort = false; + urlsShowSort.forEach(function (groupId) { + if (window.location.href.indexOf(groupId) > -1) { + showSort = true; + } + }); + // console.log(showSort); + + /* Section 2: add sort button when time grid appears */ + function listenForTimeGrid() { + if ($('.fc-timeline-slots').length > 0) { + addSortButton(); + // console.log('time grid found'); + } else { + setTimeout(listenForTimeGrid, 500); + } + } + listenForTimeGrid(); + + /* Section 3: Add sort button */ + function addSortButton() { + let sortIcon = + ''; + $('#time_grid_cont').prepend( + '

' + + sortIcon + + ' Sort by availability

' + ); + $('#sort-by-avail').bind('click', function () { + sortByAvailability(); + }); + } + + /* Section 4: Sort by availability */ + function sortByAvailability() { + addAvailCounts(); + sortByAvial(); + } + + function addAvailCounts() { + $('div.fc-timeline-lane-frame').each(function (index, el) { + $(this) + .closest('tr') + .attr('data-avail-count', getAvailCount(el)) + .addClass('sortable'); + }); + } + + function getAvailCount(el) { + return $(el).find('a.s-lc-eq-avail').length; + } + + function sortByAvial() { + let entries = $('tr.sortable'); + let tbody = $('tr.sortable:first').closest('tbody'); + $('tr.sortable').remove(); + entries + .sort(function (a, b) { + return $(b).attr('data-avail-count') - $(a).attr('data-avail-count'); + }) + .appendTo(tbody); + } +}); From 2557c865c2a9aab790f5125938896130ebc93ffb Mon Sep 17 00:00:00 2001 From: Ken Irwin Date: Tue, 30 Aug 2022 16:31:17 -0400 Subject: [PATCH 2/8] rename libcal-css-july21 to libcal-css.html --- LibCal/{libcal-css-july21.html => libcal-css.html} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LibCal/{libcal-css-july21.html => libcal-css.html} (100%) diff --git a/LibCal/libcal-css-july21.html b/LibCal/libcal-css.html similarity index 100% rename from LibCal/libcal-css-july21.html rename to LibCal/libcal-css.html From a3ff89f1745132740b4ed0e096d5decdfff11e21 Mon Sep 17 00:00:00 2001 From: Ken Irwin Date: Tue, 30 Aug 2022 16:33:15 -0400 Subject: [PATCH 3/8] renamed main libcal settings as undated files --- LibCal/{libcal-footer-july21.html => libcal-footer.html} | 0 LibCal/{libcal-header-july21.html => libcal-header.html} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename LibCal/{libcal-footer-july21.html => libcal-footer.html} (100%) rename LibCal/{libcal-header-july21.html => libcal-header.html} (100%) diff --git a/LibCal/libcal-footer-july21.html b/LibCal/libcal-footer.html similarity index 100% rename from LibCal/libcal-footer-july21.html rename to LibCal/libcal-footer.html diff --git a/LibCal/libcal-header-july21.html b/LibCal/libcal-header.html similarity index 100% rename from LibCal/libcal-header-july21.html rename to LibCal/libcal-header.html From bf9064a14acdbd9b65168a6ed9565175276c2eea Mon Sep 17 00:00:00 2001 From: Ken Irwin Date: Tue, 30 Aug 2022 16:35:08 -0400 Subject: [PATCH 4/8] created "old versions" folder with older libcal css, footer, header --- LibCal/old versions/libcal-css-july2021.html | 1212 +++++++++++++++++ .../old versions/libcal-footer-july2021.html | 63 + .../old versions/libcal-header-july2021.html | 200 +++ 3 files changed, 1475 insertions(+) create mode 100644 LibCal/old versions/libcal-css-july2021.html create mode 100644 LibCal/old versions/libcal-footer-july2021.html create mode 100644 LibCal/old versions/libcal-header-july2021.html diff --git a/LibCal/old versions/libcal-css-july2021.html b/LibCal/old versions/libcal-css-july2021.html new file mode 100644 index 0000000..a8f6f2a --- /dev/null +++ b/LibCal/old versions/libcal-css-july2021.html @@ -0,0 +1,1212 @@ + + + + + + + diff --git a/LibCal/old versions/libcal-footer-july2021.html b/LibCal/old versions/libcal-footer-july2021.html new file mode 100644 index 0000000..a52dd85 --- /dev/null +++ b/LibCal/old versions/libcal-footer-july2021.html @@ -0,0 +1,63 @@ + diff --git a/LibCal/old versions/libcal-header-july2021.html b/LibCal/old versions/libcal-header-july2021.html new file mode 100644 index 0000000..ff3a2ba --- /dev/null +++ b/LibCal/old versions/libcal-header-july2021.html @@ -0,0 +1,200 @@ + From 1da3cf966476965eab900fff4005beadfe512ded Mon Sep 17 00:00:00 2001 From: Ken Irwin Date: Tue, 30 Aug 2022 16:37:29 -0400 Subject: [PATCH 5/8] add LibCal sorting to libcal-css (js) --- LibCal/libcal-css.html | 146 ++++++++++++++++++++++++++++++----------- 1 file changed, 109 insertions(+), 37 deletions(-) diff --git a/LibCal/libcal-css.html b/LibCal/libcal-css.html index a8f6f2a..0afe6b8 100644 --- a/LibCal/libcal-css.html +++ b/LibCal/libcal-css.html @@ -1,12 +1,11 @@ - - - From 0b260cd7514d7dd880aa9d4cd69c6b2d8a76e04e Mon Sep 17 00:00:00 2001 From: Ken Irwin Date: Tue, 30 Aug 2022 16:39:49 -0400 Subject: [PATCH 6/8] updated libcal header to current file --- LibCal/libcal-header.html | 360 +++++++++++++++++++------------------- 1 file changed, 180 insertions(+), 180 deletions(-) diff --git a/LibCal/libcal-header.html b/LibCal/libcal-header.html index ff3a2ba..1906e45 100644 --- a/LibCal/libcal-header.html +++ b/LibCal/libcal-header.html @@ -1,200 +1,200 @@ +
  • COVID-19 (novel coronavirus) updates and resources
  • + + + + + + + + + + From 9cca901a9e75d7db4089677e3776fb1632c39ed1 Mon Sep 17 00:00:00 2001 From: Ken Irwin Date: Tue, 30 Aug 2022 16:40:38 -0400 Subject: [PATCH 7/8] updated libcal-footer to current --- LibCal/libcal-footer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibCal/libcal-footer.html b/LibCal/libcal-footer.html index a52dd85..dcc36f9 100644 --- a/LibCal/libcal-footer.html +++ b/LibCal/libcal-footer.html @@ -60,4 +60,4 @@ - + \ No newline at end of file From 57c2183d4bff79d2d95a59395bb3f013755e6409 Mon Sep 17 00:00:00 2001 From: Ken Irwin Date: Tue, 17 Sep 2024 16:19:15 -0400 Subject: [PATCH 8/8] update libcal-sorter -- fix typo, only show button on showSort, add new softwarecheckout ids --- LibCal/JS/libcal-sorter.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/LibCal/JS/libcal-sorter.js b/LibCal/JS/libcal-sorter.js index e5a7186..fd8132d 100644 --- a/LibCal/JS/libcal-sorter.js +++ b/LibCal/JS/libcal-sorter.js @@ -18,7 +18,10 @@ $(document).ready(function () { let urlsShowSort = [ 'equipment/item/105059', // Final Cut 'equipment/item/115969', // Logic Pro + 'equipment/item/170804', // Procreate 'equipment/item/61121', // Adobe Creative Cloud + 'equipment/item/82764', // Adobe for Fac/Staff + 'equipment/item/172159', // Acrobat for Fac/Staff 'equipment/item/141114', // test page '?lid=8370', // all Library Software Checkout pages 'lid=16728', // test page @@ -36,7 +39,7 @@ $(document).ready(function () { /* Section 2: add sort button when time grid appears */ function listenForTimeGrid() { - if ($('.fc-timeline-slots').length > 0) { + if ($('.fc-timeline-slots').length > 0 && showSort) { addSortButton(); // console.log('time grid found'); } else { @@ -62,7 +65,7 @@ $(document).ready(function () { /* Section 4: Sort by availability */ function sortByAvailability() { addAvailCounts(); - sortByAvial(); + sortByAvail(); } function addAvailCounts() { @@ -78,7 +81,7 @@ $(document).ready(function () { return $(el).find('a.s-lc-eq-avail').length; } - function sortByAvial() { + function sortByAvail() { let entries = $('tr.sortable'); let tbody = $('tr.sortable:first').closest('tbody'); $('tr.sortable').remove();