UI contact

This commit is contained in:
Mark Nadal 2018-01-27 15:02:51 -08:00
parent ee91ae7612
commit 7ecd09ec87
4 changed files with 56 additions and 21 deletions

View File

@ -109,6 +109,31 @@
<div id="info" class="page"> <div id="info" class="page">
<p>A mysterious new example app has appeared! It is not finished/ready yet.</p> <p>A mysterious new example app has appeared! It is not finished/ready yet.</p>
</div id="info"> </div id="info">
<div id="tell" class="model">
<style>
#tell {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 0;
text-align: center;
overflow: visible;
}
#tell .notify {
width: 50%;
background: black;
border: solid #222 0.2em;
top: 0.2em;
margin: 0 auto;
padding: 1%;
opacity: 0.8;
position-anchor: 50% 50%;
}
</style>
<p class="notify">Hello world!</p>
</div>
<!-- script src="/Users/mark/Dropbox/Public/gun/db/examples/jquery.js"></script> <!-- script src="/Users/mark/Dropbox/Public/gun/db/examples/jquery.js"></script>
<script src="/Users/mark/Dropbox/Public/gun/db/gun.js"></script> <script src="/Users/mark/Dropbox/Public/gun/db/gun.js"></script>
@ -118,12 +143,14 @@
<script src="/jquery.js"></script> <script src="/jquery.js"></script>
<script src="/gun.js"></script> <script src="/gun.js"></script>
<script src="/gun/lib/cryptomodules.js"></script>
<script src="/gun/sea.js"></script> <script src="/gun/sea.js"></script>
<script src="/gun/as.js"></script> <script src="/gun/as.js"></script>
<script> <script>
// Check out the interactive tutorial
// for how to build a simplified version
// of this example: https://scrimba.com/c/c2gBgt4
if(location.protocol.indexOf('s') < 0 && location.host.indexOf('localhost') < 0){ location.protocol = 'https:'; }
var gun = Gun(location.origin+'/gun'); var gun = Gun(location.origin+'/gun');
//var gun = Gun();
var app = gun.get('example/contacts/6'); var app = gun.get('example/contacts/6');
var user = gun.user(); var user = gun.user();
var c = window.c = {}; var c = window.c = {};
@ -164,15 +191,15 @@
var form = $(this).closest('form'), data = {alias: form.find('input:first').val(), pass: form.find('input:last').val()}; var form = $(this).closest('form'), data = {alias: form.find('input:first').val(), pass: form.find('input:last').val()};
data.born = Gun.time.is(); data.born = Gun.time.is();
if(!data.alias || data.alias.length < 5){ if(!data.alias || data.alias.length < 5){
console.log("Alias needs to be longer than 5 characters."); c.tell("Alias needs to be longer than 5 characters.");
return; return;
} }
if(!data.pass || data.pass.length < 9){ if(!data.pass || data.pass.length < 9){
console.log("Passphrase needs to be longer than 9 characters."); c.tell("Passphrase needs to be longer than 9 characters.");
return; return;
} }
user.create(data.alias, data.pass, function(ack){ user.create(data.alias, data.pass, function(ack){
if(ack.err){ return } if(ack.err){ c.tell(ack.err); sessionStorage.clear(); user.leave(); return }
if(ack.pub){ if(ack.pub){
gun.get('users').get(data.alias).put(gun.get('alias/'+data.alias)); gun.get('users').get(data.alias).put(gun.get('alias/'+data.alias));
} }
@ -182,30 +209,36 @@
}).on('click','form.sign button:first', become); }).on('click','form.sign button:first', become);
function become(){ function become(){
var form = $(this).closest('form'), data = {alias: form.find('input:first').val(), pass: form.find('input:last').val()}; var form = $(this).closest('form'), data = {alias: form.find('input:first').val(), pass: form.find('input:last').val()};
if(window.sessionStorage){ data.alias = data.alias || sessionStorage.alias;
data.alias = data.alias || sessionStorage.alias; data.pass = data.pass || sessionStorage.tmp;
data.pass = data.pass || sessionStorage.tmp;
}
if(!data.alias || data.alias.length < 5){ if(!data.alias || data.alias.length < 5){
console.log("Alias needs to be longer than 5 characters."); c.tell("Alias needs to be longer than 5 characters.");
return; return;
} }
if(!data.pass || data.pass.length < 9){ if(!data.pass || data.pass.length < 9){
console.log("Passphrase needs to be longer than 9 characters."); c.tell("Passphrase needs to be longer than 9 characters.");
return; return;
} }
user.auth(data.alias, data.pass, function(ack){ user.auth(data.alias, data.pass, function(ack){
if(ack.err){ c.tell(ack.err); sessionStorage.clear(); user.leave(); return }
session(data); session(data);
}); });
} }
if(window.sessionStorage && sessionStorage.tmp){ if(!window.sessionStorage){ window.sessionStorage = {clear:function(){}} }
if(sessionStorage.tmp){
become(); become();
} }
function session(data){ function session(data){
if(!window.sessionStorage){ return } if(!sessionStorage){ return }
sessionStorage.alias = data.alias; sessionStorage.alias = data.alias;
sessionStorage.tmp = data.pass; sessionStorage.tmp = data.pass;
} }
c.tell = function(what, n){
var e = $('#tell');
e.find('p').text(what);
e.show();
setTimeout(function(){e.hide()}, n || 2500);
}
}()); }());
(function(){ (function(){
$(document).on('submit', '#say', function(e){ $(document).on('submit', '#say', function(e){

View File

@ -44,7 +44,10 @@
<script src="/jquery.js"></script> <script src="/jquery.js"></script>
<script src="/gun.js"></script> <script src="/gun.js"></script>
<script> <script>
// Check out the interactive tutorial
// for how to build a simplified version
// of this example: https://scrimba.com/c/cW2Vsa
var gun = Gun(location.origin+'/gun'); var gun = Gun(location.origin+'/gun');
var think = gun.get('think'); var think = gun.get('think');
var typing, throttle; var typing, throttle;

View File

@ -55,7 +55,7 @@ describe("The Holy Grail Test!", function(){
res.end("I am "+ env.i +"!"); res.end("I am "+ env.i +"!");
}); });
var Gun = require('gun'); var Gun = require('gun');
var gun = Gun({file: env.i+'data', web: server}); var gun = Gun({file: env.i+'data', web: server, localStorage: false});
server.listen(port, function(){ server.listen(port, function(){
test.done(); test.done();
}); });
@ -181,7 +181,7 @@ describe("The Holy Grail Test!", function(){
res.end("I am "+ env.i +"!"); res.end("I am "+ env.i +"!");
}); });
var Gun = require('gun'); var Gun = require('gun');
var gun = Gun({file: env.i+'data', web: server}); var gun = Gun({file: env.i+'data', web: server, localStorage: false});
server.listen(port, function(){ server.listen(port, function(){
test.done(); test.done();
}); });

View File

@ -3,8 +3,8 @@ var config = {
port: 8080, port: 8080,
servers: 1, servers: 1,
browsers: 2, browsers: 2,
each: 100, each: 2500,
burst: 2, // do not go below 1! burst: 25, // do not go below 1!
wait: 1, wait: 1,
route: { route: {
'/': __dirname + '/index.html', '/': __dirname + '/index.html',
@ -66,7 +66,6 @@ describe("Stress test GUN with SEA users causing PANIC!", function(){
res.end("I am "+ env.i +"!"); res.end("I am "+ env.i +"!");
}); });
// Launch the server and start gun! // Launch the server and start gun!
require('/Users/mark/gun24key.js');
var Gun = require('gun'); var Gun = require('gun');
// Attach the server to gun. // Attach the server to gun.
var gun = Gun({file: env.i+'data', web: server, localStorage: false}); var gun = Gun({file: env.i+'data', web: server, localStorage: false});
@ -260,7 +259,7 @@ describe("Stress test GUN with SEA users causing PANIC!", function(){
return; return;
} }
go.check[msg.id + msg.num] = false; go.check[msg.id + msg.num] = false;
clearTimeout(end.to); end.to = setTimeout(end, 100); clearTimeout(end.to); end.to = setTimeout(end, 9);
reportc.text(++go.num); reportc.text(++go.num);
last.text(msg.what); last.text(msg.what);
//who = cols[msg.id]; //who = cols[msg.id];
@ -299,7 +298,7 @@ describe("Stress test GUN with SEA users causing PANIC!", function(){
console.log("Done! Cleaning things up..."); console.log("Done! Cleaning things up...");
setTimeout(function(){ setTimeout(function(){
done(); done();
},1000 * 60); }, 2000);
}); });
after("Everything shut down.", function(){ after("Everything shut down.", function(){