// define variables var socket = io(); var uploader = new SocketIOFileUpload(socket); var stagedFiles = null; var license = 'Creative Commons'; var nsfw = false; var nameInput = document.getElementById("publish-name"); /* socketio-file-upload listeners */ uploader.addEventListener('start', function(event){ event.file.meta.name = nameInput.value; event.file.meta.license = license; event.file.meta.nsfw = nsfw; event.file.meta.type = stagedFiles[0].type; // re-set the html in the publish area document.getElementById('publish-active-area').innerHTML = '
'; // start a progress animation createProgressBar(document.getElementById('progress-bar'), 12); // google analytics ga('send', { hitType: 'event', eventCategory: 'publish', eventAction: nameInput.value }); }); uploader.addEventListener('progress', function(event){ var percent = event.bytesLoaded / event.file.size * 100; updatePublishStatus('File is ' + percent.toFixed(2) + '% loaded to the server'); }); /* socket.io message listeners */ socket.on('publish-status', function(msg){ updatePublishStatus(msg); }); socket.on('publish-failure', function(msg){ document.getElementById('publish-active-area').innerHTML = '' + JSON.stringify(msg) + '
--(✖╭╮✖)→
For help, post the above error text in the #speech channel on the LBRY slack'; }); socket.on('publish-complete', function(msg){ var publishResults; var directUrl = '/' + msg.name + '/' + msg.result.claim_id; // build new publish area publishResults = 'Your publish is complete! View it here:
'; publishResults += ''; publishResults += ''; publishResults += ''; publishResults += ''; // update publish area document.getElementById('publish-active-area').innerHTML = publishResults; });