This repository has been archived by the owner on Jun 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
65 lines (58 loc) · 2.04 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
<!DOCTYPE html>
<html>
<head>
<title>Test OOJ</title>
<meta charset="utf-8" />
<script type="application/javascript" src="simple-js-inherit.js"></script>
<script type="application/javascript" src="event-object.js"></script>
<script>
/*
* The same without Sig/Slog
*/
function theSame() {
document.querySelector("button").addEventListener('click', function() {
alert(document.querySelector('input').value);
});
}
/**
* create the button handler
*/
var ButtonHandler = EventObject.extend({
init: function() {
this._super();
// .bind to keep the application scope
document.querySelector('button').addEventListener('click', this.clicked.bind(this), false);
},
clicked: function() {
this.emit('clicked');
}
});
/**
* Main application. Create the handler and connect button and application on signal
* clicked
*/
var MyApp = Class.extend({
init: function() {
this.bh = new ButtonHandler();
this.bh.connect('clicked', this.onButtonClicked.bind(this));
},
onButtonClicked: function(e) {
alert(document.querySelector("input").value);
}
});
/**
* Start the app when the DOM is ready
*/
document.addEventListener('DOMContentLoaded', function() {var app = new MyApp()}, false);
</script>
</head>
<body>
<h1 id="value-to-change">Signal Slot Class Based Experiment</h1>
<p>This is a test for Signal / Slot based javascript. Please fill the input bellow,
click on 'OK' then a alert box will be displayed with the value of the field </p>
<div>
<input type="text" value="Nothing" />
<button>OK</button>
</div>
</body>
</html>