spee.ch/views/index.handlebars

68 lines
2.6 KiB
Handlebars
Raw Normal View History

2017-06-23 06:43:53 +02:00
<div class="wrapper">
2017-07-03 20:16:51 +02:00
{{> topBar}}
<div class="full">
2017-06-23 06:43:53 +02:00
{{> publish}}
2017-07-03 20:16:51 +02:00
{{> learnMore}}
2017-07-13 09:19:59 +02:00
{{> trendingAssets}}
2017-06-23 06:43:53 +02:00
</div>
2017-07-13 09:19:59 +02:00
{{> footer}}
2017-06-11 03:33:03 +02:00
</div>
2017-06-10 01:46:57 +02:00
<script src="/socket.io/socket.io.js"></script>
<script src="/siofu/client.js"></script>
<script src="/assets/js/generalFunctions.js"></script>
<script src="/assets/js/publishFunctions.js"></script>
<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;
var license = document.getElementById('publish-license').value;
var nsfw = document.getElementById('publish-nsfw').checked;
event.file.meta.name = name;
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 = '<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;
var showUrl = '/show/' + msg.name + '/' + msg.result.claim_id;
// 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;
});
//event listener to filter claim name inputs
2017-07-23 03:01:17 +02:00
document.getElementById('claim-name-input').addEventListener('input', function() {
var name = this.value;
this.value = name.replace(/\s+/g, '-');
})
</script>