UNPKG

@gooddollar/gun

Version:

A realtime, decentralized, offline-first, graph data synchronization engine.

34 lines (29 loc) 1.05 kB
<!DOCTYPE html> <div class="model" style="display: none;"> <video width="100%" controls autoplay></video> <audio width="100%" controls autoplay></audio> <img style="max-width: 100%;"> </div> <center> <p>Drag & drop videos, songs, or images! <input type="file" multiple></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){ return up.shrink(eve, resize, 1024) } var b64 = (eve.base64 || ((eve.event || eve).target || eve).result || eve); gun.get('test').get(eve.id).put(b64); }); gun.get('test').map().on(function(data){ if(!data){ return } var type = data.split(';')[0], ui; 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>