spee.ch/views/index.handlebars

148 lines
7.1 KiB
Handlebars
Raw Normal View History

2017-10-30 18:07:23 +01:00
<div class="row row--tall flex-container--column">
2017-10-11 22:33:56 +02:00
<form>
<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>
2017-10-30 18:07:23 +01:00
<div id="primary-dropzone" class="dropzone row row--margined row--padded row--tall flex-container--column flex-container--center-center" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event)" ondragenter="dragenter_handler(event)" ondragleave="dragexit_handler(event)" onclick="triggerFileChooser('siofu_input', event)">
2017-10-23 22:07:05 +02:00
<div id="primary-dropzone-instructions">
2017-10-28 00:15:05 +02:00
<p class="info-message-placeholder info-message--failure" id="input-error-file-selection" hidden="true"></p>
<p>Drag & drop image or video here to publish</p>
2017-10-24 07:29:20 +02:00
<p class="fine-print">OR</p>
<p class="blue--underlined">CHOOSE FILE</p>
2017-10-24 07:29:20 +02:00
</div>
<div id="dropbzone-dragover" class="hidden">
<p class="blue">Drop it.</p>
2017-10-02 20:47:12 +02:00
</div>
2017-09-29 23:24:53 +02:00
</div>
2017-10-23 22:07:05 +02:00
<div id="publish-form" class="hidden">
2017-10-25 18:32:07 +02:00
<div class="row row--padded row--no-bottom">
<div class="column column--10">
<!-- title input -->
<input type="text" id="publish-title" class="input-text text--large input-text--full-width" placeholder="Give your post a title...">
2017-10-24 22:39:06 +02:00
</div>
<div class="column column--5 column--sml-10" >
2017-10-25 18:32:07 +02:00
<!-- preview -->
<div class="row row--padded">
2017-10-27 01:08:38 +02:00
<div id="asset-preview-holder" class="dropzone" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event)" ondragenter="preview_onmouseenter_handler()" ondragleave="preview_onmouseleave_handler()" onmouseenter="preview_onmouseenter_handler()" onmouseleave="preview_onmouseleave_handler()" onclick="triggerFileChooser('siofu_input', event)">
<div id="asset-preview-dropzone-instructions" class="hidden">
2017-10-25 18:32:07 +02:00
<p>Drag & drop image or video here</p>
<p class="fine-print">OR</p>
<p class="blue--underlined">CHOOSE FILE</p>
2017-10-25 18:32:07 +02:00
</div>
2017-10-27 01:08:38 +02:00
<div id="asset-preview-target"></div>
2017-10-03 23:52:50 +02:00
</div>
</div>
</div><div class="column column--5 column--sml-10 align-content-top">
2017-10-25 18:32:07 +02:00
<div id="publish-active-area" class="row row--padded">
{{> publishForm-Channel}}
{{> publishForm-Url}}
{{> publishForm-Thumbnail}}
{{> publishForm-Details}}
{{> publishForm-Submit}}
</div>
2017-10-10 19:14:43 +02:00
</div>
2017-09-30 00:56:13 +02:00
</div>
2017-09-29 23:24:53 +02:00
</div>
<div id="publish-status" class="hidden">
2017-10-24 22:39:06 +02:00
<div class="row row--margined">
<div id="publish-update" class="row align-content-center"></div>
<div id="publish-progress-bar" class="row align-content-center"></div>
<div id="upload-percent" class="row align-content-center"></div>
</div>
2017-10-12 22:10:44 +02:00
</div>
2017-09-29 23:24:53 +02:00
</div>
2017-06-10 01:46:57 +02:00
<script typ="text/javascript">
2017-10-03 23:52:50 +02:00
checkCookie();
2017-10-12 22:10:44 +02:00
let stagedFiles = null;
2017-10-23 22:07:05 +02:00
const publishFormWrapper = document.getElementById('publish-form');
2017-10-12 22:10:44 +02:00
const publishStatus = document.getElementById('publish-status');
const publishUpdate = document.getElementById('publish-update');
2017-10-12 22:10:44 +02:00
const publishProgressBar = document.getElementById('publish-progress-bar');
const uploadPercent = document.getElementById('upload-percent');
2017-10-03 19:05:09 +02:00
function uploadStarted (event){
2017-10-10 03:29:40 +02:00
console.log('starting upload');
2017-10-12 22:10:44 +02:00
addInputValuesToFileMetaData(event)
// hide the publish tool
hidePublishTools();
2017-09-30 00:56:13 +02:00
// show the progress status and animation
2017-10-12 22:10:44 +02:00
showPublishStatus();
showPublishProgressBar();
};
function uploadProgress (event){
var percent = event.bytesLoaded / event.file.size * 100;
updatePublishStatus('<p>File is loading to server</p>')
updateUploadPercent(`<p class="blue">${percent.toFixed(2)}%</p>`)
};
function filePublishUpdate (msg) {
updatePublishStatus(`<p>${msg}</p>`);
2017-10-25 18:17:47 +02:00
updateUploadPercent(`<p>Curious what magic is happening here? <a class="link--primary" target="blank" href="https://lbry.io/faq/what-is-lbry">Learn more.</a></p>`);
};
function filePublishFailure (msg){
2017-10-25 18:17:47 +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 class="link--primary" href="https://discord.gg/YjYbwhS" target="_blank">lbry discord</a></strong>');
2017-10-12 22:10:44 +02:00
hidePublishProgressBar();
hideUploadPercent();
};
function filePublishComplete (msg) {
2017-10-12 22:10:44 +02:00
const 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>');
2017-10-25 18:17:47 +02:00
updateUploadPercent('<p><a class="link--primary" target="_blank" href="\' + showUrl + \'">If you do not get redirected, click here.</a></p>')
2017-09-30 00:56:13 +02:00
// redirect the user
window.location.href = showUrl;
};
2017-10-12 22:10:44 +02:00
function hidePublishTools() {
publishFormWrapper.setAttribute('class', 'hidden');
2017-10-12 22:10:44 +02:00
}
// publish status functions
function showPublishStatus() {
2017-10-30 18:07:23 +01:00
publishStatus.setAttribute('class', 'row row--tall flex-container--column flex-container--center-center');
2017-10-12 22:10:44 +02:00
}
function updatePublishStatus(msg){
publishUpdate.innerHTML = msg;
2017-10-12 22:10:44 +02:00
}
// progress bar functions
function showPublishProgressBar(){
createProgressBar(publishProgressBar, 12);
}
function hidePublishProgressBar(){
publishProgressBar.hidden = true;
}
// upload percent functions
function updateUploadPercent(msg){
uploadPercent.innerHTML = msg;
}
function hideUploadPercent(){
uploadPercent.hidden = true;
}
function addInputValuesToFileMetaData(event) {
// get values from inputs
const name = document.getElementById('claim-name-input').value.trim();
const title = document.getElementById('publish-title').value.trim();
const description = document.getElementById('publish-description').value.trim();
const license = document.getElementById('publish-license').value.trim();
2017-10-12 22:10:44 +02:00
const nsfw = document.getElementById('publish-nsfw').checked;
const anonymous = document.getElementById('anonymous-select').checked;
const channel = document.getElementById('channel-name-select').value.trim();
const thumbnail = document.getElementById('claim-thumbnail-input').value.trim();
2017-10-12 22:10:44 +02:00
// set values on file meta data
event.file.meta.name = name;
event.file.meta.title = title;
event.file.meta.description = description;
event.file.meta.license = license;
event.file.meta.nsfw = nsfw;
event.file.meta.type = stagedFiles[0].type;
if (!anonymous) {
event.file.meta.channel = channel;
}
if (thumbnail && (thumbnail.trim !== '')){
event.file.meta.thumbnail = thumbnail;
}
}
</script>