mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
load Gun once in NW.js's JavaScript Contexts
In the NW.js's JavaScript Contexts, `require`, `window` are both defined... [JavaScript Contexts in NW.js](http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/)
This commit is contained in:
parent
b0662c2464
commit
bb4dae2d04
6
nts.js
6
nts.js
@ -2,8 +2,10 @@
|
||||
|
||||
var env;
|
||||
if(typeof global !== "undefined"){ env = global }
|
||||
if(typeof require !== "undefined"){ var Gun = require('./gun') }
|
||||
if(typeof window !== "undefined"){ var Gun = (env = window).Gun }
|
||||
else {
|
||||
if(typeof require !== "undefined"){ var Gun = require('./gun') }
|
||||
}
|
||||
|
||||
Gun.on('opt', function(at){
|
||||
this.to.next(at);
|
||||
@ -43,4 +45,4 @@
|
||||
}; ping();
|
||||
});
|
||||
// test by opening up examples/game/nts.html on devices that aren't NTP synced.
|
||||
}());
|
||||
}());
|
||||
|
Loading…
x
Reference in New Issue
Block a user