diff --git a/main/pub/chat/src/main.css b/main/pub/chat/src/main.css index 24a119f91..2c8028c22 100644 --- a/main/pub/chat/src/main.css +++ b/main/pub/chat/src/main.css @@ -37,7 +37,8 @@ .iden, .time, #length, -input.join { +input.join, +.stations { font-family: "source-code-pro"; } html, @@ -45,6 +46,8 @@ body { height: 100%; font-family: "bau"; } +input.join, +.stations, #length, .time { font-size: 0.6rem; @@ -66,21 +69,26 @@ body { } #c { width: 66rem; - position: absolute; - left: 50%; top: 0; padding: 1rem 1rem 0 1rem; - margin-left: -33rem; background-color: #fff; height: 100%; } #station-container { left: 0; } +#stations-container, +#writing-container { + display: inline-block; + vertical-align: top; +} #station { width: 18rem; text-align: right; } +.station.selected { + font-weight: 500; +} .join-ctrl div, .join-ctrl input { display: inline; @@ -113,7 +121,7 @@ body { height: auto; } .attr { - width: 18rem; + width: 9rem; text-align: right; margin-right: 2rem; } @@ -194,6 +202,8 @@ input.join:focus { width: 8rem; margin-right: 1rem; } + .join-ctrl input, + .stations, .iden, #station { font-size: 0.5rem; diff --git a/main/pub/chat/src/main.js b/main/pub/chat/src/main.js index f768fc0fb..cb29c6156 100644 --- a/main/pub/chat/src/main.js +++ b/main/pub/chat/src/main.js @@ -10,22 +10,16 @@ module.exports = { messages: messages }); }, - switchStation: function(station) { - return MessageDispatcher.handleViewAction({ - type: "station-switch", - station: station - }); - }, - sendMessage: function(message) { - var serial, _message; + sendMessage: function(station, message) { + var serial, _audi, _message; serial = window.util.uuid32(); + _audi = {}; + _audi[station] = "pending"; _message = { ship: window.urb.ship, thought: { serial: serial, - audience: { - "~zod/main": "pending" - }, + audience: _audi, statement: { speech: { say: message @@ -58,6 +52,12 @@ module.exports = { config: config }); }, + switchStation: function(station) { + return StationDispatcher.handleViewAction({ + type: "station-switch", + station: station + }); + }, loadStations: function(stations) { return StationDispatcher.handleServerAction({ type: "stations-load", @@ -101,10 +101,12 @@ module.exports = recl({ },{"lodash":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/lodash/dist/lodash.js","react":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/react/react.js"}],"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/MessagesComponent.coffee":[function(require,module,exports){ -var Member, Message, MessageStore, React, StationStore, div, input, recl, textarea, _, _ref; +var Member, Message, MessageStore, React, StationStore, div, input, moment, recl, textarea, _, _ref; _ = require('lodash'); +moment = require('moment-timezone'); + React = require('react'); recl = React.createClass; @@ -118,8 +120,20 @@ StationStore = require('../stores/StationStore.coffee'); Member = require('./MemberComponent.coffee'); Message = recl({ + lz: function(n) { + if (n < 10) { + return "0" + n; + } else { + return "" + n; + } + }, convTime: function(time) { - return time.format("~HH.mm.ss"); + var d, h, m, s; + d = new Date(time); + h = this.lz(d.getHours()); + m = this.lz(d.getMinutes()); + s = this.lz(d.getSeconds()); + return "~" + h + "." + m + "." + s; }, render: function() { var name, pendingClass; @@ -133,7 +147,7 @@ Message = recl({ }, [ div({ className: "time" - }, this.props.thought.statement.time), Member({ + }, this.convTime(this.props.thought.statement.time)), Member({ ship: this.props.ship }, "") ]), div({ @@ -147,7 +161,7 @@ module.exports = recl({ stateFromStore: function() { return { messages: MessageStore.getAll(), - station: StationStore.getAll() + station: StationStore.getStations() }; }, getInitialState: function() { @@ -184,8 +198,8 @@ module.exports = recl({ -},{"../stores/MessageStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/MessageStore.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/MemberComponent.coffee","lodash":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/lodash/dist/lodash.js","react":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/react/react.js"}],"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/StationsComponent.coffee":[function(require,module,exports){ -var Member, React, StationActions, StationStore, div, input, recl, _, _ref; +},{"../stores/MessageStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/MessageStore.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/MemberComponent.coffee","lodash":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/lodash/dist/lodash.js","moment-timezone":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/moment-timezone/index.js","react":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/react/react.js"}],"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/StationsComponent.coffee":[function(require,module,exports){ +var React, StationActions, StationStore, div, input, recl, _, _ref; _ = require('lodash'); @@ -199,12 +213,11 @@ StationStore = require('../stores/StationStore.coffee'); StationActions = require('../actions/StationActions.coffee'); -Member = require('./MemberComponent.coffee'); - module.exports = recl({ stateFromStore: function() { return { - members: StationStore.getAll() + stations: StationStore.getStations(), + station: StationStore.getStation() }; }, getInitialState: function() { @@ -221,8 +234,8 @@ module.exports = recl({ _onChangeStore: function() { return this.setState(this.stateFromStore()); }, - _click: function() { - return this.$el.find('join-ctrl').toggleClass('disabled'); + _click: function(e) { + return StationActions.switchStation($(e.target).text()); }, _keyUp: function(e) { if (e.keyCode === 13) { @@ -230,8 +243,20 @@ module.exports = recl({ } }, render: function() { - var stations; - stations = []; + var station, stations, _click; + station = this.state.station; + _click = this._click; + stations = this.state.stations.map(function(_station) { + var k; + k = "station"; + if (_station === station) { + k += " selected"; + } + return div({ + className: k, + onClick: _click + }, _station); + }); return div({ id: "stations" }, [ @@ -252,7 +277,7 @@ module.exports = recl({ -},{"../actions/StationActions.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/actions/StationActions.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/MemberComponent.coffee","lodash":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/lodash/dist/lodash.js","react":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/react/react.js"}],"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/WritingComponent.coffee":[function(require,module,exports){ +},{"../actions/StationActions.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/actions/StationActions.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/StationStore.coffee","lodash":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/lodash/dist/lodash.js","react":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/react/react.js"}],"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/WritingComponent.coffee":[function(require,module,exports){ var Member, MessageActions, React, StationStore, div, input, recl, textarea, _ref; React = require('react'); @@ -280,12 +305,12 @@ module.exports = recl({ }, stateFromStore: function() { return { - station: StationStore.getAll() + station: StationStore.getStation() }; }, _keyDown: function(e) { if (e.keyCode === 13) { - MessageActions.sendMessage(this.$writing.text()); + MessageActions.sendMessage(this.state.station, this.$writing.text()); this.$length.text("0/69"); this.$writing.text(''); this.set(); @@ -472,8 +497,8 @@ $(function() { WritingComponent = require('./components/WritingComponent.coffee'); $c = $('#c'); $c.append("
"); - $c.append(""); $c.append(""); + $c.append(""); $c.append("