var React = require('react'); var render = require('../../lib/render.jsx'); var FormattedHTMLMessage = require('react-intl').FormattedHTMLMessage; var FormattedMessage = require('react-intl').FormattedMessage; var injectIntl = require('react-intl').injectIntl; var api = require('../../lib/api'); var Page = require('../../components/page/www/page.jsx'); var TitleBanner = require('../../components/title-banner/title-banner.jsx'); var FlexRow = require('../../components/flex-row/flex-row.jsx'); var SubNavigation = require('../../components/subnavigation/subnavigation.jsx'); require('./download.scss'); require('../../components/forms/button.scss'); var Download = injectIntl(React.createClass({ type: 'Download', getInitialState: function () { return { swfVersion: '' }; }, componentDidMount: function () { var uri = '/scratchr2/static/sa/version.xml'; if (this.props.intl.locale === 'pt-br') { uri = '/scratchr2/static/sa/pt-br/version.xml'; } api({ host: '', uri: uri, responseType: 'string' }, function (err, body, res) { if (err || res.statusCode >= 400) { return this.setState({ swfVersion: -1 }); } var doc = new DOMParser().parseFromString(body, 'text/xml'); return this.setState({ swfVersion: doc.getElementsByTagName('versionNumber')[0].childNodes[0].nodeValue }); }.bind(this)); }, render: function () { var downloadPath = '/scratchr2/static/sa/Scratch-'; if (this.props.intl.locale === 'pt-br') { downloadPath = '/scratchr2/static/sa/pt-br/Scratch-'; } if (this.state.swfVersion.length > 0 && this.state.swfVersion !== -1) { var downloadUrls = { mac: downloadPath + this.state.swfVersion + '.dmg', mac105: downloadPath + this.state.swfVersion + '.air', windows: downloadPath + this.state.swfVersion + '.exe', linux: downloadPath + this.state.swfVersion + '.air' }; } return (

  • {'1'}

    • - {' '}
    • - {' '}
    • - {' '}
    • - {' '}

    {'2'}

    {downloadUrls ? [
    • - {' '}
    • - {' '}
    • - {' '}
    • - {' '}
    ] : []} {this.state.swfVersion === -1 ? [

    ] : []}

    {'3'}

    • - {' '}
    • - {' '}
    • - {' '}

    {this.state.swfVersion !== -1 ? [

    ] : []}

    ); } })); render(, document.getElementById('app'));