-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.js
37 lines (33 loc) · 970 Bytes
/
code.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
// an array of strings (hex colors)
var colors = [
'#362143',
'#DB649C',
'#754792',
'#FF9800',
'#1976D2',
'#9E9E9E',
'#ff4f79',
'#8BC34A',
'#171717',
'#00BCD4'
];
// Variable for the current color index
var currentColor = 0;
// On click function (Replace #click-android with the suitable ID of your target)
$('#click-android').on('click', function() {
// Color Switcher
if (currentColor == colors.length-1) currentColor = 0;
else currentColor++;
// Actual Change of colors
document.body.style.backgroundColor = colors[currentColor];
//Android status bar color attributes
$('meta[name=theme-color]').remove();
$('head').append( '<meta name="theme-color" content="'+colors[currentColor]+'">' );
});
// Calling the function
function click() {
}
//when the window has finished loading, update the body to the first color as fallback
window.onload = function() {
document.body.style.backgroundColor = colors[currentColor];
}