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">
<p>A mysterious new example app has appeared! It is not finished/ready yet.</p>
</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/gun.js"></script>
@ -118,12 +143,14 @@
<script src="/jquery.js"></script>
<script src="/gun.js"></script>
<script src="/gun/lib/cryptomodules.js"></script>
<script src="/gun/sea.js"></script>
<script src="/gun/as.js"></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();
var app = gun.get('example/contacts/6');
var user = gun.user();
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()};
data.born = Gun.time.is();
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;
}
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;
}
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){
gun.get('users').get(data.alias).put(gun.get('alias/'+data.alias));
}
@ -182,30 +209,36 @@
}).on('click','form.sign button:first', become);
function become(){
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.pass = data.pass || sessionStorage.tmp;
}
data.alias = data.alias || sessionStorage.alias;
data.pass = data.pass || sessionStorage.tmp;
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;
}
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;
}
user.auth(data.alias, data.pass, function(ack){
if(ack.err){ c.tell(ack.err); sessionStorage.clear(); user.leave(); return }
session(data);
});
}
if(window.sessionStorage && sessionStorage.tmp){
if(!window.sessionStorage){ window.sessionStorage = {clear:function(){}} }
if(sessionStorage.tmp){
become();
}
function session(data){
if(!window.sessionStorage){ return }
if(!sessionStorage){ return }
sessionStorage.alias = data.alias;
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(){
$(document).on('submit', '#say', function(e){

View File

@ -44,7 +44,10 @@
<script src="/jquery.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 think = gun.get('think');
var typing, throttle;

View File

@ -55,7 +55,7 @@ describe("The Holy Grail Test!", function(){
res.end("I am "+ env.i +"!");
});
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(){
test.done();
});
@ -181,7 +181,7 @@ describe("The Holy Grail Test!", function(){
res.end("I am "+ env.i +"!");
});
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(){
test.done();
});

View File

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