diff --git a/skins/base/views/templates/Register.js b/skins/base/views/templates/Register.js index 94f3b96971..1f789860d4 100644 --- a/skins/base/views/templates/Register.js +++ b/skins/base/views/templates/Register.js @@ -27,9 +27,18 @@ var RegisterController = require("../../../../src/controllers/templates/Register var ServerConfig = ComponentBroker.get("molecules/ServerConfig"); module.exports = React.createClass({ + DEFAULT_HS_URL: 'https://matrix.org', + DEFAULT_IS_URL: 'https://matrix.org', + displayName: 'Register', mixins: [RegisterController], + getInitialState: function() { + return { + serverConfigVisible: false + }; + }, + getRegFormVals: function() { return { email: this.refs.email.getDOMNode().value, @@ -40,24 +49,65 @@ module.exports = React.createClass({ }, getHsUrl: function() { - return this.refs.serverConfig.getHsUrl(); + if (this.state.serverConfigVisible) { + return this.refs.serverConfig.getHsUrl(); + } else { + return this.DEFAULT_HS_URL; + } }, getIsUrl: function() { - return this.refs.serverConfig.getIsUrl(); + if (this.state.serverConfigVisible) { + return this.refs.serverConfig.getIsUrl(); + } else { + return this.DEFAULT_IS_URL; + } + }, + + onServerConfigVisibleChange: function(ev) { + this.setState({ + serverConfigVisible: ev.target.checked + }); + }, + + getUserIdSuffix: function() { + var actualHsUrl = document.createElement('a'); + actualHsUrl.href = this.getHsUrl(); + var defaultHsUrl = document.createElement('a'); + defaultHsUrl.href = this.DEFAULT_HS_URL; + if (actualHsUrl.host == defaultHsUrl.host) { + return ':matrix.org'; + } + return ''; + }, + + onServerUrlChanged: function(newUrl) { + this.forceUpdate(); }, componentForStep: function(step) { switch (step) { case 'initial': + var serverConfigStyle = {}; + if (!this.state.serverConfigVisible) { + serverConfigStyle.display = 'none'; + } return (