bitcoin-atm

bitcoin atm for pyc inc.

git clone https://9o.is/git/bitcoin-atm.git

ActorsBridge.js

(2538B)


      1 
      2 /** 
      3  * Broadcasts message to angular app in html document. 
      4  * To listen for an event:
      5  * 
      6  * $rootScope.$on(event, function (event, message) {
      7  *   // code here
      8  * });
      9  */
     10 window.broadcast = function(/*event, message*/) {
     11 	var scope = angular.element('[ng-app]').scope();
     12 	scope.$apply(function () {
     13 		//scope.$broadcast(event, message);
     14 	});
     15 };
     16 
     17 /**
     18  * Overlord Comet
     19  * Sends messages to Overlord
     20  * ie. window.overlord.send("Hello, Overlord!");
     21  */
     22 window.Overlord = function(sendFunc) {
     23 	"use strict";
     24 	var self = this;
     25 	
     26 	self.send = sendFunc;
     27 };
     28 
     29 /**
     30  * Logger Comet
     31  * Sends logs to server.
     32  */
     33 window.Logger = function(sendFunc) {
     34 	"use strict";
     35 	var self = this;
     36 	
     37 	self.send = sendFunc;
     38 	self.error = function(msg){self.send({error: msg});};
     39 	self.warn = function(msg){self.send({warn: msg});};
     40 	self.info = function(msg){self.send({info: msg});};
     41 	self.debug = function(msg){self.send({debug: msg});};
     42 };
     43 
     44 /**
     45  * Configuration Comet
     46  * Updates the client with the machine's configurations. 
     47  */
     48 window.Configurations = function() {
     49 	"use strict";
     50 	var self = this;
     51 
     52 	self.apply = function(message) {
     53 		window.broadcast('configUpdate', message);
     54 	};
     55 };
     56 
     57 /**
     58  * Session Comet
     59  * Sends a data value to be saved by the client session. 
     60  */
     61 window.Session = function() {
     62 	"use strict";
     63 	var self = this;
     64 
     65 	self.apply = function(message) {
     66 		window.broadcast('sessionUpdate', message);
     67 	};
     68 };
     69 
     70 /**
     71  * Price Ticker Comet
     72  * Updates the price for price ticker on screen. 
     73  */
     74 window.PriceTicker = function() {
     75 	"use strict";
     76 	var self = this;
     77 
     78 	self.apply = function(message) {
     79 		window.broadcast('priceUpdate', message);
     80 	};
     81 };
     82 
     83 /**
     84  * Wallet Balance Comet
     85  * Updates the wallet balance. 
     86  */
     87 window.WalletBalance = function() {
     88 	"use strict";
     89 	var self = this;
     90 
     91 	self.apply = function(message) {
     92 		window.broadcast('balanceUpdate', message);
     93 	};
     94 };
     95 
     96 /**
     97  * Data Manager Comet
     98  * Updates the data, but not the state, of the machine.
     99  */
    100 window.DataManager = function() {
    101 	"use strict";
    102 	var self = this;
    103 
    104 	self.apply = function(message) {
    105 		window.broadcast('dataUpdate', message);
    106 	};
    107 };
    108 
    109 /**
    110  * State Manager Comet
    111  * Updates the state and data of the machine.
    112  */
    113 window.StateManager = function() {
    114 	"use strict";
    115 	var self = this;
    116 
    117 	self.apply = function(message) {
    118 		window.broadcast('stateUpdate', message);
    119 	};
    120 };
    121 
    122 /**
    123  * Acceptor Comet
    124  * Sends messages to fake bill acceptor
    125  * ie. window.acceptor.send(5); // sends $5
    126  */
    127 window.Acceptor = function(sendFunc) {
    128 	"use strict";
    129 	var self = this;
    130 	
    131 	self.send = sendFunc;
    132 };