-
Notifications
You must be signed in to change notification settings - Fork 1
/
ears.html
37 lines (34 loc) · 932 Bytes
/
ears.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ears</title>
<link rel="stylesheet" href="">
</head>
<body>
<h1>ears.js</h1>
<h2>Object Event Manager</h2>
<pre><code class="jsObject">
{
"name": "ears.js",
"description": "An object event manager",
"class": "Human"
}
</code></pre>
<button class="action">Mutate Object (This is NOT a DOM event)</button>
<script src="dist/ears.js"></script>
<script>
var codeContainer = document.querySelector('.jsObject'),
obj = JSON.parse(codeContainer.innerText),
ear = new Ears(obj);
ear.on('mutation', function (e) {
alert('The mutants are comming!');
});
document.querySelector('.action').addEventListener('click', function (e) {
var obj = JSON.stringify(ear.set('class', 'Mutant').raw());
codeContainer.innerHTML = obj;
});
</script>
</body>
</html>