mirror of
https://github.com/amark/gun.git
synced 2025-10-14 00:59:35 +00:00
paste example
This commit is contained in:
parent
b5b4357a5d
commit
f8bb17e27f
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>
|
@ -5,6 +5,7 @@
|
|||||||
<link href='https://fonts.googleapis.com/css?family=Poiret+One' rel='stylesheet' type='text/css'>
|
<link href='https://fonts.googleapis.com/css?family=Poiret+One' rel='stylesheet' type='text/css'>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1><button id="left">←</button> <span id="date"></span> Schedule <button id="right">→</button></h1>
|
<h1><button id="left">←</button> <span id="date"></span> Schedule <button id="right">→</button></h1>
|
||||||
|
|
||||||
<form id="add">
|
<form id="add">
|
||||||
|
@ -34,8 +34,8 @@ record.save = function(data){
|
|||||||
record.file.readAsDataURL(data);
|
record.file.readAsDataURL(data);
|
||||||
record.file.onloadend = function(){
|
record.file.onloadend = function(){
|
||||||
var b64 = record.file.result;
|
var b64 = record.file.result;
|
||||||
b64 = "data:video/webm" + b64.substr(b64.indexOf(';'));
|
b64 = "data:video/webm" + b64.slice(b64.indexOf(';'));
|
||||||
gun.get('screen').get('test').put(b64);
|
gun.get('test').get('screen').put(b64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ $('#play').on('click', ()=>{
|
|||||||
}
|
}
|
||||||
$('#play').text("Stop");
|
$('#play').text("Stop");
|
||||||
record.playing = true;
|
record.playing = true;
|
||||||
gun.get('screen').get('test').once((data)=>{
|
gun.get('test').get('screen').once((data)=>{
|
||||||
if(!data){ return }
|
if(!data){ return }
|
||||||
$('#video').get(0).src = data;
|
$('#video').get(0).src = data;
|
||||||
$('#video').get(0).play()
|
$('#video').get(0).play()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user