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-10-02 20:47:12 +02:00
<div class="row row--full-height">
2017-10-04 18:05:35 +02:00
<div id="primary-dropzone-wrapper">
<div id="primary-dropzone" class="dropzone" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event)">
<div id="primary-dropzone-instructions">
2017-10-03 19:05:09 +02:00
<div class="row">
<p>Drag & drop image or video here</p>
<p>OR</p>
<form>
<label class="input-file-label" for="siofu_input">CHOOSE FILE</label>
<input class=" input-file" type="file" id="siofu_input" name="siofu_input" accept="video/*,image/*" onchange="previewAndStageFile(event.target.files[0])" enctype="multipart/form-data"/>
</form>
</div>
<div class="info-message info-message--failure" id="input-error-file-selection" hidden="true"></div>
2017-10-02 20:47:12 +02:00
</div>
</div>
2017-09-29 23:24:53 +02:00
</div>
2017-10-02 20:47:12 +02:00
<div id="publish-form-wrapper" hidden="true">
2017-10-03 02:36:25 +02:00
<div class="column column--10">
<!-- title input -->
2017-10-03 20:23:10 +02:00
<input type="text" id="publish-title" class="input-text input-text--large input-text--full-width" placeholder="Title (optional)">
2017-10-03 02:36:25 +02:00
</div>
2017-10-04 01:26:43 +02:00
<div class="column column--5 column--med-10 align-content-top" >
2017-10-03 02:36:25 +02:00
<!-- preview -->
<div class="row">
2017-10-03 23:52:50 +02:00
<div id="asset-preview-holder" class="dropzone" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event)" onmouseenter="showInstructions()" onmouseleave="hideInstructions()">
<div id="asset-preview-target"></div>
<div id="preview-dropzone-instructions" hidden="true">
<div class="row">
<p>Drag & drop image or video here</p>
<p>OR</p>
<form>
<label class="input-file-label" for="siofu_input">CHOOSE FILE</label>
<input class=" input-file" type="file" id="siofu_input" name="siofu_input" accept="video/*,image/*" onchange="previewAndStageFile(event.target.files[0])" enctype="multipart/form-data"/>
</form>
</div>
</div>
</div>
2017-10-03 02:36:25 +02:00
</div>
<!-- description input -->
2017-10-03 23:52:50 +02:00
<textarea rows="2" id="publish-description" class="textarea textarea--large textarea--full-width" placeholder="Description (optional)"></textarea>
2017-10-04 01:26:43 +02:00
</div><div class="column column--5 column--med-10 align-content-top">
2017-10-03 02:36:25 +02:00
<div id="publish-status" class="row" hidden="true"></div>
<div id="publish-progress-bar" class="row" hidden="true"></div>
2017-09-30 00:56:13 +02:00
<div id="publish-active-area">
{{ > publishForm-Channel }}
{{ > publishForm-Url }}
2017-10-10 03:29:40 +02:00
{{ > publishForm-Thumbnail }}
2017-09-30 00:56:13 +02:00
{{ > publishForm-Details }}
{{ > publishForm-Submit }}
</div>
2017-09-29 23:24:53 +02:00
</div>
</div>
2017-06-10 01:46:57 +02:00
2017-10-02 20:47:12 +02:00
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-07-23 00:09:58 +02:00
<script typ="text/javascript">
2017-10-03 23:52:50 +02:00
2017-10-07 01:42:19 +02:00
checkCookie();
2017-09-30 00:56:13 +02:00
var socket = io();
var uploader = new SocketIOFileUpload(socket);
var stagedFiles = null;
2017-10-03 19:05:09 +02:00
2017-09-30 00:56:13 +02:00
/* drop zone functions */
2017-10-03 23:52:50 +02:00
function showInstructions () {
document.getElementById('preview-dropzone-instructions').hidden = false;
document.getElementById('asset-preview').style.opacity = 0.3;
}
function hideInstructions () {
document.getElementById('preview-dropzone-instructions').hidden = true;
document.getElementById('asset-preview').style.opacity = 1;
}
function drop_handler(event) {
event.preventDefault();
2017-09-30 00:56:13 +02:00
// if dropped items aren't files, reject them
2017-10-03 23:52:50 +02:00
var dt = event.dataTransfer;
2017-09-30 00:56:13 +02:00
if (dt.items) {
if (dt.items[0].kind == 'file') {
var droppedFile = dt.items[0].getAsFile();
previewAndStageFile(droppedFile);
}
}
}
2017-10-03 23:52:50 +02:00
function dragover_handler(event) {
event.preventDefault();
2017-09-30 00:56:13 +02:00
}
2017-10-03 23:52:50 +02:00
function dragend_handler(event) {
var dt = event.dataTransfer;
2017-09-30 00:56:13 +02:00
if (dt.items) {
for (var i = 0; i < dt.items.length; i++) {
dt.items.remove(i);
}
} else {
2017-10-03 23:52:50 +02:00
event.dataTransfer.clearData();
2017-09-30 00:56:13 +02:00
}
}
2017-10-03 19:05:09 +02:00
2017-07-23 00:09:58 +02:00
/* socketio-file-upload listeners */
2017-09-30 00:56:13 +02:00
function updatePublishStatus(msg) {
document.getElementById('publish-status').innerHTML = msg;
}
2017-07-23 00:09:58 +02:00
uploader.addEventListener('start', function(event) {
2017-10-10 03:29:40 +02:00
console.log('starting upload');
const name = document.getElementById('claim-name-input').value;
const title = document.getElementById('publish-title').value;
const description = document.getElementById('publish-description').value;
const license = document.getElementById('publish-license').value;
const nsfw = document.getElementById('publish-nsfw').checked;
const anonymous = document.getElementById('anonymous-select').checked;
console.log('anonymous?', anonymous);
const channel = document.getElementById('channel-name-select').value;
console.log('channel:', channel);
const thumbnail = document.getElementById('claim-thumbnail-input').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-10-10 03:29:40 +02:00
if (!anonymous) {
event.file.meta.channel = channel;
}
if (thumbnail && (thumbnail.trim !== '')) {
event.file.meta.thumbnail = thumbnail;
}
2017-09-30 00:56:13 +02:00
// hide the submit area
document.getElementById('publish-active-area').hidden = true;
// show the progress status and animation
document.getElementById('publish-status').hidden = false;
document.getElementById('publish-progress-bar').hidden = false;
createProgressBar(document.getElementById('publish-progress-bar'), 12);
2017-07-23 00:09:58 +02:00
// 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) {
2017-09-30 00:56:13 +02:00
updatePublishStatus('<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>');
document.getElementById('publish-progress-bar').hidden = true;
2017-07-23 00:09:58 +02:00
});
socket.on('publish-complete', function(msg) {
2017-10-10 03:29:40 +02:00
console.log(msg);
2017-09-20 00:39:54 +02:00
var showUrl = msg.result.claim_id + "/" + msg.name;
2017-09-30 00:56:13 +02:00
// update status
updatePublishStatus('<p>Your publish is complete! You are being redirected to it now.</p><p><a target="_blank" href="' + showUrl + '">If you do not get redirected, click here.</a></p>');
document.getElementById('publish-progress-bar').hidden = true;
// redirect the user
2017-07-23 00:09:58 +02:00
window.location.href = showUrl;
});
</script>