-
Notifications
You must be signed in to change notification settings - Fork 247
/
Copy pathindex.html
96 lines (84 loc) · 2.23 KB
/
index.html
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
<html>
<head>
<title>Circles</title>
<style>
.canvas {
margin-top: 1em;
text-align: center;
}
.circle {
display: inline-block;
margin: 1em;
}
.circles-decimals {
font-size: .4em;
}
.buttons {
margin-top: 1em;
}
button {
font-size: .8em;
padding: .3em .8em;
}
</style>
</head>
<body>
<div class="canvas">
<div class="circle" id="circles-1"></div>
<div class="circle" id="circles-2"></div>
<div class="circle" id="circles-3"></div>
<div class="circle" id="circles-4"></div>
<div class="circle" id="circles-5"></div>
<div class="buttons">
<button id="change-value-button">Change values to 20</button>
<button id="add-width-button">Change width to 20</button>
<button id="substract-width-button">Change width to 10</button>
<button id="colors-button">Swap colors</button>
</div>
</div>
<script src="../circles.min.js"></script>
<script>
//@ http://jsfromhell.com/array/shuffle [v1.0]
function shuffle(o){ //v1.0
for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
}
var colors = [
['#D3B6C6', '#4B253A'], ['#FCE6A4', '#EFB917'], ['#BEE3F7', '#45AEEA'], ['#F8F9B6', '#D2D558'], ['#F4BCBF', '#D43A43']
], circles = [];
for (var i = 1; i <= 5; i++) {
var child = document.getElementById('circles-' + i),
percentage = 31.42 + (i * 9.84);
circles.push(Circles.create({
id: child.id,
value: percentage,
radius: 60,
width: 10,
colors: colors[i - 1]
}));
}
document.getElementById('change-value-button').onclick = function()
{
for(var i = 0, l = circles.length; i < l; i++)
circles[i].update(20, 250);
};
document.getElementById('add-width-button').onclick = function()
{
for(var i = 0, l = circles.length; i < l; i++) {
circles[i].updateWidth(20);
}
};
document.getElementById('substract-width-button').onclick = function()
{
for(var i = 0, l = circles.length; i < l; i++)
circles[i].updateWidth(10);
};
document.getElementById('colors-button').onclick = function()
{
colors = shuffle(colors);
for(var i = 0, l = circles.length; i < l; i++)
circles[i].updateColors(colors[i]);
};
</script>
</body>
</html>