Skip to content

Commit

Permalink
Added EventSignal example
Browse files Browse the repository at this point in the history
  • Loading branch information
rgr-myrg committed May 7, 2011
1 parent 195f022 commit 31cbc2c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
4 changes: 3 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

VERSION="0.1-SNAPSHOT"
ARTIFACT="devshop-$VERSION.js"
JS_FILES="--js src/core.js --js src/singletonfactory.js --js src/observable.js --js src/observer.js"
JS_FILES="--js src/core.js --js src/singletonfactory.js --js src/observable.js --js src/observer.js --js src/eventsignal.js"
JS_BUILD="build/$ARTIFACT"
JS_TEMP="build/tmp.js"
EXAMPLE="examples/devshop.js"
LICENSE="LICENSE"

echo -n "Compiling...\n"
Expand All @@ -16,6 +17,7 @@ cat $LICENSE $JS_TEMP > $JS_BUILD

echo -n "Created $JS_BUILD\n"

cp -p $JS_TEMP $EXAMPLE
rm $JS_TEMP

if [ $? -ne 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion build/devshop-0.1-SNAPSHOT.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions examples/devshop.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions examples/eventsignal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en:us'>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>DevShop.Me :: Event Signal</title>
<style>
</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);
};
};
</script>
</head>
<body>
<form>
<table>
<tr>
<td>Type in this box:</td>
<td><input onkeyup="UI.onKeyUp()" type="text" id="box" name="box" value="" size="50"/></td>
</tr>
<tr>
<td>Echo:</td><td><div id="echo"></div></td>
</tr>
<tr>
<td>Mirror:</td><td><div id="mirror"></div></td>
</tr>
</table>
</form>
</body>
</html>

0 comments on commit 31cbc2c

Please sign in to comment.