gun/web/time.html
2015-01-14 13:29:15 -07:00

507 lines
18 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!--
<script src="../gun.js"></script>
<link id="style" rel="stylesheet" href="https://yandex.st/highlightjs/8.0/styles/sunburst.min.css">
<script src="https://yandex.st/highlightjs/8.0/highlight.min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/4374976/random/phrase.js"></script>
-->
</head>
<body>
<style>
@import url(https://fonts.googleapis.com/css?family=Dosis|Poiret+One|Oxygen);
html, body {
margin: 0;
padding: 0;
height: 100%;
font-family: 'Oxygen', Candara, Calibri, Segoe, "Segoe UI", Optima, Arial, sans-serif;
}
.center {
text-align: center;
}
.lean {
font-family: 'Poiret One', Candara, Calibri, Segoe, "Segoe UI", Optima, Arial, sans-serif;
}
.clean {
font-family: 'Dosis', Candara, Calibri, Segoe, "Segoe UI", Optima, Arial, sans-serif;
}
.crisp {
font-family: 'Oxygen', Candara, Calibri, Segoe, "Segoe UI", Optima, Arial, sans-serif;
}
pre {
background-color: black;
border: 1px dashed white;
color: white;
line-height: 1.5em;
padding: 1em;
overflow: hidden;
}
button {
border: none;
color: white;
background: skyblue;
padding: 1em;
cursor: pointer;
}
input {
background: transparent;
border: 2px dashed grey;
padding: 1em;
}
.step {
display: none;
}
.step:target {
display: block;
}
.grid {
text-align: center;
}
.unit {
display: inline-block;
}
.learn {
min-width: 250px;
max-width: 400px;
width: 30%;
padding: 2em;
}
.svg {
background: white url('./img/devices.svg') no-repeat 50% 50%;
height: 40em;
}
.GUN {
background: transparent url('./img/gun.svg') no-repeat 50% 50%;
background-size: 60%;
}
.dull {
background-color: #EEE;
-webkit-transition: background-color 600ms linear;
-moz-transition: background-color 600ms linear;
transition: background-color 600ms linear;
}
.blue {
background-color: skyblue;
-webkit-transition: background-color 600ms linear;
-moz-transition: background-color 600ms linear;
transition: background-color 600ms linear;
}
.red {
background-color: red;
-webkit-transition: background-color 600ms linear;
-moz-transition: background-color 600ms linear;
transition: background-color 600ms linear;
}
.green {
background-color: MediumSpringGreen;
-webkit-transition: background-color 600ms linear;
-moz-transition: background-color 600ms linear;
transition: background-color 600ms linear;
}
.fold {
width: 100%;
height: 100%;
min-height: 450px;
position: relative;
}
.grid {
display: inline-block;
}
@media (max-width: 760px) {
body {
font-siz----e: 10pt;
}
}
@media (max-width: 1279px) {
.wide {
display: none;
}
}
</style>
<div class="fold">
<div class="behold" style="overflow: hidden; position: relative; width: 100%; min-height 400px; margin: -200px 0 0; padding:0; top: 40%; text-align: center;">
<div class="graphic grid" style="min-width: 300px; max-width: 600px; height: 400px;
position: relative; margin:0 auto; padding:0;">
<img src="./img/server.png" class="server" style="position: absolute; top: 2%; left: 35%; wid-th: 50%;">
<div class="desktop" style="height: 10em; width: 17em; position: absolute; top: 36%; left: 3%;">
<div class="monitor" style="height: 100%; width: 100%; background: #222; padding: .75em; margin-left: -.75em; border-radius: 1em;">
<div class="dull screen GUN" style="height: 100%; width: 100%;">
</div>
</div>
<div class="stand" style="margin: 1px auto 0px;
border-bottom: 2.75em solid #888;
border-left: .5em solid transparent;
border-right: .5em solid transparent;
height: 0;
width: 3.2em;">
</div>
<div class="stand" style="width: 6em; height: .5em; background: #888; margin: 0px auto"></div>
</div>
<div class="laptop" style="height: 7em; width: 12em; position: absolute; top: 60%; left: 48%;">
<div class="lid" style="height: 100%; width: 100%; background: #222; padding: .6em; margin-left: -.6em; border-radius: .6em .6em 0em 0em;">
<div class="dull screen GUN" style="height: 100%; width: 100%;">
</div>
</div>
<div class="case" style="height: .75em; width: 140%; margin-left: -20%; background: #999; border-radius: 0em 0em 5em 5em;">
</div>
</div>
<div class="phone" style="height: 3.75em; width: 2.25em; position: absolute; top: 35%; left: 70%;">
<div class="case" style="height: 100%; width: 100%; background: #222; padding: .5em .2em; margin-left: -.2em; border-radius: 0.25em;">
<div class="dull screen GUN" style="height: 100%; width: 100%;">
</div>
</div>
</div>
<div class="arrow desktop-server" style="width: 52px; height: 52px; border: dashed 0px FireBrick; border-radius: 50px 0 0 0;
position: absolute; left: 20%; top: 15%; border-width: 3px 0px 0px 3px;">
<div class="rarr" style="position: absolute; top: -.59em; right: -.7em;
width: 0;
height: 0;
border-top: .5em solid transparent;
border-left: 1em solid FireBrick;
border-bottom: .5em solid transparent;">
</div>
<div class="darr" style="position: absolute; bottom: -.75em; left: -.59em;
width: 0;
height: 0;
border-left: .5em solid transparent;
border-right: .5em solid transparent;
border-top: 1em solid FireBrick;">
</div>
</div>
<div class="arrow phone-server" style="width: 26px; height: 52px; border: dashed 0px FireBrick; border-radius: 0 0 50px 0;
position: absolute; left: 80%; top: 35%; border-width: 0px 3px 3px 0px;">
<div class="uarr" style="position: absolute; top: -.9em; right: -.59em;
width: 0;
height: 0;
border-left: .5em solid transparent;
border-right: .5em solid transparent;
border-bottom: 1em solid FireBrick;">
</div>
<div class="larr" style="position: absolute; bottom: -.55em; left: -.59em;
width: 0;
height: 0;
border-top: .5em solid transparent;
border-right: 1em solid FireBrick;
border-bottom: .5em solid transparent;">
</div>
</div>
<div class="arrow updown laptop-server" style="height: 50px; border: dashed 0px FireBrick; border-radius: 0;
position: absolute; left: 60%; top: 40%; border-width: 0px 3px 0px 0px;">
<div class="uarr" style="position: absolute; top: -1em; left: -.45em;
width: 0;
height: 0;
border-left: .5em solid transparent;
border-right: .5em solid transparent;
border-bottom: 1em solid FireBrick;">
</div>
<div class="darr" style="position: absolute; bottom: -1em; left: -.45em;
width: 0;
height: 0;
border-left: .5em solid transparent;
border-right: .5em solid transparent;
border-top: 1em solid FireBrick;">
</div>
</div>
<span style="color: transparent">Distributed embedded graph database engine. The no pain, no cost, no backend, NoDB database, gun.</span>
</div>
<div class="graphic wide grid" style="min-width: 300px; max-width: 600px; height: 400px;
position: relative; margin:0 auto; padding:0;">
<div class="arrow server-server" style="width: 100px; height: 0px; border: dashed 0px FireBrick; border-radius: 0;
position: absolute; left: -9%; top: 15%; border-width: 3px 0px 0px 0px;">
<div class="rarr" style="position: absolute; top: -.59em; left: -.5em;
width: 0;
height: 0;
border-top: .5em solid transparent;
border-right: 1em solid FireBrick;
border-bottom: .5em solid transparent;">
</div>
<div class="larr" style="position: absolute; top: -.59em; right: -.6em;
width: 0;
height: 0;
border-left: 1em solid FireBrick;
border-bottom: .5em solid transparent;
border-top: .5em solid transparent;">
</div>
</div>
<img src="./img/server.png" class="server" style="position: absolute; top: 2%; right: 35%;">
<div class="desktop" style="height: 10em; width: 17em; position: absolute; top: 36%; right: 3%;">
<div class="monitor" style="height: 100%; width: 100%; background: #222; padding: .75em; margin-left: -.75em; border-radius: 1em;">
<div class="dull screen GUN" style="height: 100%; width: 100%;">
</div>
</div>
<div class="stand" style="margin: 1px auto 0px;
border-bottom: 2.75em solid #888;
border-left: .5em solid transparent;
border-right: .5em solid transparent;
height: 0;
width: 3.2em;">
</div>
<div class="stand" style="width: 6em; height: .5em; background: #888; margin: 0px auto"></div>
</div>
<div class="laptop" style="height: 7em; width: 12em; position: absolute; top: 60%; right: 48%;">
<div class="lid" style="height: 100%; width: 100%; background: #222; padding: .6em; margin-left: -.6em; border-radius: .6em .6em 0em 0em;">
<div class="dull screen GUN" style="height: 100%; width: 100%;">
</div>
</div>
<div class="case" style="height: .75em; width: 140%; margin-left: -20%; background: #999; border-radius: 0em 0em 5em 5em;">
</div>
</div>
<div class="phone" style="height: 3.75em; width: 2.25em; position: absolute; top: 35%; right: 70%;">
<div class="case" style="height: 100%; width: 100%; background: #222; padding: .5em .2em; margin-left: -.2em; border-radius: 0.25em;">
<div class="dull screen GUN" style="height: 100%; width: 100%;">
</div>
</div>
</div>
<div class="arrow desktop-server" style="width: 52px; height: 52px; border: dashed 0px FireBrick; border-radius: 0 50px 0 0;
position: absolute; right: 20%; top: 15%; border-width: 3px 3px 0px 0px;">
<div class="rarr" style="position: absolute; top: -.59em; left: -.5em;
width: 0;
height: 0;
border-top: .5em solid transparent;
border-right: 1em solid FireBrick;
border-bottom: .5em solid transparent;">
</div>
<div class="darr" style="position: absolute; bottom: -.75em; right: -.59em;
width: 0;
height: 0;
border-left: .5em solid transparent;
border-right: .5em solid transparent;
border-top: 1em solid FireBrick;">
</div>
</div>
<div class="arrow phone-server" style="width: 26px; height: 52px; border: dashed 0px FireBrick; border-radius: 0 0 0px 50px;
position: absolute; right: 80.3%; top: 34.3%; border-width: 0px 0px 3px 3px;">
<div class="uarr" style="position: absolute; top: -.8em; left: -.59em;
width: 0;
height: 0;
border-left: .5em solid transparent;
border-right: .5em solid transparent;
border-bottom: 1em solid FireBrick;">
</div>
<div class="rarr" style="position: absolute; bottom: -.55em; right: -.7em;
width: 0;
height: 0;
border-top: .5em solid transparent;
border-left: 1em solid FireBrick;
border-bottom: .5em solid transparent;">
</div>
</div>
<div class="arrow updown laptop-server" style="height: 50px; border: dashed 0px FireBrick; border-radius: 0;
position: absolute; right: 60%; top: 40%; border-width: 0px 3px 0px 0px;">
<div class="uarr" style="position: absolute; top: -1em; left: -.45em;
width: 0;
height: 0;
border-left: .5em solid transparent;
border-right: .5em solid transparent;
border-bottom: 1em solid FireBrick;">
</div>
<div class="darr" style="position: absolute; bottom: -1em; left: -.45em;
width: 0;
height: 0;
border-left: .5em solid transparent;
border-right: .5em solid transparent;
border-top: 1em solid FireBrick;">
</div>
</div>
<span style="color: transparent">Distributed embedded graph database engine. The no pain, no cost, no backend, NoDB database, gun.</span>
</div>
<script>
$(function(){
var c = ['dull', 'blue', 'green']
, a = 'dull blue red green';
$(".screen").click(function(){
c.push(c.shift());
var to = c[0];
$(this).removeClass(a).addClass(to);
$('.screen').not(this).each(function(){
var t = $(this);
setTimeout(function(){
t.removeClass(a).addClass(to);
}, rand(400,700));
});
});
function rand(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
})
</script>
<div class="center" style="margin-top: 2%;">
<div class="lean" style="font-size: 400%;">Easiest Database Ever</div>
<div class="lean" style="font-size: 225%;">Sync state in a cinch at a distributed system scale.</div>
</div>
</div>
</div> <!-- END FOLD -->
<div style="display: none;">
<div class="svg">
AWESOME SAUCE COLOR SYNCING
</div>
<div id="steps">
<div id="step1">
As easy as 1, 2, 3!
<ol>
<li>Connect to a gun server.</li>
<li>Save some data.</li>
<li>Create a key to open it up later.</li>
</ol>
<pre>var gun = Gun('http://localhost:8888/gun');
gun.set({hello: 'world'}).key('<span class="random">my/first/data</span>');</pre>
<a href="#step2" class="run"><button>
Try it Now!
</button></a>
<small>Disclaimer: This is a demo only! Data is deleted every 24 hours.</small>
<!--
<div>
Already have a key? Then
<input placeholder="copy and paste it into here!">
</div>
-->
</div>
<div id="step2" class="step">
Let's test to see if the data got saved.
<ol>
<li><a id="parallel" href="?key=" target="_blank">Open this page</a> in another browser tab.</li>
<li>Now you'll see <b class="random" style="color: crimson;">my/first/data</b> load over there.
<li>Meanwhile, this textarea will wait for realtime updates from the other tab:</li>
</ol>
<textarea style="width: 100%; height: 100px;">// Your data will log here!</textarea>
The next level will be unlocked when you complete the realtime sync between tabs.
</div>
<div id="step3" class="step">
<pre>var gun = Gun('http://localhost:8888/gun');
gun.load('<span class="random">my/first/data</span>', function(err, data){
$('textarea').text(demo.print(data));
});</pre>
<a href="#step4" class="run"><button>
Run the Code!
</button></a> Does the key match from the previous tab?
<textarea style="width: 100%; height: 100px;">// Your data will log here!</textarea>
</div>
<div id="step4" class="step">
Now let's listen to realtime updates, and change the value on the 'hello' field.
<pre>gun.load('<span class="random">my/first/data</span>')
.on(function(updates){
$('textarea').text(demo.print(updates));
}).path('hello').set('You!');</pre>
<a class="run"><button>
Let's do This!
</button></a>
<textarea style="width: 100%; height: 100px;">// Your data will log here!</textarea>
</div>
</div>
<div class="grid">
<div class="learn unit center">
<h1 class="lean">Did you know?</h1>
<h2 class="lean">GUN is lightning fast, cause it runs in memory.</h2>
Click to <a href="#step2" class="run"><button>
See How
</button></a> persistence works.
</div>
<div class="learn unit center">
<h1 class="lean">Guess what!</h1>
<h2 class="lean">GUN is the only database with realtime push notifications.</h2>
Learn <a href="#step2" class="run"><button>
How it Works
</button></a>.
</div>
<div class="learn unit center">
<h1 class="lean">Have Big Data?</h1>
<h2 class="lean">GUN tranforms it into <i>meaningful data</i>, with regular JS.</h2>
Discover <a href="#step2" class="run"><button>
How To
</button></a> do a graph search.
</div>
</div>
<script>
$(function(){
var demo = {}, gun;
window.demo = demo;
demo.key = location.search.split('=')[1];
demo.random = demo.key || random_phrase.noun() +'/'+ random_phrase.verb() +'/'+ random_phrase.adjective() +'/'+ random_phrase.noun() +'/'+ random_phrase.adverb();
$(".random").text(demo.random);
$('pre').each(function(){
$(this).html(hljs.highlight('javascript', $(this).text()).value);
});
$('#step1').addClass((demo.key || location.hash)? 'step' : '').find('a').first().click(function(){
$('#step1').addClass('step');
});
$('#parallel').attr('href', '?key=' + demo.random + '#step3');
$(".run").click(function(){
var code = $(this).closest('.step').attr('id');
if(!code || !demo[code]){ return } // something went wrong!
demo[code]();
});
demo.step0 = function(){
gun = window.gun = window.gun || Gun('http://localhost:8888/gun');
}
demo.step1 = function(){
demo.step0();
gun.set({hello: 'world'}).key(demo.random);
// and also do this, so we can unlock!
gun.load(demo.random)
.on(function(updates){
$('textarea').text(demo.print(updates));
// unlock level 5!
});
}
demo.step2 = function(){} // no step 2
demo.step3 = function(){
demo.step0();
gun.load(demo.random, function(err, data){
$('textarea').text(demo.print(data));
});
}
demo.step4 = function(){
demo.step0();
gun.load(demo.random)
.on(function(updates){
$('textarea').text(demo.print(updates));
}).path('hello').set('You!');
}
demo.print = function(data){
if(!data){ return }
delete data._; // this is gun specific metadata that we don't want to print.
return JSON.stringify(data, null, 2);
}
});
</script>
</div>
<a href="https://github.com/amark/gun" target="_blank" class="wide"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"></a>
</body>
</html>