2017-09-29 01:37:20 +02:00
<script src="/assets/js/generalFunctions.js"></script>
2017-09-29 20:59:53 +02:00
{{ > topBar }}
2017-09-29 23:24:53 +02:00
<div class="row" id="file-selection-area">
<div id="drop-zone" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event)">
<div class="row">
<p>Drag and drop your file here, or choose your file below.</p>
<div class="info-message info-message--failure" id="input-error-file-selection" hidden="true"></div>
</div>
<div class="row">
<input type="file" id="siofu_input" name="file" accept="video/*,image/*" onchange="previewAndStageFile(event.target.files[0])" enctype="multipart/form-data"/>
</div>
</div>
</div>
<div class="row">
<div class="column column--5" id="asset-preview-holder"></div>
<div class="column column--5" id="publish-active-area">
{{ > publishForm-Channel }}
{{ > publishForm-Url }}
{{ > publishForm-Details }}
{{ > publishForm-Submit }}
</div>
</div>
2017-06-10 01:46:57 +02:00
<script src="/socket.io/socket.io.js"></script>
<script src="/siofu/client.js"></script>
2017-07-28 23:39:39 +02:00
<script src="/assets/js/validationFunctions.js"></script>
2017-09-20 18:49:05 +02:00
<script src="/assets/js/publishFileFunctions.js"></script>
2017-09-29 23:24:53 +02:00
<script type="text/javascript" >
function resetPublishArea () {
// reset file selection area
document.getElementById('file-selection-area').innerHTML = `<div id="drop-zone" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event)">
<p>Drag and drop your file here, or choose your file below.</p>
<div class="info-message info-message--failure" id="input-error-file-selection" hidden="true"></div>
<input type="file" id="siofu_input" name="file" accept="video/*,image/*" onchange="previewAndStageFile(event.target.files[0])" enctype="multipart/form-data"/>
</div>
<div id="asset-preview-holder"></div>`;
// reset inputs
document.getElementById('claim-name-input').value = '';
document.getElementById('publish-title').value = '';
document.getElementById('publish-description').value = '';
document.getElementById('publish-nsfw').checked = false;
// remove staged files
stagedFiles = null;
// clear any errors
document.getElementById('input-error-file-selection').innerHTML = '';
document.getElementById('input-error-claim-name').innerHTML = '';
document.getElementById('input-error-publish-submit').innerHTML = '';
document.getElementById('input-success-claim-name').hidden = true;
}
</script>
2017-07-23 00:09:58 +02:00
<script typ="text/javascript">
// define variables
var socket = io();
var uploader = new SocketIOFileUpload(socket);
var stagedFiles = null;
/* socketio-file-upload listeners */
uploader.addEventListener('start', function(event) {
2017-07-23 03:01:17 +02:00
var name = document.getElementById('claim-name-input').value;
2017-08-21 01:56:37 +02:00
var title = document.getElementById('publish-title').value;
var description = document.getElementById('publish-description').value;
2017-07-23 00:09:58 +02:00
var license = document.getElementById('publish-license').value;
var nsfw = document.getElementById('publish-nsfw').checked;
2017-09-20 00:39:54 +02:00
var channel = document.getElementById('channel-name-select').value;
2017-07-23 00:09:58 +02:00
event.file.meta.name = name;
2017-08-21 01:56:37 +02:00
event.file.meta.title = title;
event.file.meta.description = description;
2017-07-23 00:09:58 +02:00
event.file.meta.license = license;
event.file.meta.nsfw = nsfw;
event.file.meta.type = stagedFiles[0].type;
2017-09-20 00:39:54 +02:00
event.file.meta.channel = channel;
2017-07-23 00:09:58 +02:00
// re-set the html in the publish area
document.getElementById('publish-active-area').innerHTML = '<div id="publish-status"></div><div id="progress-bar"></div>';
// start a progress animation
createProgressBar(document.getElementById('progress-bar'), 12);
// google analytics
ga('send', {
hitType: 'event',
eventCategory: 'publish',
eventAction: name
});
});
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 = '<p> --(✖╭╮✖)→ </p><p>' + JSON.stringify(msg) + '</p><strong>For help, post the above error text in the #speech channel on the <a href="https://lbry.slack.com/" target="_blank">lbry slack</a></strong>';
});
socket.on('publish-complete', function(msg) {
var publishResults;
2017-09-20 00:39:54 +02:00
var showUrl = msg.result.claim_id + "/" + msg.name;
2017-07-23 00:09:58 +02:00
// build new publish area
publishResults = '<p>Your publish is complete! You are being redirected to it now.</p>';
publishResults += '<p><a target="_blank" href="' + showUrl + '">If you do not get redirected, click here.</a></p>';
// update publish area
document.getElementById('publish-active-area').innerHTML = publishResults;
window.location.href = showUrl;
});
</script>