-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
135 lines (84 loc) · 2.69 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<script src="dist/brickrouge.umd.js"></script>
<div class="doc-example">
<div brickrouge-is="clone">
<time brickrouge-is="time">TIME</time> <button class="btn btn-primary btn-sm">Clone</button>
</div>
</div>
<script type="text/javascript">
console.log(Brickrouge)
!function(Brickrouge) {
function Clone(element, options) {
element
.querySelector('button')
.addEventListener('click', function() {
var clone = Brickrouge.clone(element)
element.parentNode.appendChild(clone)
element.parentNode.insertBefore(clone, element)
})
}
var n = 1
function Time(element, options) {
function rainbow(numOfSteps, step) {
// This function generates vibrant, "evenly spaced" colours (i.e. no clustering). This is ideal for creating easily distinguishable vibrant markers in Google Maps and other apps.
// Adam Cole, 2011-Sept-14
// HSV to RBG adapted from: http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
var r, g, b;
var h = step / numOfSteps;
var i = ~~(h * 6);
var f = h * 6 - i;
var q = 1 - f;
switch(i % 6){
case 0: r = 1; g = f; b = 0; break;
case 1: r = q; g = 1; b = 0; break;
case 2: r = 0; g = 1; b = f; break;
case 3: r = 0; g = q; b = 1; break;
case 4: r = f; g = 0; b = 1; break;
case 5: r = 1; g = 0; b = q; break;
}
return "#" + ("00" + (~ ~(r * 255)).toString(16)).slice(-2) + ("00" + (~ ~(g * 255)).toString(16)).slice(-2) + ("00" + (~ ~(b * 255)).toString(16)).slice(-2);
}
element.style.backgroundColor = rainbow(32, ++n % 32)
function render() {
element.innerHTML = (new Date).toISOString()
}
render()
setInterval(render, 1000)
}
Brickrouge.register('clone', function(element, options) {
return new Clone(element, options)
})
Brickrouge.register('time', function(element, options) {
return new Time(element, options)
})
} (Brickrouge)
!function (Brickrouge) {
const MadonnaEvent = Brickrouge.Subject.createEvent(function (say) {
this.say = say
})
class Constructor extends Brickrouge.mixin(Object, Brickrouge.Subject)
{
}
var subject = new Constructor
subject.observe(MadonnaEvent, function (ev) {
console.log('madonna:', ev)
})
subject.notify(new MadonnaEvent("bitch, I'm madonna"))
} (Brickrouge)
Brickrouge.observeRunning(function (ev) {
console.log('observeRunning:', ev)
})
Brickrouge.observeWidget(function (ev) {
console.log('observeWidget:', ev)
})
Brickrouge.observeUpdate(function (ev) {
console.log('observeUpdate:', ev)
})
Brickrouge.run()
</script>
</body>