Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added EventSignal example

  • Loading branch information...
commit 31cbc2cb74acfb445bf9e088cc8f266f7fc194c0 1 parent 195f022
@rgr-myrg authored
View
4 build.sh
@@ -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"
@@ -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
View
2  build/devshop-0.1-SNAPSHOT.js
@@ -3,4 +3,4 @@
* Released under the MIT license:
* https://github.com/rgr-myrg/DevShop-JS/raw/master/MIT-LICENSE
*/
-(function(){window.DevShop=typeof window.DevShop==="object"?window.DevShop:{};window.DevShop.Me=function(a){for(var b in a)a.hasOwnProperty(b)&&(window.DevShop[b]=a[b]);DevShop=devshop=window.DevShop}})();(function(){DevShop.Me({SingletonFactory:function(a){var b={},c={};if(typeof a.extend==="function")try{b=new a.extend}catch(d){}else if(typeof a.extend==="object")b=a.extend;if(typeof a.instance==="function")try{c=new a.instance}catch(f){}else if(typeof a.instance==="object")c=a.instance;for(var e in b)b.hasOwnProperty(e)&&(c[e]||(c[e]=b[e]));if(typeof c.initialize==="function")try{c.initialize()}catch(g){}return c}})})();(function(){DevShop.Me({Observable:function(a){return DevShop.SingletonFactory({extend:function(){this.observers=[];this.addObserver=function(b){if((typeof b==="function"||typeof b==="object")&&typeof b.notify==="function")if(this.observers.push(b),typeof b.onRegister==="function")try{b.onRegister()}catch(a){}};this.notifyObservers=function(b){for(var a=this.observers.length,d=0;d<a;d++)try{this.observers[d].notify(b,this)}catch(f){}}},instance:a})}})})();(function(){DevShop.Me({Observer:function(a){return DevShop.SingletonFactory({extend:function(){this.onRegister=function(){};this.notify=function(b,a){this.observable=a;if(typeof this[b]==="function")try{this[b]()}catch(d){}}},instance:a})}})})();
+(function(){window.DevShop=typeof window.DevShop==="object"?window.DevShop:{};window.DevShop.Me=function(a){for(var b in a)a.hasOwnProperty(b)&&(window.DevShop[b]=a[b]);DevShop=devshop=window.DevShop}})();(function(){DevShop.Me({SingletonFactory:function(a){var b={},c={};if(typeof a.extend==="function")try{b=new a.extend}catch(d){}else if(typeof a.extend==="object")b=a.extend;if(typeof a.instance==="function")try{c=new a.instance}catch(f){}else if(typeof a.instance==="object")c=a.instance;for(var e in b)b.hasOwnProperty(e)&&(c[e]||(c[e]=b[e]));if(typeof c.initialize==="function")try{c.initialize()}catch(g){}return c}})})();(function(){DevShop.Me({Observable:function(a){return DevShop.SingletonFactory({extend:function(){this.observers=[];this.addObserver=function(b){if((typeof b==="function"||typeof b==="object")&&typeof b.notify==="function")if(this.observers.push(b),typeof b.onRegister==="function")try{b.onRegister()}catch(a){}};this.notifyObservers=function(b){for(var a=this.observers.length,d=0;d<a;d++)try{this.observers[d].notify(b,this)}catch(f){}}},instance:a})}})})();(function(){DevShop.Me({Observer:function(a){return DevShop.SingletonFactory({extend:function(){this.onRegister=function(){};this.notify=function(b,a){this.observable=a;if(typeof this[b]==="function")try{this[b]()}catch(d){}}},instance:a})}})})();(function(){DevShop.Me({EventSignal:function(){var a=[];this.addListener=function(b){typeof b==="function"&&a.push(b)};this.removeListener=function(b){for(var c=a.length,d=0;d<c;d++)a[d]===b&&a.splice(d)};this.dispatch=function(){for(var b=a.length,c=0;c<b;c++)try{a[c].apply(this,arguments)}catch(d){}}}})})();
View
7 examples/devshop.js
@@ -1,6 +1 @@
-/**
- * Copyright (c) 2011 Roger Myrg http://devshop.me/
- * Released under the MIT license:
- * https://github.com/rgr-myrg/DevShop-JS/raw/master/MIT-LICENSE
- */
-(function(){window.DevShop=typeof window.DevShop==="object"?window.DevShop:{};window.DevShop.Me=function(a){for(var b in a)a.hasOwnProperty(b)&&(window.DevShop[b]=a[b]);DevShop=devshop=window.DevShop}})();(function(){DevShop.Me({SingletonFactory:function(a){var b={},c={};if(typeof a.extend==="function")try{b=new a.extend}catch(d){}else if(typeof a.extend==="object")b=a.extend;if(typeof a.instance==="function")try{c=new a.instance}catch(f){}else if(typeof a.instance==="object")c=a.instance;for(var e in b)b.hasOwnProperty(e)&&(c[e]||(c[e]=b[e]));if(typeof c.initialize==="function")try{c.initialize()}catch(g){}return c}})})();(function(){DevShop.Me({Observable:function(a){return DevShop.SingletonFactory({extend:function(){this.observers=[];this.addObserver=function(b){if((typeof b==="function"||typeof b==="object")&&typeof b.notify==="function")if(this.observers.push(b),typeof b.onRegister==="function")try{b.onRegister()}catch(a){}};this.notifyObservers=function(b){for(var a=this.observers.length,d=0;d<a;d++)try{this.observers[d].notify(b,this)}catch(f){}}},instance:a})}})})();(function(){DevShop.Me({Observer:function(a){return DevShop.SingletonFactory({extend:function(){this.onRegister=function(){};this.notify=function(b,a){this.observable=a;if(typeof this[b]==="function")try{this[b]()}catch(d){}}},instance:a})}})})();
+(function(){window.DevShop=typeof window.DevShop==="object"?window.DevShop:{};window.DevShop.Me=function(a){for(var b in a)a.hasOwnProperty(b)&&(window.DevShop[b]=a[b]);DevShop=devshop=window.DevShop}})();(function(){DevShop.Me({SingletonFactory:function(a){var b={},c={};if(typeof a.extend==="function")try{b=new a.extend}catch(d){}else if(typeof a.extend==="object")b=a.extend;if(typeof a.instance==="function")try{c=new a.instance}catch(f){}else if(typeof a.instance==="object")c=a.instance;for(var e in b)b.hasOwnProperty(e)&&(c[e]||(c[e]=b[e]));if(typeof c.initialize==="function")try{c.initialize()}catch(g){}return c}})})();(function(){DevShop.Me({Observable:function(a){return DevShop.SingletonFactory({extend:function(){this.observers=[];this.addObserver=function(b){if((typeof b==="function"||typeof b==="object")&&typeof b.notify==="function")if(this.observers.push(b),typeof b.onRegister==="function")try{b.onRegister()}catch(a){}};this.notifyObservers=function(b){for(var a=this.observers.length,d=0;d<a;d++)try{this.observers[d].notify(b,this)}catch(f){}}},instance:a})}})})();(function(){DevShop.Me({Observer:function(a){return DevShop.SingletonFactory({extend:function(){this.onRegister=function(){};this.notify=function(b,a){this.observable=a;if(typeof this[b]==="function")try{this[b]()}catch(d){}}},instance:a})}})})();(function(){DevShop.Me({EventSignal:function(){var a=[];this.addListener=function(b){typeof b==="function"&&a.push(b)};this.removeListener=function(b){for(var c=a.length,d=0;d<c;d++)a[d]===b&&a.splice(d)};this.dispatch=function(){for(var b=a.length,c=0;c<b;c++)try{a[c].apply(this,arguments)}catch(d){}}}})})();
View
51 examples/eventsignal.html
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.