paste example

This commit is contained in:
Mark Nadal 2019-11-09 14:38:02 -08:00
parent b5b4357a5d
commit f8bb17e27f
3 changed files with 24 additions and 3 deletions

20
examples/basic/paste.html Normal file
View 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>

View File

@ -5,6 +5,7 @@
<link href='https://fonts.googleapis.com/css?family=Poiret+One' rel='stylesheet' type='text/css'>
</head>
<body>
<h1><button id="left">&larr;</button> <span id="date"></span> Schedule <button id="right">&rarr;</button></h1>
<form id="add">

View File

@ -34,8 +34,8 @@ record.save = function(data){
record.file.readAsDataURL(data);
record.file.onloadend = function(){
var b64 = record.file.result;
b64 = "data:video/webm" + b64.substr(b64.indexOf(';'));
gun.get('screen').get('test').put(b64);
b64 = "data:video/webm" + b64.slice(b64.indexOf(';'));
gun.get('test').get('screen').put(b64);
}
}
@ -48,7 +48,7 @@ $('#play').on('click', ()=>{
}
$('#play').text("Stop");
record.playing = true;
gun.get('screen').get('test').once((data)=>{
gun.get('test').get('screen').once((data)=>{
if(!data){ return }
$('#video').get(0).src = data;
$('#video').get(0).play()