cats!
@ -7,11 +7,7 @@ var Gun = require('gun');
|
||||
var gun = Gun({
|
||||
s3: (process.env.NODE_ENV === 'production')? null : require('../../test/shotgun') // replace this with your own keys!
|
||||
});
|
||||
app.use(function(req, res, next){
|
||||
console.log("THIS HIT SEEEERVER", req.url);
|
||||
next();
|
||||
})
|
||||
.use(gun.server)
|
||||
app.use(gun.server)
|
||||
.use(express.static(__dirname))
|
||||
app.listen(port);
|
||||
|
||||
|
229
examples/admin/slinger-t.html
Normal file
@ -0,0 +1,229 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="https://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="../../gun.js"></script>
|
||||
</head>
|
||||
<body><center>
|
||||
<style>
|
||||
html, body {
|
||||
font-family: Papyrus, fantasy;
|
||||
font-size: 18pt;
|
||||
}
|
||||
.start .player {
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 1.5em;
|
||||
background: skyblue;
|
||||
font-family: Papyrus, fantasy;
|
||||
}
|
||||
.screen {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.off {
|
||||
display: none;
|
||||
}
|
||||
.white {
|
||||
color: white;
|
||||
}
|
||||
.winner input, .winner button {
|
||||
font-size: 18pt;
|
||||
}
|
||||
</style>
|
||||
<div class="start screen">
|
||||
<!--<pre>
|
||||
¦¦¦¦¦¦+ ¦¦+ ¦¦+ ¦¦¦+ ¦¦+ ¦¦¦¦¦¦¦+ ¦¦+ ¦¦+ ¦¦¦+ ¦¦+ ¦¦¦¦¦¦+ ¦¦¦¦¦¦¦+ ¦¦¦¦¦¦+
|
||||
¦¦+----+ ¦¦¦ ¦¦¦ ¦¦¦¦+ ¦¦¦ ¦¦+----+ ¦¦¦ ¦¦¦ ¦¦¦¦+ ¦¦¦ ¦¦+----+ ¦¦+----+ ¦¦+--¦¦+
|
||||
¦¦¦ ¦¦¦+ ¦¦¦ ¦¦¦ ¦¦+¦¦+ ¦¦¦ ¦¦¦¦¦¦¦+ ¦¦¦ ¦¦¦ ¦¦+¦¦+ ¦¦¦ ¦¦¦ ¦¦¦+ ¦¦¦¦¦+ ¦¦¦¦¦¦++
|
||||
¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦+¦¦+¦¦¦ +----¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦+¦¦+¦¦¦ ¦¦¦ ¦¦¦ ¦¦+--+ ¦¦+--¦¦+
|
||||
+¦¦¦¦¦¦++ +¦¦¦¦¦¦++ ¦¦¦ +¦¦¦¦¦ ¦¦¦¦¦¦¦¦ ¦¦¦¦¦¦¦+ ¦¦¦ ¦¦¦ +¦¦¦¦¦ +¦¦¦¦¦¦++ ¦¦¦¦¦¦¦+ ¦¦¦ ¦¦¦
|
||||
+-----+ +-----+ +-+ +---+ +------+ +------+ +-+ +-+ +---+ +-----+ +------+ +-+ +-+
|
||||
</pre>-->
|
||||
<h1>GUN SLINGER</h1>
|
||||
<h3>Select!</h3>
|
||||
<button id="one" class="player">Player 1</button>
|
||||
<button id="two" class="player">Player 2</button>
|
||||
<h5>Next game available in 15 seconds or less...<h5>
|
||||
<h4>Fastest draw in the west, <span id="fastest">no</span> seconds, by <span id="slinger">nobody</span>.</h4>
|
||||
<h5>Previous duel won in <span id="previous">no</span> seconds, by <span id="last">no one</span>.</h5>
|
||||
</div>
|
||||
<div class="shoot screen off white" style="background: tan;">
|
||||
<h3>GET READY!</h3>
|
||||
</div>
|
||||
<div class="fire screen off" style="background: lime;">
|
||||
<h3>FIRE!</h3>
|
||||
<h5>by tapping this screen</h5>
|
||||
</div>
|
||||
<div class="stop screen off" style="background: yellow;">
|
||||
<h3>STOP!</h3>
|
||||
<h5>...waiting for the other player...</h5>
|
||||
</div>
|
||||
<div class="disqualified screen off white" style="background: red;">
|
||||
<h3>DISQUALIFIED!</h3>
|
||||
</div>
|
||||
<div class="loser screen off white" style="background: red;">
|
||||
<h3>YOU DIED!</h3>
|
||||
</div>
|
||||
<div class="draw screen off white" style="background: red;">
|
||||
<h3>YOU BOTH DIED!</h3>
|
||||
<button onclick="game.reset()">Reset Game</button>
|
||||
</div>
|
||||
<div class="default screen off white" style="background: skyblue;">
|
||||
<h3>YOU WON!</h3>
|
||||
<button onclick="game.reset()">Reset</button>
|
||||
</div>
|
||||
<div class="winner screen off white" style="background: skyblue;">
|
||||
<h3>YOU WON!</h3>
|
||||
<form onsubmit="game.rank()">
|
||||
<input placeholder="nickname">
|
||||
<button onclick="game.rank()">Rank</button>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
var game = window.game = {me:{}}
|
||||
//, gun = Gun('https://gunjs.herokuapp.com/gun')
|
||||
, gun = window.gun = Gun('http://localhost:8888' + '/gun')
|
||||
.load('game/duel')
|
||||
;
|
||||
gun.path('name').get(function(val){
|
||||
console.log('gunslinger has results', val);
|
||||
});
|
||||
gun.get(function(player){
|
||||
console.log("Game update", player);
|
||||
if(game.timeout){
|
||||
clearTimeout(game.timeout);
|
||||
} else {
|
||||
game.timeout = setTimeout(game.reset, 15 * 1000);
|
||||
}
|
||||
$('.start').find('#one').text(player.one? 'Taken!' : 'Player 1').attr('disabled', player.one? true : false);
|
||||
$('.start').find('#two').text(player.two? 'Taken!' : 'Player 2').attr('disabled', player.two? true : false);
|
||||
$('.start').find('#fastest').text(player.fastest || 'no');
|
||||
$('.start').find('#slinger').text(player.slinger || 'nobody');
|
||||
$('.start').find('#previous').text(player.previous || 'no');
|
||||
$('.start').find('#last').text(player.last || 'no one');
|
||||
game.start(player);
|
||||
game.compare(player);
|
||||
});
|
||||
gun.path('dqed').get(function(){
|
||||
if(!game.me.player || game.me.dqed){ return }
|
||||
game.me.default = true;
|
||||
game.screen('default');
|
||||
});
|
||||
gun.path('one').get(function(val){
|
||||
console.log('gun player one', val);
|
||||
if(null === val){
|
||||
game.cancel();
|
||||
}
|
||||
})
|
||||
game.start = function(player){
|
||||
if(game.me.started){ return }
|
||||
if(!player.one || !player.two){ return }
|
||||
if(!player || !game.me || !game.me.player){ return }
|
||||
console.log("start?", player, game.me);
|
||||
if(player[game.me.player] == game.me[game.me.player]){
|
||||
game.screen('shoot');
|
||||
game.coordinate();
|
||||
} else {
|
||||
game.cancel();
|
||||
}
|
||||
}
|
||||
gun.path('coordinate').get(game.coordinate = function(at){
|
||||
if(!game.me.player){ return }
|
||||
var started = game.me.started = Gun.roulette();
|
||||
if(at){
|
||||
Gun.schedule(at, function(){
|
||||
if(game.me.dqed || game.me.default || started != game.me.started){ return }
|
||||
game.screen('fire');
|
||||
game.me.draw = (+new Date());
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(game.me.player != 'two'){ return }
|
||||
game.me.coordinate = (+new Date()) + Math.round(Math.random() * 2000 + 2700); // MIN is the right number, and MAX is the SUM of both numbers.
|
||||
gun.path('coordinate').set(game.me.coordinate);
|
||||
});
|
||||
game.compare = function(score){
|
||||
if(!game.me.player || game.me.over || !score.onespeed || !score.twospeed){ return }
|
||||
if(score.onespeed < score.twospeed){
|
||||
if(game.me.one){
|
||||
win(score.onespeed);
|
||||
} else {
|
||||
game.screen('loser');
|
||||
}
|
||||
} else
|
||||
if(score.twospeed < score.onespeed){
|
||||
if(game.me.two){
|
||||
win(score.twospeed);
|
||||
} else {
|
||||
game.screen('loser');
|
||||
}
|
||||
} else {
|
||||
game.screen('draw');
|
||||
}
|
||||
function win(speed){
|
||||
game.me.over = true;
|
||||
game.screen('winner');
|
||||
speed = speed / 1000; // convert to seconds
|
||||
if(score.fastest && speed < score.fastest){
|
||||
gun.path('fastest').set(speed);
|
||||
game.me.fastest = true;
|
||||
}
|
||||
gun.path('previous').set(speed);
|
||||
}
|
||||
}
|
||||
game.rank = function(){
|
||||
var nick = $(".winner").find('input').val() || 'Masked Cowboy';
|
||||
gun.path('last').set(nick);
|
||||
if(game.me.fastest){
|
||||
gun.path('slinger').set(nick);
|
||||
}
|
||||
game.reset();
|
||||
}
|
||||
game.reset = function(){
|
||||
console.log("Resetting game");
|
||||
gun.path('one').set(null);
|
||||
gun.path('two').set(null);
|
||||
gun.path('dqed').set(null);
|
||||
gun.path('coordinate').set(null);
|
||||
gun.path('onespeed').set(null);
|
||||
gun.path('twospeed').set(null);
|
||||
game.cancel();
|
||||
}
|
||||
game.cancel = function(){
|
||||
game.screen();
|
||||
game.me = {};
|
||||
}
|
||||
game.screen = function(screen){
|
||||
$('.screen').addClass('off').filter('.' + (screen || 'start')).removeClass('off');
|
||||
}
|
||||
$('.player').on('click', function(){
|
||||
if(game.me.player){ return }
|
||||
game.me = {};
|
||||
gun.path(game.me.player = this.id).set(game.me[game.me.player] = Gun.roulette());
|
||||
});
|
||||
$('.shoot').on('click', function(){
|
||||
if(!game.me.player){ return }
|
||||
game.me.dqed = true;
|
||||
game.screen('disqualified');
|
||||
gun.path('dqed').set(game.me[game.me.player]);
|
||||
});
|
||||
$('.fire').on('click', function(){
|
||||
if(!game.me.player || game.me.fired){ return }
|
||||
game.me.fired = (+new Date());
|
||||
game.me.speed = game.me.fired - game.me.draw;
|
||||
gun.path(game.me.player + 'speed').set(game.me.speed);
|
||||
game.screen('stop');
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</center></body>
|
||||
</html>
|
@ -34,6 +34,9 @@
|
||||
.white {
|
||||
color: white;
|
||||
}
|
||||
.winner input, .winner button {
|
||||
font-size: 18pt;
|
||||
}
|
||||
</style>
|
||||
<div class="start screen">
|
||||
<!--<pre>
|
||||
@ -49,6 +52,8 @@
|
||||
<button id="one" class="player">Player 1</button>
|
||||
<button id="two" class="player">Player 2</button>
|
||||
<h5>Next game available in 15 seconds or less...<h5>
|
||||
<h4>Fastest draw in the west, <span id="fastest">no</span> seconds, by <span id="slinger">nobody</span>.</h4>
|
||||
<h5>Previous duel won in <span id="previous">no</span> seconds, by <span id="last">no one</span>.</h5>
|
||||
</div>
|
||||
<div class="shoot screen off white" style="background: tan;">
|
||||
<h3>GET READY!</h3>
|
||||
@ -71,15 +76,22 @@
|
||||
<h3>YOU BOTH DIED!</h3>
|
||||
<button onclick="game.reset()">Reset Game</button>
|
||||
</div>
|
||||
<div class="default screen off white" style="background: skyblue;">
|
||||
<h3>YOU WON!</h3>
|
||||
<button onclick="game.reset()">Reset</button>
|
||||
</div>
|
||||
<div class="winner screen off white" style="background: skyblue;">
|
||||
<h3>YOU WON!</h3>
|
||||
<button onclick="game.reset()">Reset Game</button>
|
||||
<form onsubmit="game.rank()">
|
||||
<input placeholder="nickname">
|
||||
<button onclick="game.rank()">Rank</button>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
var game = window.game = {me:{}}
|
||||
//, gun = Gun(location.origin + '/gun')
|
||||
, gun = window.gun = Gun('http://localhost:8888' + '/gun')
|
||||
, gun = Gun('https://gunjs.herokuapp.com/gun')
|
||||
//, gun = window.gun = Gun('http://localhost:8888' + '/gun')
|
||||
.load('game/duel')
|
||||
;
|
||||
gun.path('name').get(function(val){
|
||||
@ -94,13 +106,17 @@
|
||||
}
|
||||
$('.start').find('#one').text(player.one? 'Taken!' : 'Player 1').attr('disabled', player.one? true : false);
|
||||
$('.start').find('#two').text(player.two? 'Taken!' : 'Player 2').attr('disabled', player.two? true : false);
|
||||
$('.start').find('#fastest').text(player.fastest || 'no');
|
||||
$('.start').find('#slinger').text(player.slinger || 'nobody');
|
||||
$('.start').find('#previous').text(player.previous || 'no');
|
||||
$('.start').find('#last').text(player.last || 'no one');
|
||||
game.start(player);
|
||||
game.compare(player);
|
||||
});
|
||||
gun.path('dqed').get(function(){
|
||||
if(!game.me.player || game.me.dqed){ return }
|
||||
game.me.default = true;
|
||||
game.screen('winner');
|
||||
game.screen('default');
|
||||
});
|
||||
gun.path('one').get(function(val){
|
||||
console.log('gun player one', val);
|
||||
@ -136,23 +152,41 @@
|
||||
gun.path('coordinate').set(game.me.coordinate);
|
||||
});
|
||||
game.compare = function(score){
|
||||
if(!game.me.player || !score.onespeed || !score.twospeed){ return }
|
||||
if(!game.me.player || game.me.over || !score.onespeed || !score.twospeed){ return }
|
||||
if(score.onespeed < score.twospeed){
|
||||
if(game.me.one){
|
||||
game.screen('winner');
|
||||
win(score.onespeed);
|
||||
} else {
|
||||
game.screen('loser');
|
||||
}
|
||||
} else
|
||||
if(score.twospeed < score.onespeed){
|
||||
if(game.me.two){
|
||||
game.screen('winner');
|
||||
win(score.twospeed);
|
||||
} else {
|
||||
game.screen('loser');
|
||||
}
|
||||
} else {
|
||||
game.screen('draw');
|
||||
}
|
||||
function win(speed){
|
||||
game.me.over = true;
|
||||
game.screen('winner');
|
||||
speed = speed / 1000; // convert to seconds
|
||||
if(score.fastest && speed < score.fastest){
|
||||
gun.path('fastest').set(speed);
|
||||
game.me.fastest = true;
|
||||
}
|
||||
gun.path('previous').set(speed);
|
||||
}
|
||||
}
|
||||
game.rank = function(){
|
||||
var nick = $(".winner").find('input').val() || 'Masked Cowboy';
|
||||
gun.path('last').set(nick);
|
||||
if(game.me.fastest){
|
||||
gun.path('slinger').set(nick);
|
||||
}
|
||||
game.reset();
|
||||
}
|
||||
game.reset = function(){
|
||||
console.log("Resetting game");
|
||||
|
195
examples/admin/slinger_.html
Normal file
@ -0,0 +1,195 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="https://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="../../gun.js"></script>
|
||||
</head>
|
||||
<body><center>
|
||||
<style>
|
||||
html, body {
|
||||
font-family: Papyrus, fantasy;
|
||||
font-size: 18pt;
|
||||
}
|
||||
.start .player {
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 1.5em;
|
||||
background: skyblue;
|
||||
font-family: Papyrus, fantasy;
|
||||
}
|
||||
.screen {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.off {
|
||||
display: none;
|
||||
}
|
||||
.white {
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
<div class="start screen">
|
||||
<!--<pre>
|
||||
¦¦¦¦¦¦+ ¦¦+ ¦¦+ ¦¦¦+ ¦¦+ ¦¦¦¦¦¦¦+ ¦¦+ ¦¦+ ¦¦¦+ ¦¦+ ¦¦¦¦¦¦+ ¦¦¦¦¦¦¦+ ¦¦¦¦¦¦+
|
||||
¦¦+----+ ¦¦¦ ¦¦¦ ¦¦¦¦+ ¦¦¦ ¦¦+----+ ¦¦¦ ¦¦¦ ¦¦¦¦+ ¦¦¦ ¦¦+----+ ¦¦+----+ ¦¦+--¦¦+
|
||||
¦¦¦ ¦¦¦+ ¦¦¦ ¦¦¦ ¦¦+¦¦+ ¦¦¦ ¦¦¦¦¦¦¦+ ¦¦¦ ¦¦¦ ¦¦+¦¦+ ¦¦¦ ¦¦¦ ¦¦¦+ ¦¦¦¦¦+ ¦¦¦¦¦¦++
|
||||
¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦+¦¦+¦¦¦ +----¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦+¦¦+¦¦¦ ¦¦¦ ¦¦¦ ¦¦+--+ ¦¦+--¦¦+
|
||||
+¦¦¦¦¦¦++ +¦¦¦¦¦¦++ ¦¦¦ +¦¦¦¦¦ ¦¦¦¦¦¦¦¦ ¦¦¦¦¦¦¦+ ¦¦¦ ¦¦¦ +¦¦¦¦¦ +¦¦¦¦¦¦++ ¦¦¦¦¦¦¦+ ¦¦¦ ¦¦¦
|
||||
+-----+ +-----+ +-+ +---+ +------+ +------+ +-+ +-+ +---+ +-----+ +------+ +-+ +-+
|
||||
</pre>-->
|
||||
<h1>GUN SLINGER</h1>
|
||||
<h3>Select!</h3>
|
||||
<button id="one" class="player">Player 1</button>
|
||||
<button id="two" class="player">Player 2</button>
|
||||
<h5>Next game available in 15 seconds or less...<h5>
|
||||
</div>
|
||||
<div class="shoot screen off white" style="background: tan;">
|
||||
<h3>GET READY!</h3>
|
||||
</div>
|
||||
<div class="fire screen off" style="background: lime;">
|
||||
<h3>FIRE!</h3>
|
||||
<h5>by tapping this screen</h5>
|
||||
</div>
|
||||
<div class="stop screen off" style="background: yellow;">
|
||||
<h3>STOP!</h3>
|
||||
<h5>...waiting for the other player...</h5>
|
||||
</div>
|
||||
<div class="disqualified screen off white" style="background: red;">
|
||||
<h3>DISQUALIFIED!</h3>
|
||||
</div>
|
||||
<div class="loser screen off white" style="background: red;">
|
||||
<h3>YOU DIED!</h3>
|
||||
</div>
|
||||
<div class="draw screen off white" style="background: red;">
|
||||
<h3>YOU BOTH DIED!</h3>
|
||||
<button onclick="game.reset()">Reset Game</button>
|
||||
</div>
|
||||
<div class="winner screen off white" style="background: skyblue;">
|
||||
<h3>YOU WON!</h3>
|
||||
<button onclick="game.reset()">Reset Game</button>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
var game = window.game = {me:{}}
|
||||
, gun = Gun('https://gunjs.herokuapp.com/gun')
|
||||
//, gun = window.gun = Gun('http://localhost:8888' + '/gun')
|
||||
.load('game/duel')
|
||||
;
|
||||
gun.path('name').get(function(val){
|
||||
console.log('gunslinger has results', val);
|
||||
});
|
||||
gun.get(function(player){
|
||||
console.log("Game update", player);
|
||||
if(game.timeout){
|
||||
clearTimeout(game.timeout);
|
||||
} else {
|
||||
game.timeout = setTimeout(game.reset, 15 * 1000);
|
||||
}
|
||||
$('.start').find('#one').text(player.one? 'Taken!' : 'Player 1').attr('disabled', player.one? true : false);
|
||||
$('.start').find('#two').text(player.two? 'Taken!' : 'Player 2').attr('disabled', player.two? true : false);
|
||||
game.start(player);
|
||||
game.compare(player);
|
||||
});
|
||||
gun.path('dqed').get(function(){
|
||||
if(!game.me.player || game.me.dqed){ return }
|
||||
game.me.default = true;
|
||||
game.screen('winner');
|
||||
});
|
||||
gun.path('one').get(function(val){
|
||||
console.log('gun player one', val);
|
||||
if(null === val){
|
||||
game.cancel();
|
||||
}
|
||||
})
|
||||
game.start = function(player){
|
||||
if(game.me.started){ return }
|
||||
if(!player.one || !player.two){ return }
|
||||
if(!player || !game.me || !game.me.player){ return }
|
||||
console.log("start?", player, game.me);
|
||||
if(player[game.me.player] == game.me[game.me.player]){
|
||||
game.screen('shoot');
|
||||
game.coordinate();
|
||||
} else {
|
||||
game.cancel();
|
||||
}
|
||||
}
|
||||
gun.path('coordinate').get(game.coordinate = function(at){
|
||||
if(!game.me.player){ return }
|
||||
var started = game.me.started = Gun.roulette();
|
||||
if(at){
|
||||
Gun.schedule(at, function(){
|
||||
if(game.me.dqed || game.me.default || started != game.me.started){ return }
|
||||
game.screen('fire');
|
||||
game.me.draw = (+new Date());
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(game.me.player != 'two'){ return }
|
||||
game.me.coordinate = (+new Date()) + Math.round(Math.random() * 2000 + 2700); // MIN is the right number, and MAX is the SUM of both numbers.
|
||||
gun.path('coordinate').set(game.me.coordinate);
|
||||
});
|
||||
game.compare = function(score){
|
||||
if(!game.me.player || !score.onespeed || !score.twospeed){ return }
|
||||
if(score.onespeed < score.twospeed){
|
||||
if(game.me.one){
|
||||
game.screen('winner');
|
||||
} else {
|
||||
game.screen('loser');
|
||||
}
|
||||
} else
|
||||
if(score.twospeed < score.onespeed){
|
||||
if(game.me.two){
|
||||
game.screen('winner');
|
||||
} else {
|
||||
game.screen('loser');
|
||||
}
|
||||
} else {
|
||||
game.screen('draw');
|
||||
}
|
||||
}
|
||||
game.reset = function(){
|
||||
console.log("Resetting game");
|
||||
gun.path('one').set(null);
|
||||
gun.path('two').set(null);
|
||||
gun.path('dqed').set(null);
|
||||
gun.path('coordinate').set(null);
|
||||
gun.path('onespeed').set(null);
|
||||
gun.path('twospeed').set(null);
|
||||
game.cancel();
|
||||
}
|
||||
game.cancel = function(){
|
||||
game.screen();
|
||||
game.me = {};
|
||||
}
|
||||
game.screen = function(screen){
|
||||
$('.screen').addClass('off').filter('.' + (screen || 'start')).removeClass('off');
|
||||
}
|
||||
$('.player').on('click', function(){
|
||||
if(game.me.player){ return }
|
||||
game.me = {};
|
||||
gun.path(game.me.player = this.id).set(game.me[game.me.player] = Gun.roulette());
|
||||
});
|
||||
$('.shoot').on('click', function(){
|
||||
if(!game.me.player){ return }
|
||||
game.me.dqed = true;
|
||||
game.screen('disqualified');
|
||||
gun.path('dqed').set(game.me[game.me.player]);
|
||||
});
|
||||
$('.fire').on('click', function(){
|
||||
if(!game.me.player || game.me.fired){ return }
|
||||
game.me.fired = (+new Date());
|
||||
game.me.speed = game.me.fired - game.me.draw;
|
||||
gun.path(game.me.player + 'speed').set(game.me.speed);
|
||||
game.screen('stop');
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</center></body>
|
||||
</html>
|
5
examples/cats/get.js
Normal file
@ -0,0 +1,5 @@
|
||||
var gun = require('gun')({
|
||||
s3: (process.env.NODE_ENV === 'production')? null : require('../../test/shotgun') // replace this with your own keys!
|
||||
});
|
||||
|
||||
gun.load('kitten/hobbes').path('servant.cat.servant.name').get(function(name){ console.log(name) })
|
13
examples/cats/load.js
Normal file
@ -0,0 +1,13 @@
|
||||
var gun = require('gun')({
|
||||
s3: (process.env.NODE_ENV === 'production')? null : require('../../test/shotgun') // replace this with your own keys!
|
||||
});
|
||||
|
||||
gun.load('email/mark@gundb.io', function(Mark){
|
||||
console.log("Hello ", Mark);
|
||||
this.path('username').set('amark'); // because we hadn't saved it yet!
|
||||
this.path('cat').get(function(Hobbes){ // `this` is context of the nodes you explore via path
|
||||
console.log(Hobbes);
|
||||
this.set({ servant: Mark, coat: "tabby" }); // oh no! Hobbes has become Mark's master.
|
||||
this.key('kitten/hobbes'); // cats are taking over the internet! Better make an index for them.
|
||||
});
|
||||
});
|
7
examples/cats/set.js
Normal file
@ -0,0 +1,7 @@
|
||||
var gun = require('gun')({
|
||||
s3: (process.env.NODE_ENV === 'production')? null : require('../../test/shotgun') // replace this with your own keys!
|
||||
});
|
||||
|
||||
gun.set({ name: "Mark Nadal", email: "mark@gunDB.io", cat: { name: "Hobbes", species: "kitty" } })
|
||||
.key('email/mark@gundb.io')
|
||||
;
|
27
gate/s3.js
@ -127,4 +127,29 @@
|
||||
return this;
|
||||
}
|
||||
return s3;
|
||||
})(require('../gun'), {});
|
||||
})(require('../gun'), {});
|
||||
/**
|
||||
Knox S3 Config is:
|
||||
knox.createClient({
|
||||
key: ''
|
||||
, secret: ''
|
||||
, bucket: ''
|
||||
, endpoint: 'us-standard'
|
||||
, port: 0
|
||||
, secure: true
|
||||
, token: ''
|
||||
, style: ''
|
||||
, agent: ''
|
||||
});
|
||||
|
||||
aws-sdk for s3 is:
|
||||
{ "accessKeyId": "akid", "secretAccessKey": "secret", "region": "us-west-2" }
|
||||
AWS.config.loadFromPath('./config.json');
|
||||
{
|
||||
accessKeyId: process.env.AWS_ACCESS_KEY_ID = ''
|
||||
,secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY = ''
|
||||
,Bucket: process.env.s3Bucket = ''
|
||||
,region: process.env.AWS_REGION = "us-east-1"
|
||||
,sslEnabled: ''
|
||||
}
|
||||
**/
|
18
gun.js
@ -13,6 +13,7 @@
|
||||
}
|
||||
;(function(Gun){
|
||||
Gun.is = function(gun){ return (gun instanceof Gun)? true : false }
|
||||
Gun.version = 0.8;
|
||||
Gun.union = function(graph, prime){
|
||||
var context = Gun.shot();
|
||||
context.nodes = {};
|
||||
@ -178,7 +179,8 @@
|
||||
}
|
||||
Chain.load = function(key, cb, opt){
|
||||
var gun = this.chain();
|
||||
gun.shot.then(cb = cb || function(){});
|
||||
cb = cb || function(){};
|
||||
gun.shot.then(function(){ cb.apply(gun, arguments) });
|
||||
cb.soul = (key||{})[Gun._.soul];
|
||||
if(cb.soul){
|
||||
cb.node = gun.__.graph[cb.soul];
|
||||
@ -250,7 +252,7 @@
|
||||
gun.back.shot.then(function trace(node){ // should handle blank and err! Err already handled?
|
||||
//console.log("shot path", path, node);
|
||||
gun.field = null;
|
||||
gun._.node = gun.back._.node;
|
||||
gun._.node = node;
|
||||
if(!path.length){ // if the path resolves to another node, we finish here
|
||||
return gun.shot('then').fire(node); // already frozen from loaded.
|
||||
}
|
||||
@ -301,16 +303,16 @@
|
||||
The live state at point of confirmation may or may not be different than when it was called.
|
||||
If this causes any application-level concern, it can compare against the live data by immediately reading it, or accessing the logs if enabled.
|
||||
*/
|
||||
Chain.set = function(val, cb, opt){ // TODO: set failed miserably to catch depth references in social tests
|
||||
Chain.set = function(val, cb, opt){ // TODO: need to turn deserializer into a trampolining function so stackoverflow doesn't happen.
|
||||
opt = opt || {};
|
||||
var gun = this, set;
|
||||
gun.shot.then(function(){
|
||||
if(gun.field){ // a field cannot be 0!
|
||||
set = {}; // in case we are doing a set on a field, not on a node
|
||||
set[gun.field] = val; // we create a blank node with the field/value to be set
|
||||
set._ = Gun.ify.soul.call(gun, {}, gun._.node); // and then set their souls to be the same
|
||||
val = set; // that way they will merge correctly for us during the union!
|
||||
}
|
||||
val = set;
|
||||
} // TODO: should be able to handle val being a relation or a gun context or a gun promise.
|
||||
val._ = Gun.ify.soul.call(gun, {}, gun._.node); // and then set their souls to be the same that way they will merge correctly for us during the union!
|
||||
cb = Gun.fns.is(cb)? cb : function(){};
|
||||
set = Gun.ify.call(gun, val);
|
||||
cb.root = set.root;
|
||||
@ -823,7 +825,7 @@
|
||||
tab.set = tab.set || function(nodes, cb){
|
||||
cb = cb || function(){};
|
||||
// TODO: batch and throttle later.
|
||||
tab.store.set(cb.id = 'send/' + Gun.text.random(), nodes);
|
||||
//tab.store.set(cb.id = 'send/' + Gun.text.random(), nodes);
|
||||
//tab.url(nodes);
|
||||
Gun.obj.map(gun.__.opt.peers, function(peer, url){
|
||||
tab.ajax(url, nodes, function respond(err, reply, id){
|
||||
@ -850,7 +852,7 @@
|
||||
return;
|
||||
}
|
||||
if(body.reply || body.defer || body.refed){ return }
|
||||
tab.store.del(respond.id);
|
||||
//tab.store.del(respond.id);
|
||||
}, {headers: {'Gun-Sub': tab.subscribe.sub || ''}});
|
||||
});
|
||||
Gun.obj.map(nodes, function(node, soul){
|
||||
|
@ -1,5 +1,5 @@
|
||||
{ "name": "gun"
|
||||
, "version": "0.0.7"
|
||||
, "version": "0.0.8"
|
||||
, "author": "Mark Nadal"
|
||||
, "description": "Graph engine."
|
||||
, "engines": {
|
||||
|
28
shots.js
@ -1,4 +1,5 @@
|
||||
;(function(){
|
||||
console.log("Hello wonderful person! :) I'm mark@gunDB.io, message me for help or with hatemail. I want to hear from you! <3");
|
||||
var Gun = require(__dirname+'/gun')
|
||||
, S3 = require(__dirname+'/gate/s3') // redis has been removed, can be replaced with a disk system
|
||||
, formidable = require('formidable')
|
||||
@ -438,29 +439,4 @@
|
||||
}
|
||||
};
|
||||
module.exports = Gun;
|
||||
}());
|
||||
/**
|
||||
Knox S3 Config is:
|
||||
knox.createClient({
|
||||
key: ''
|
||||
, secret: ''
|
||||
, bucket: ''
|
||||
, endpoint: 'us-standard'
|
||||
, port: 0
|
||||
, secure: true
|
||||
, token: ''
|
||||
, style: ''
|
||||
, agent: ''
|
||||
});
|
||||
|
||||
aws-sdk for s3 is:
|
||||
{ "accessKeyId": "akid", "secretAccessKey": "secret", "region": "us-west-2" }
|
||||
AWS.config.loadFromPath('./config.json');
|
||||
{
|
||||
accessKeyId: process.env.AWS_ACCESS_KEY_ID = ''
|
||||
,secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY = ''
|
||||
,Bucket: process.env.s3Bucket = ''
|
||||
,region: process.env.AWS_REGION = "us-east-1"
|
||||
,sslEnabled: ''
|
||||
}
|
||||
**/
|
||||
}());
|
BIN
web/deck/colors.png
Normal file
After Width: | Height: | Size: 2.1 MiB |
BIN
web/deck/dbs.png
Normal file
After Width: | Height: | Size: 192 KiB |
BIN
web/deck/failwhale.png
Normal file
After Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 27 KiB |
@ -69,48 +69,17 @@
|
||||
<i>Adam Draper, Boost;</i>
|
||||
</div>
|
||||
</div>
|
||||
<div id="team" class="screen break"><div style="height: 12%"></div>
|
||||
<div class="big">Team</div>
|
||||
<div><i>Here are the people powering the<br>"Open Source Firebase", "Dropbox for Developers", or "Bitcoin for Data".</i></div>
|
||||
<br>
|
||||
<div>
|
||||
<div>
|
||||
<img src="prudential.gif" style="height: 2.5em">
|
||||
<img src="ucla.png" style="height: 2.5em">
|
||||
<img src="thiel.svg" style="height: 2.3em">
|
||||
</div>
|
||||
<b>Mark Nadal</b>
|
||||
CEO, 4 years experience in Synchronization Systems.
|
||||
<div class="small">
|
||||
Consulting clientele include a Thiel Fellow,
|
||||
prototyped Prudential Retirement's SuperBowl advert's online interactive,
|
||||
startup UCLA alumni.
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<div>
|
||||
<img src="stackoverflow.png" style="height: 3em">
|
||||
<img src="boi.png" style="height: 3em">
|
||||
<img src="nodejs.png" style="height: 2.7em">
|
||||
</div>
|
||||
<b>AJ ONeal</b>
|
||||
CIO, 8 years experience with Software and Database Architecture.
|
||||
<div class="small">
|
||||
Contributor to NodeJS core,
|
||||
in the top 1 percentile rank of all StackOverflow users,
|
||||
built a Billboard Hot 100 rap artist's Twitter feed client.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="problem" class="screen break"><div style="height: 10%"></div>
|
||||
|
||||
</div>
|
||||
<!--<div id="problem" class="screen break"><div style="height: 10%"></div>
|
||||
<div class="big">Problem</div>
|
||||
<div>Businesses struggle with "sharding" data.</div>
|
||||
<div>Concurrency is infamous within software, and we solve it.</div>
|
||||
<img src="jargon.png" height="50%" title="via http://tagul.com">
|
||||
<div class="small">The amount of academic jargon invented for the topic is absurd.</div>
|
||||
<div>"<i>There are only two hard things in Computer Science: cache invalidation and naming things.</i>" ~ Phil Karlton</div>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="screen break"><div style="height: 10%"></div>
|
||||
<div id="how" class="big">How</div>
|
||||
<div>
|
||||
@ -162,6 +131,40 @@
|
||||
<div>Gun is the union of these two niches.</div>
|
||||
<div><b>The facts predict they are the buzzwords of the future.</b></div>
|
||||
</div>
|
||||
<div id="team" class="screen break"><div style="height: 12%"></div>
|
||||
<div class="big">Team</div>
|
||||
<div><i>Here are the people powering the<br>"Open Source Firebase", "Dropbox for Developers", or "Bitcoin for Data".</i></div>
|
||||
<br>
|
||||
<div>
|
||||
<div>
|
||||
<img src="prudential.gif" style="height: 2.5em">
|
||||
<img src="ucla.png" style="height: 2.5em">
|
||||
<img src="thiel.svg" style="height: 2.3em">
|
||||
</div>
|
||||
<b>Mark Nadal</b>
|
||||
CEO, 4 years experience in Synchronization Systems.
|
||||
<div class="small">
|
||||
Consulting clientele include a Thiel Fellow,
|
||||
prototyped Prudential Retirement's SuperBowl advert's online interactive,
|
||||
startup UCLA alumni.
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<div>
|
||||
<img src="stackoverflow.png" style="height: 3em">
|
||||
<img src="boi.png" style="height: 3em">
|
||||
<img src="nodejs.png" style="height: 2.7em">
|
||||
</div>
|
||||
<b>AJ ONeal</b>
|
||||
CIO, 8 years experience with Software and Database Architecture.
|
||||
<div class="small">
|
||||
Contributor to NodeJS core,
|
||||
in the top 1 percentile rank of all StackOverflow users,
|
||||
built a Billboard Hot 100 rap artist's Twitter feed client.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="text-align: center; padding: 2.5em 0 4em;">
|
||||
<div id="how" class="big">You?</div>
|
||||
<div>
|
||||
|
BIN
web/deck/lang.png
Normal file
After Width: | Height: | Size: 137 KiB |
BIN
web/deck/npm.png
Before Width: | Height: | Size: 15 KiB |
BIN
web/deck/polygen.png
Normal file
After Width: | Height: | Size: 987 KiB |
BIN
web/deck/stat.png
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
web/deck/stats.png
Normal file
After Width: | Height: | Size: 65 KiB |
BIN
web/deck/team.jpg
Normal file
After Width: | Height: | Size: 347 KiB |