mirror of
https://github.com/amark/gun.git
synced 2025-11-27 15:54:04 +00:00
use tmp/dht.html as playground?
This commit is contained in:
parent
82deba55a3
commit
86a2abb9e3
53
test/tmp/dht.html
Normal file
53
test/tmp/dht.html
Normal file
@ -0,0 +1,53 @@
|
||||
<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="MetaMask Login">
|
||||
</form>
|
||||
|
||||
<ul></ul>
|
||||
|
||||
<form id="said">
|
||||
<input id="say">
|
||||
<input id="speak" type="submit" value="speak">
|
||||
</form>
|
||||
|
||||
<script src="../../../gun/examples/jquery.js"></script>
|
||||
<script src="../../../gun/gun.js"></script>
|
||||
<script src="../../../gun/sea.js"></script>
|
||||
<script src="../../../gun/axe.js"></script>
|
||||
|
||||
<script>
|
||||
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>
|
||||
Loading…
x
Reference in New Issue
Block a user