var publishNumberInputStyle = { width: '50px', }, publishFieldLabelStyle = { display: 'inline-block', width: '118px', textAlign: 'right', verticalAlign: 'top', }, publishFieldStyle = { width: '330px', }; var PublishPage = React.createClass({ publish: function() { var metadata = { title: this.refs.meta_title.value, author: this.refs.meta_author.value, description: this.refs.meta_description.value, language: this.refs.meta_language.value, license: this.refs.meta_license.value, }; if (this.refs.meta_thumbnail.value) { metadata.thumbnail = this.refs.meta_thumbnail.value; } if (this.state.isFee) { metadata.fee = parseFloat(this.state.fee); } lbry.publish({ name: this.state.name, file_path: this._tempFilePath, bid: parseFloat(this.state.bid), metadata: metadata, }); }, getInitialState: function() { this._tempFilePath = null; return { name: '', bid: '', nameResolved: false, claimValue: 0.0, fileInfo: null, uploadProgress: 0.0, uploaded: false, tempFileReady: false, }; }, handleNameChange: function(event) { var name = event.target.value; if (!name) { this.setState({ name: '', nameResolved: false, }); return; } lbry.resolveName(name, (info) => { if (!info) { this.setState({ name: name, nameResolved: false, }); } else { lbry.search(name, (results) => { var claimValue = results[0].value; this.setState({ name: name, nameResolved: true, claimValue: parseFloat(claimValue), }); }); } }); }, handleBidChange: function(event) { this.setState({ bid: event.target.value, }); }, handleFeeChange: function(event) { this.setState({ fee: event.target.value, }); }, handleFileChange: function(event) { event.preventDefault(); var fileInput = event.target; this._tempFilePath = null; if (fileInput.files.length == 0) { // File was removed this.setState({ fileInfo: null, uploadProgress: 0.0, uploaded: false, tempFileReady: false, }); } else { var file = fileInput.files[0]; this.setState({ fileInfo: { name: file.name, size: file.size, }, uploadProgress: 0.0, uploaded: false, tempFileReady: false, }); var xhr = new XMLHttpRequest(); xhr.upload.addEventListener('progress', (event) => { this.setState({ uploadProgress: (event.loaded / event.total), }); }); xhr.upload.addEventListener('load', (event) => { this.setState({ uploaded: true, }); }); xhr.addEventListener('load', (event) => { this._tempFilePath = JSON.parse(xhr.responseText); this.setState({ tempFileReady: true, }); }) xhr.open('POST', '/upload', true); xhr.send(new FormData(fileInput.form)); } }, handleFeePrefChange: function(feeEnabled) { this.setState({ isFee: feeEnabled }); }, readyToPublish: function() { var bidFloat = parseFloat(this.state.bid); return (this.state.name && this.state.fileInfo && !isNaN(bidFloat) && (!this.state.claimValue || bidFloat > this.state.claimValue)); }, render: function() { if (this.state.fileInfo && !this.state.tempFileReady) { // A file was chosen but the daemon hasn't finished processing it yet, i.e. it's loading, so // we need a value for the progress bar. if (!this.state.uploaded) { // Still uploading var progressOpts = { value: this.state.uploadProgress, }; } else { // Fully uploaded and waiting for server to finish processing, so set progress bar to "indeterminite" var progressOpts = {}; } } return (

Publish Content

LBRY name

What LBRY name would you like to claim for this file?
lbry:// { (!this.state.name ? '' : (this.state.nameResolved ? This name is currently claimed for {lbry.formatCredits(this.state.claimValue)} credits : This name is available)) }

Choose file

{ !this.state.fileInfo ? '' : (!this.state.tempFileReady ?
{!this.state.uploaded ? Importing file into LBRY... : Processing file...}
:
File ready for publishing!
) }

Bid amount

How much would you like to bid for this name? { !this.state.nameResolved ? Since this name is not currently resolved, you may bid as low as you want, but higher bids help prevent others from claiming your name. : You must bid over {lbry.formatCredits(this.state.claimValue)} credits to claim this name. }
Credits {this.state.bid && isNaN(this.state.bid) ? Must be a number : ''}

Fee

How much would you like to charge for this file?

Your content

Additional content information (optional)

); } });