mirror of
https://github.com/amark/gun.git
synced 2026-02-18 09:43:50 +00:00
paste example
This commit is contained in:
20
examples/basic/paste.html
Normal file
20
examples/basic/paste.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<textarea style="width: 100%; height: 100%;" placeholder="paste here!"></textarea>
|
||||
|
||||
<script src="../jquery.js"></script>
|
||||
<script src="../../../gun/gun.js"></script>
|
||||
|
||||
<script>
|
||||
//var gun = Gun(location.origin + '/gun'), to;
|
||||
var gun = Gun('https://gunjs.herokuapp.com/gun'), to;
|
||||
|
||||
var paste = gun.get('test').get('paste').on(function(data){
|
||||
$('textarea').val(data);
|
||||
})
|
||||
|
||||
$('textarea').on('input change blur keyup mouseup touchend', function(){
|
||||
clearTimeout(to); // debounce
|
||||
to = setTimeout(function(){
|
||||
paste.put($('textarea').val());
|
||||
}, 100);
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user