mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
55 lines
1.4 KiB
HTML
55 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<h1>User</h1>
|
|
|
|
<form id="sign">
|
|
<input id="alias" placeholder="username">
|
|
<input id="pass" type="password" placeholder="passphrase">
|
|
<input id="in" type="submit" value="sign in">
|
|
<input id="up" type="button" value="sign up">
|
|
<input id="mask" type="button" value="Identifi Login">
|
|
</form>
|
|
|
|
<ul></ul>
|
|
|
|
<form id="said">
|
|
<input id="say">
|
|
<input id="speak" type="submit" value="speak">
|
|
</form>
|
|
|
|
<script src="../jquery.js"></script>
|
|
<script src="../../../gun/gun.js"></script>
|
|
<script src="../../../gun/sea.js"></script>
|
|
|
|
<script>
|
|
//var gun = Gun('http://localhost:8765/gun');
|
|
var gun = Gun(); //Gun(['http://localhost:8765/gun', 'https://guntest.herokuapp.com/gun']);
|
|
var user = gun.user().recall({sessionStorage: true});
|
|
|
|
$('#up').on('click', function(e){
|
|
user.create($('#alias').val(), $('#pass').val(), login);
|
|
});
|
|
function login(e){
|
|
user.auth($('#alias').val(), $('#pass').val());
|
|
return false; // e.preventDefault();
|
|
};
|
|
$('#sign').on('submit', login);
|
|
$('#mask').on('click', login);
|
|
|
|
gun.on('auth', function(){
|
|
$('#sign').hide();
|
|
user.get('said').map().on(UI);
|
|
});
|
|
|
|
$('#said').on('submit', function(e){
|
|
e.preventDefault();
|
|
//if(!user.is){ return }
|
|
user.get('said').set($('#say').val());
|
|
$('#say').val("");
|
|
});
|
|
|
|
function UI(say, id){
|
|
var li = $('#' + id).get(0) || $('<li>').attr('id', id).appendTo('ul');
|
|
$(li).text(say);
|
|
};
|
|
</script> |