Create upload.html

This commit is contained in:
Mark Nadal 2020-05-23 21:40:34 -07:00
parent d56e06fec7
commit c45950a771

View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<center>
<video width="100%" controls="controls"></video>
<img style="max-width: 100%;">
<span id="up">Drag & drop video or image to upload!</span>
</center>
<script src="../jquery.js"></script>
<script src="../../../gun/gun.js"></script>
<script src="../../../gun/lib/upload.js"></script>
<script>
var gun = Gun(location.origin + '/gun');
$('html').upload(function resize(eve, up){
if(up && ((eve.file||{}).type||'').indexOf('image') + 1){
return up.shrink(eve, resize, 1024);
}
var b64 = (eve.base64 || ((eve.event || eve).target || eve).result || eve);
gun.get('test').get('paste').put(b64);
})
gun.get('test').get('paste').on(function(data){
$('video, img').css({display: 'none'})
if(!data){ return }
var type = data.split(';')[0], ui;
if(type.indexOf('image') + 1){ ui = $("img") }
if(type.indexOf('video') + 1){ ui = $('video') }
($(ui).css({display: 'block'}).get(0)||{}).src = data;
})
</script>