Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modified Examples

  • Loading branch information...
commit 7088fe8cd3ba63f28ae62d6dd15d81bb1cf3ec26 1 parent 8670029
@rgr-myrg authored
View
55 examples/eventsignal.html
@@ -7,29 +7,37 @@
</style>
<script type="text/javascript" src="devshop.js"></script>
<script type="text/javascript">
- var Echo={
- onKeyUp:function(msg){
- document.getElementById('echo').innerHTML=msg;
- }
- };
- var Mirror={
- onKeyUp:function(msg){
- var arr=msg.split('');
- var msg='';
- if(arr.length>0)
- for(var x=arr.length-1;x>=0;x--)
- msg+=arr[x];
- document.getElementById('mirror').innerHTML=msg;
- }
- };
- var UI=new function(){
- var typed=new DevShop.EventSignal;
- typed.addListener(Echo.onKeyUp);
- typed.addListener(Mirror.onKeyUp);
- this.onKeyUp=function(){
- typed.dispatch(document.getElementById('box').value);
- };
+ var Echo={
+ onKeyUp:function(msg){
+ document.getElementById('echo').innerHTML=msg;
+ }
+ };
+ var Mirror={
+ onKeyUp:function(msg){
+ var arr=msg.split('');
+ var msg='';
+ if(arr.length>0)
+ for(var x=arr.length-1;x>=0;x--)
+ msg+=arr[x];
+ document.getElementById('mirror').innerHTML=msg;
+ }
+ };
+ var Vertical={
+ onKeyUp:function(msg){
+ var arr=msg.split('');
+ var msg=arr.join('<br>');
+ document.getElementById('vertical').innerHTML=msg;
+ }
+ };
+ var UI=new function(){
+ var keyUp=new DevShop.EventSignal;
+ keyUp.addListener(Echo.onKeyUp);
+ keyUp.addListener(Mirror.onKeyUp);
+ keyUp.addListener(Vertical.onKeyUp);
+ this.onKeyUp=function(){
+ keyUp.dispatch(document.getElementById('box').value);
};
+ };
</script>
</head>
<body>
@@ -45,6 +53,9 @@
<tr>
<td>Mirror:</td><td><div id="mirror"></div></td>
</tr>
+ <tr>
+ <td valign="top">Vertical:</td><td valign="top"><div id="vertical"></div></td>
+ </tr>
</table>
</form>
</body>
View
15 examples/mvc.html
@@ -22,6 +22,13 @@
document.getElementById('mirror').innerHTML=msg;
}
};
+ var Vertical={
+ onKeyUp:function(msg){
+ var arr=msg.split('');
+ var msg=arr.join('<br>');
+ document.getElementById('vertical').innerHTML=msg;
+ }
+ };
var DataProxy=DevShop.SingletonFactory({
extend : DevShop.Proxy,
implement : DevShop.ProxyInterface,
@@ -32,7 +39,7 @@
var StartUpCmd=DevShop.SingletonFactory({
implement : DevShop.CommandInterface,
instance : {
- execute:function(notification){console.log(notification.name);
+ execute:function(notification){
this.facade.registerProxy(DataProxy);
this.facade.registerMediator(UIMediator);
}
@@ -41,10 +48,11 @@
var KeyUpCmd=DevShop.SingletonFactory({
implement : DevShop.CommandInterface,
instance : {
- execute:function(notification){console.log(notification.name);
+ execute:function(notification){
var msg=this.facade.retrieveProxy(DataProxy.NAME).getData();
Echo.onKeyUp(msg);
Mirror.onKeyUp(msg);
+ Vertical.onKeyUp(msg);
}
}
});
@@ -99,6 +107,9 @@
<tr>
<td>Mirror:</td><td><div id="mirror"></div></td>
</tr>
+ <tr>
+ <td valign="top">Vertical:</td><td valign="top"><div id="vertical"></div></td>
+ </tr>
</table>
</form>
</body>
View
14 examples/observer.html
@@ -22,16 +22,23 @@
document.getElementById('mirror').innerHTML=msg;
}
});
+ var Vertical=new DevShop.Observer({
+ onKeyUp:function(){
+ var arr=this.observable.getMsg().split('');
+ var msg=arr.join('<br>');
+ document.getElementById('vertical').innerHTML=msg;
+ }
+ });
var UI=new DevShop.Observable({
initialize:function(){
this.addObserver(Echo);
this.addObserver(Mirror);
+ this.addObserver(Vertical);
},
onKeyUp:function(){
/*
Event Handler Mapping
- The event name is wired to observer's handler methods.
- This facilitates notifications and dynamic mapping.
+ The event name is wired to observer's handler methods.
*/
this.notifyObservers('onKeyUp');
},
@@ -54,6 +61,9 @@
<tr>
<td>Mirror:</td><td><div id="mirror"></div></td>
</tr>
+ <tr>
+ <td valign="top">Vertical:</td><td valign="top"><div id="vertical"></div></td>
+ </tr>
</table>
</form>
</body>
Please sign in to comment.
Something went wrong with that request. Please try again.