123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- ;(function(){
-
- var root;
- if(typeof window !== "undefined"){ root = window }
- if(typeof global !== "undefined"){ root = global }
- root = root || {};
- var console = root.console || {log: function(){}};
- function USE(arg, req){
- return req? require(arg) : arg.slice? USE[R(arg)] : function(mod, path){
- arg(mod = {exports: {}});
- USE[R(path)] = mod.exports;
- }
- function R(p){
- return p.split('/').slice(-1).toString().replace('.js','');
- }
- }
- if(typeof module !== "undefined"){ var common = module }
-
- ;USE(function(module){
- if(typeof window !== "undefined"){ module.window = window }
- var tmp = module.window || module;
- var AXE = tmp.AXE || function(){};
- if(AXE.window = module.window){ try{
- AXE.window.AXE = AXE;
- tmp = document.createEvent('CustomEvent');
- tmp.initCustomEvent('extension', false, false, {type: "AXE"});
- (window.dispatchEvent || window.fireEvent)(tmp);
- window.postMessage({type: "AXE"}, '*');
- } catch(e){} }
- try{ if(typeof common !== "undefined"){ common.exports = AXE } }catch(e){}
- module.exports = AXE;
- })(USE, './root');
-
- ;USE(function(module){
- var AXE = USE('./root'), Gun = (AXE.window||{}).Gun || USE('./gun', 1);
- (Gun.AXE = AXE).GUN = AXE.Gun = Gun;
- Gun.on('opt', function(at){
- if(!at.axe){
- at.axe = {};
- var p = at.opt.peers, tmp;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- console.log("axe", at.opt);
- if(at.opt.super){
- function verify(msg, send, at) {
- var peers = Object.keys(p), puts = Object.keys(msg.put), i, j, peer;
- var soul = puts[0];
- for (i=0; i < peers.length; ++i) {
- peer = p[peers[i]];
-
- if (!peer.id) {console.log('AXE peer without id: ', peer); continue;}
- if (!Gun.subscribe[soul] || !Gun.subscribe[soul][peer.id]) { console.log('AXE SAY reject msg to peer: %s, soul: %s', peer.id, soul); continue; }
- send(msg, peer);
- }
- }
- AXE.say = function(msg, send, at) {
- if (!msg.put) { send(msg); return; }
- console.log('AXE HOOK!! ', msg);
- verify(msg, send, at);
- };
-
- }
- if(at.opt.super){
- at.on('in', USE('./lib/super', 1), at);
- } else {
-
- }
- }
- this.to.next(at);
- });
- function input(msg){
- var at = this.as, to = this.to;
- }
- module.exports = AXE;
- })(USE, './axe');
- }());
|