
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 0.78 KB | hits: 11 | expires: Never
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
<script type="text/javascript">
function Contact() {
var state = false;
this.onStateChange = function() {};
this.getState = function() {
return state;
};
this.setState = function(value) {
state = value;
this.onStateChange();
};
}
function Connection(c1, c2) {
c1.onStateChange = function() {
c2.setState(c1.getState());
};
c2.onStateChange = function() {
c1.setState(c2.getState());
};
}
window.onload = function() {
var ac1 = new Contact();
var ac2 = new Contact();
var conn1 = new Connection(ac1, ac2);
ac1.setState(true);
alert(ac2.getState());
}
</script>
</head>
<body>
</body>
</html>