forked from sugarlabs/www
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
executable file
·161 lines (150 loc) · 5.57 KB
/
main.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
$(document).ready(function () {
// Colour changing affect of logo and donation banner
var COLORS = [['006E00', '78E600'], ['68008C', '78E600'],
['006E00', '00BEFF'], ['033CD2', '00BEFF'],
['6E008C', '00BEFF'], ['A00000', 'FF7800'],
['033CD2', 'FF64D2'], ['6E008C', 'FF64D2'],
['6E008C', 'FF7800'], ['033CD2', 'FF7800'],
['006E00', 'FFD732'], ['6E008C', 'FFD732']];
//select random colors
var colorIndex = Math.floor((Math.random() * 12));
var selectedColors = COLORS[colorIndex];
//Apply selected colors to the Sugarlabs logo
var logoID = colorIndex + 1;
if (logoID < 10) {
logoID = "0" + logoID;
}
var defaultIcon = document.querySelector('#defaultIcon1');
if (defaultIcon) {
// Use absolute path for favicon
var faviconPath = '/assets/favicon_' + logoID + '.png';
// Test if favicon exists before setting
var img = new Image();
img.onload = function() {
defaultIcon.href = faviconPath;
};
img.onerror = function() {
// Fallback to default favicon
defaultIcon.href = '/assets/favicon.png';
};
img.src = faviconPath;
}
var h = document.querySelector('.logo1').innerHTML;
h = h.replace(/033cd2/g, selectedColors[0]);
h = h.replace(/78e600/g, selectedColors[1]);
document.querySelector('.logo1').innerHTML = h;
if (document.getElementById("secondHeader").style.display != "none") {
var h = document.querySelector('.logo2').innerHTML;
h = h.replace(/033cd2/g, selectedColors[0]);
h = h.replace(/78e600/g, selectedColors[1]);
document.querySelector('.logo2').innerHTML = h;
}
// Apply the first color to the banner background
var donationBanner = document.getElementById("donation-banner");
if (donationBanner) {
donationBanner.style.backgroundColor = `#${selectedColors[0]}`;
}
// Apply the second color to the donate button background
var donateButton = document.getElementById("donate-button");
if (donateButton) {
donateButton.style.backgroundColor = `#${selectedColors[1]}`;
}
// Footer links collapse code
$(".widget h4").click(
function () {
$(this).parent().toggleClass('active');
});
// Disabling code
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification));
// Internet Explorer 6-11
var isIE = /*@cc_on!@*/false || !!document.documentMode;
// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
var isOtherdevice = navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i);
var isSmallWidth = 0;
if (window.innerWidth < 768) {
isSmallWidth = 1;
}
if (isOpera || isFirefox || isSafari || isIE || isEdge || isChrome || isOtherdevice || isSmallWidth) {
$('#loaderDiv').css('display', 'block');
$('#animationPart1').addClass('start');
$('#animationPart2').addClass('start');
$('#animationPart3').addClass('start');
if (isIE) {
$('#navh2').css('display', 'block');
$('#navh3').css('display', 'block');
}
else {
$('#navh').css('display', 'block');
$('#navh1').css('display', 'block');
}
}
if (!isOpera && !isFirefox && !isSafari && !isIE && !isEdge && !isChrome && !isOtherdevice && !isSmallWidth) {
$('#ftctn').css('display', 'none');
$('#myBtn2').css('display', 'none');
$('#navh2').css('display', 'block');
$('#navh').css('display', 'none');
$('#navh3').css('display', 'block');
$('#navh1').css('display', 'none');
}
// Slideshows code
$("#glimpse-slider").owlCarousel({
paginationSpeed: 500,
singleItem: true,
autoPlay: 3000,
});
$("#testimonial-slider1").owlCarousel({
paginationSpeed: 500,
singleItem: true,
autoPlay: 3000,
});
$("#testimonial-slider2").owlCarousel({
paginationSpeed: 500,
singleItem: true,
autoPlay: 3000,
});
$("#testimonial-slider3").owlCarousel({
paginationSpeed: 500,
singleItem: true,
autoPlay: 3000,
});
$("#testimonial-slider4").owlCarousel({
paginationSpeed: 500,
singleItem: true,
autoPlay: 3000,
});
$("#testimonial-slider5").owlCarousel({
paginationSpeed: 500,
singleItem: true,
autoPlay: 3000,
});
$("#testimonial-slider6").owlCarousel({
paginationSpeed: 500,
singleItem: true,
autoPlay: 3000,
});
$("#testimonial-slider7").owlCarousel({
paginationSpeed: 500,
singleItem: true,
autoPlay: 3000,
});
$("#social-media-logos").owlCarousel({
autoPlay: 3000,
items: 5,
itemsDesktop: [1199, 5],
itemsDesktopSmall: [979, 5],
});
var fullHeight = function () {
$('.js-fullheight').css('height', $(window).height());
$(window).resize(function () {
$('.js-fullheight').css('height', $(window).height());
});
};
});