Published
Edited
Apr 6, 2021
Insert cell
md`# gunDB`
Insert cell
html`<html>
<body>
<h1>Todo</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">
</form>

<ul></ul>

<form id="said">
<input id="say">
<input id="speak" type="submit" value="speak">
</form>

<!-- script src="https://cdn.jsdelivr.net/npm/gun/lib/webrtc.js"></script -->

<script>

</script>
</body>
</html>`
Insert cell
$ = require('jquery')
Insert cell
Gun = require('https://cdn.jsdelivr.net/npm/gun/gun.js').catch(() =>{
require('https://cdn.jsdelivr.net/npm/gun/sea.js').catch(() =>{})

return window.Gun
})
Insert cell
gun = Gun([ 'https://mvp-gun.herokuapp.com/gun', 'https://e2eec.herokuapp.com/gun']);
Insert cell
{
console.log('i;m here')
let user = gun.user()
console.log("i'm here")
$('#up').on('click', function(e){
user.create($('#alias').val(), $('#pass').val());
});

$('#sign').on('submit', function(e){
e.preventDefault();
user.auth($('#alias').val(), $('#pass').val());
});
$('#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);
};
gun.on('auth', function(){
$('#sign').hide();
user.get('said').map().once(UI);
});
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more