PageSourceSearch

https://www.umb.edu/media/umassboston/site-assets/javascript/automated-faculty-staff-list-jquery-sort.js

js umb.edu collected 2026-09-24 08:27:07 UTC 10,427 bytes, 259 lines download raw bytes

1/* source and destination classes jquery */
2/* */
3jQuery('.staff-div.source-non-listed-faculty-1').appendTo('div.destination-full-time-faculty-1');
4jQuery('.staff-div.source-non-listed-faculty-2').appendTo('div.destination-full-time-faculty-2');
5jQuery('.staff-div.source-non-listed-faculty-3').appendTo('div.destination-full-time-faculty-3');
6jQuery('.staff-div.source-non-listed-faculty-4').appendTo('div.destination-full-time-faculty-4');
7jQuery('.staff-div.source-non-listed-faculty-5').appendTo('div.destination-full-time-faculty-5');
8jQuery('.staff-div.source-non-listed-faculty-6').appendTo('div.destination-full-time-faculty-6');
9
10/* automated faculty list order js */
11  $(".auto-list-1col-group .auto-list-1col, .auto-list-2col-group .auto-list-2col, .auto-list-1col-group .auto-list-1col .destination-full-time-faculty-1, .auto-list-2col-group .auto-list-2col .destination-full-time-faculty-1, .auto-list-1col-group .auto-list-1col .destination-full-time-faculty-2, .auto-list-2col-group .auto-list-2col .destination-full-time-faculty-2, .auto-list-1col-group .auto-list-1col .destination-full-time-faculty-3, .auto-list-2col-group .auto-list-2col .destination-full-time-faculty-3, .auto-list-1col-group .auto-list-1col .destination-full-time-faculty-4, .auto-list-2col-group .auto-list-2col .destination-full-time-faculty-4, .auto-list-1col-group .auto-list-1col .destination-full-time-faculty-5, .auto-list-2col-group .auto-list-2col .destination-full-time-faculty-5, .auto-list-1col-group .auto-list-1col .destination-full-time-faculty-6, .auto-list-2col-group .auto-list-2col .destination-full-time-faculty-6").each(function() {
12    $(this).find('div.staff-div').sort(function(a, b) {
13      var aText = $(a).text(),
14        bText = $(b).text();
15      return aText < bText ? -1 : aText > bText ? 1 : 0;
16    }).appendTo(this);
17  });
18
19
20//for list-only
21$(document).ready(function () {
22    // Move and sort li elements inside .auto-list-1col-group .auto-list-1col
23    //1
24    function moveAndSortListItems1() {
25        let $destinationList1 = $("ul.destination-full-time-faculty-1");
26        let $sourceItems1 = $("li.staff-list.source-non-listed-faculty-1");
27
28        if ($destinationList1.length) {
29            // Move elements to destination
30            $sourceItems1.appendTo($destinationList1);
31
32            // Sort li elements alphabetically
33            let $listItems1 = $destinationList1.children("li.staff-list");
34            $listItems1.sort(function (a, b) {
35                return $(a).text().localeCompare($(b).text());
36            });
37
38            // Append sorted elements back
39            $destinationList1.append($listItems1);
40        }
41    }
42    //2
43    function moveAndSortListItems2() {
44        let $destinationList2 = $("ul.destination-full-time-faculty-2");
45        let $sourceItems2 = $("li.staff-list.source-non-listed-faculty-2");
46
47        if ($destinationList2.length) {
48            // Move elements to destination
49            $sourceItems2.appendTo($destinationList2);
50
51            // Sort li elements alphabetically
52            let $listItems2 = $destinationList2.children("li.staff-list");
53            $listItems2.sort(function (a, b) {
54                return $(a).text().localeCompare($(b).text());
55            });
56
57            // Append sorted elements back
58            $destinationList2.append($listItems2);
59        }
60    }
61    //3
62    function moveAndSortListItems3() {
63        let $destinationList3 = $("ul.destination-full-time-faculty-3");
64        let $sourceItems3 = $("li.staff-list.source-non-listed-faculty-3");
65
66        if ($destinationList3.length) {
67            // Move elements to destination
68            $sourceItems3.appendTo($destinationList3);
69
70            // Sort li elements alphabetically
71            let $listItems3 = $destinationList3.children("li.staff-list");
72            $listItems3.sort(function (a, b) {
73                return $(a).text().localeCompare($(b).text());
74            });
75
76            // Append sorted elements back
77            $destinationList3.append($listItems3);
78        }
79    }
80    //1
81    function moveAndSortListItems4() {
82        let $destinationList4 = $("ul.destination-full-time-faculty-4");
83        let $sourceItems4 = $("li.staff-list.source-non-listed-faculty-4");
84
85        if ($destinationList4.length) {
86            // Move elements to destination
87            $sourceItems4.appendTo($destinationList4);
88
89            // Sort li elements alphabetically
90            let $listItems4 = $destinationList4.children("li.staff-list");
91            $listItems4.sort(function (a, b) {
92                return $(a).text().localeCompare($(b).text());
93            });
94
95            // Append sorted elements back
96            $destinationList4.append($listItems4);
97        }
98    }
99    //5
100    function moveAndSortListItems5() {
101        let $destinationList5 = $("ul.destination-full-time-faculty-5");
102        let $sourceItems5 = $("li.staff-list.source-non-listed-faculty-5");
103
104        if ($destinationList5.length) {
105            // Move elements to destination
106            $sourceItems5.appendTo($destinationList5);
107
108            // Sort li elements alphabetically
109            let $listItems5 = $destinationList5.children("li.staff-list");
110            $listItems5.sort(function (a, b) {
111                return $(a).text().localeCompare($(b).text());
112            });
113
114            // Append sorted elements back
115            $destinationList5.append($listItems5);
116        }
117    }
118    //6
119    function moveAndSortListItems6() {
120        let $destinationList6 = $("ul.destination-full-time-faculty-6");
121        let $sourceItems6 = $("li.staff-list.source-non-listed-faculty-6");
122
123        if ($destinationList6.length) {
124            // Move elements to destination
125            $sourceItems6.appendTo($destinationList6);
126
127            // Sort li elements alphabetically
128            let $listItems6 = $destinationList6.children("li.staff-list");
129            $listItems6.sort(function (a, b) {
130                return $(a).text().localeCompare($(b).text());
131            });
132
133            // Append sorted elements back
134            $destinationList6.append($listItems6);
135        }
136    }
137
138    moveAndSortListItems1();
139    moveAndSortListItems2();
140    moveAndSortListItems3();
141    moveAndSortListItems4();
142    moveAndSortListItems5();
143    moveAndSortListItems6();
144});
145
146
147/**/
148$(".social-list-1col-group .social-list-1col, .social-media-directory-group .social-media-list").each(function() { 
149    $(this).find('div.social-media-box').sort(function(a, b) {
150      var aText = $(a).text(),
151        bText = $(b).text();
152      return aText < bText ? -1 : aText > bText ? 1 : 0;
153    }).appendTo(this);
154  });
155/* new social media directory jquery */
156/*
157$(document).ready(function () {
158    var $uls = $("ul.social-media-directory-ul").toArray(); // Convert UL elements to an array
159    $uls.sort(function (a, b) {
160        var firstLiA = $(a).children("li").first().text().trim();
161        var firstLiB = $(b).children("li").first().text().trim();
162        return firstLiA.localeCompare(firstLiB); // Compare based on first LI text
163    });
164    $("div.social-media-directory-links").append($uls); // Append sorted ULs back to the body (or a container element)
165});
166*/
167/* newer social media directory jquery */
168$(document).ready(function () {
169    var $uls_academics = $("ul.social-media-directory-ul-academics").toArray(); // Convert UL elements to an array
170    $uls_academics.sort(function (a, b) {
171        var firstLiA = $(a).children("li").first().text().trim();
172        var firstLiB = $(b).children("li").first().text().trim();
173        return firstLiA.localeCompare(firstLiB); // Compare based on first LI text
174    });
175    $("div.social-media-directory-links-academics").append($uls_academics); // Append sorted ULs back to the body (or a container element)
176});
177$(document).ready(function () {
178    var $uls_campus_life = $("ul.social-media-directory-ul-campus-life").toArray(); // Convert UL elements to an array
179    $uls_campus_life.sort(function (a, b) {
180        var firstLiA = $(a).children("li").first().text().trim();
181        var firstLiB = $(b).children("li").first().text().trim();
182        return firstLiA.localeCompare(firstLiB); // Compare based on first LI text
183    });
184    $("div.social-media-directory-links-campus-life").append($uls_campus_life); // Append sorted ULs back to the body (or a container element)
185});
186$(document).ready(function () {
187    var $uls_ci = $("ul.social-media-directory-ul-ci").toArray(); // Convert UL elements to an array
188    $uls_ci.sort(function (a, b) {
189        var firstLiA = $(a).children("li").first().text().trim();
190        var firstLiB = $(b).children("li").first().text().trim();
191        return firstLiA.localeCompare(firstLiB); // Compare based on first LI text
192    });
193    $("div.social-media-directory-links-ci").append($uls_ci); // Append sorted ULs back to the body (or a container element)
194});
195
196
197/* 
198//previously used
199
200$(document).ready(function() {
201  // Get all the div elements with class 'item' inside the container
202  var items = $('.social-media-list .social-media-box').get();
203  // Sort the divs alphabetically based on the text content
204  items.sort(function(a, b) {
205    var textA = $(a).text().toUpperCase();
206    var textB = $(b).text().toUpperCase();
207    
208    return textA.localeCompare(textB);
209  });
210  // Append the sorted divs back to the container
211  $.each(items, function(index, item) {
212    $('.social-media-list').append(item);
213  });
214});
215
216*/
217
218/* show more */
219/* 
220$(document).ready(function() {
221  // Initially hide all items except the first 10
222  $('.social-media-list .social-media-box').slice(10).hide(); // Hide items from the 4th onward
223
224  // Show more items when the button is clicked
225  $('#show-more').click(function() {
226    var hiddenItems = $('.social-media-list .social-media-box:hidden'); // Find hidden items
227    hiddenItems.slice(0, 10).show(); // Show the next 10 hidden items
228
229    // If all items are shown, hide the button
230    if ($('.social-media-list .social-media-box:hidden').length === 0) {
231      //$('#show-more').hide();
232      //$('span.button.social').hide();
233      $('span#show-more').hide();
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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.