-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
89 lines (78 loc) · 2.04 KB
/
main.js
File metadata and controls
89 lines (78 loc) · 2.04 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
/**
* AgentFramework.dev - Main JavaScript
*/
(function () {
'use strict';
/**
* Set the current year in the copyright notice
*/
function setCurrentYear() {
var yearElement = document.getElementById('current-year');
if (yearElement) {
yearElement.textContent = new Date().getFullYear();
}
}
/**
* Shuffle an array using Fisher-Yates algorithm
* @param {Array} array - The array to shuffle
* @returns {Array} - The shuffled array
*/
function shuffleArray(array) {
var shuffled = array.slice();
for (var i = shuffled.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = shuffled[i];
shuffled[i] = shuffled[j];
shuffled[j] = temp;
}
return shuffled;
}
/**
* Randomize the order of an element's direct children
* @param {string} elementId - The id of the element to randomize
*/
function randomizeElementChildren(elementId) {
var element = document.getElementById(elementId);
if (!element) {
return;
}
var items = Array.prototype.slice.call(element.children);
var shuffled = shuffleArray(items);
shuffled.forEach(function (item) {
element.appendChild(item);
});
}
/**
* Randomize the order of instructor list items
*/
function randomizeInstructors() {
randomizeElementChildren('instructor-list');
}
/**
* Randomize the order of community partner cards
*/
function randomizeCommunityPartners() {
randomizeElementChildren('community-partners-grid');
}
/**
* Randomize the order of past sponsor cards
*/
function randomizePastSponsors() {
randomizeElementChildren('past-sponsors-grid');
}
/**
* Initialize all functionality when DOM is ready
*/
function init() {
setCurrentYear();
randomizeInstructors();
randomizeCommunityPartners();
randomizePastSponsors();
}
// Run initialization when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();