mirror of
https://github.com/amark/gun.git
synced 2025-07-02 02:42:34 +00:00
34 lines
1.0 KiB
HTML
34 lines
1.0 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<center>
|
|
<video width="100%" controls autoplay></video>
|
|
<audio width="100%" controls autoplay></audio>
|
|
<img style="max-width: 100%;">
|
|
<p>Drag & drop videos, songs, or images to upload!</p>
|
|
</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, audio, 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') }
|
|
if(type.indexOf('audio') + 1){ ui = $('audio') }
|
|
($(ui).css({display: 'block'}).get(0)||{}).src = data;
|
|
})
|
|
</script> |