mirror of
https://github.com/amark/gun.git
synced 2026-03-02 07:03:18 +00:00
uploads
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<center>
|
||||
<div class="model" style="display: none;">
|
||||
<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>
|
||||
</div>
|
||||
<center>
|
||||
Drag & drop videos, songs, or images! <input type="file" multiple>
|
||||
</center>
|
||||
|
||||
<script src="../jquery.js"></script>
|
||||
@@ -19,16 +21,16 @@ $('html').upload(function resize(eve, up){
|
||||
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(eve.id).put(b64);
|
||||
});
|
||||
|
||||
gun.get('test').get('paste').on(function(data){
|
||||
$('video, audio, img').css({display: 'none'})
|
||||
gun.get('test').map().on(function(data){
|
||||
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;
|
||||
if(type.indexOf('image') + 1){ ui = $("img").get(0) }
|
||||
if(type.indexOf('video') + 1){ ui = $('video').get(0) }
|
||||
if(type.indexOf('audio') + 1){ ui = $('audio').get(0) }
|
||||
if(!ui){ return }
|
||||
$(ui).clone().prependTo('center').get(0).src = data;
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user