<html>
<head>
<title>test_cb</title>
<script language="javascript">
var sp_logic = {
mediator_: null,
bind: function (mediator) {
this.mediator_ = mediator;
},
notify_dev_online: function (dev_id) {
var cb = this.mediator_.notify_dev_online;
this.apply(cb, { id :dev_id });
},
apply: function (fun, param, defaultValue) {
if ((typeof fun) == "function" && null != fun) {
return fun.apply(this.mediator_, param ? [param] : []);
}
return defaultValue;
}
};
var mediator = {
sp_logic_: null,
init: function (sp_logic) {
sp_logic.bind(this);
this.sp_logic_ = sp_logic;
},
notify_dev_online: function (dev_id) {
alert(dev_id);
}
};
function test_onclick() {
mediator.init(sp_logic);
sp_logic.notify_dev_online(1);
}
</script>
</head>
<body>
<input id="test" type="button" value="test" name="test" οnclick="javascript:test_onclick()" />
</body>
</html>
<head>
<title>test_cb</title>
<script language="javascript">
var sp_logic = {
mediator_: null,
bind: function (mediator) {
this.mediator_ = mediator;
},
notify_dev_online: function (dev_id) {
var cb = this.mediator_.notify_dev_online;
this.apply(cb, { id :dev_id });
},
apply: function (fun, param, defaultValue) {
if ((typeof fun) == "function" && null != fun) {
return fun.apply(this.mediator_, param ? [param] : []);
}
return defaultValue;
}
};
var mediator = {
sp_logic_: null,
init: function (sp_logic) {
sp_logic.bind(this);
this.sp_logic_ = sp_logic;
},
notify_dev_online: function (dev_id) {
alert(dev_id);
}
};
function test_onclick() {
mediator.init(sp_logic);
sp_logic.notify_dev_online(1);
}
</script>
</head>
<body>
<input id="test" type="button" value="test" name="test" οnclick="javascript:test_onclick()" />
</body>
</html>