front end PM glyph display

This commit is contained in:
Anton Dyudin 2015-11-02 12:42:58 -08:00
parent 4aa03de827
commit 3101e61227
3 changed files with 39 additions and 15 deletions

View File

@ -94,7 +94,7 @@ module.exports = recl
stations:StationStore.getStations() stations:StationStore.getStations()
configs:StationStore.getConfigs() configs:StationStore.getConfigs()
typing:MessageStore.getTyping() typing:MessageStore.getTyping()
glyph:StationStore.getGlyphMap() glyphs:StationStore.getGlyphMap()
} }
getInitialState: -> @stateFromStore() getInitialState: -> @stateFromStore()
@ -198,10 +198,10 @@ module.exports = recl
div {id: "messages"}, _messages.map (_message,k) => div {id: "messages"}, _messages.map (_message,k) =>
nowSaid = [_message.ship,_message.thought.audience] nowSaid = [_message.ship,_message.thought.audience]
glyph = window.util.getGlyph @state.glyphs, _.keys _message.thought.audience
{station} = @state {station} = @state
mess = { mess = {
station, @_handlePm, @_handleAudi, glyph, station, @_handlePm, @_handleAudi,
glyph: @state.glyph[(_.keys _message.thought.audience).join " "]
unseen: lastIndex and lastIndex is k unseen: lastIndex and lastIndex is k
sameAs: _.isEqual lastSaid, nowSaid sameAs: _.isEqual lastSaid, nowSaid
} }

View File

@ -385,7 +385,7 @@ module.exports = recl({
stations: StationStore.getStations(), stations: StationStore.getStations(),
configs: StationStore.getConfigs(), configs: StationStore.getConfigs(),
typing: MessageStore.getTyping(), typing: MessageStore.getTyping(),
glyph: StationStore.getGlyphMap() glyphs: StationStore.getGlyphMap()
}; };
}, },
getInitialState: function() { getInitialState: function() {
@ -508,14 +508,15 @@ module.exports = recl({
id: "messages" id: "messages"
}, _messages.map((function(_this) { }, _messages.map((function(_this) {
return function(_message, k) { return function(_message, k) {
var mess, nowSaid, ref4; var glyph, mess, nowSaid, ref4;
nowSaid = [_message.ship, _message.thought.audience]; nowSaid = [_message.ship, _message.thought.audience];
glyph = window.util.getGlyph(_this.state.glyphs, _.keys(_message.thought.audience));
station = _this.state.station; station = _this.state.station;
mess = { mess = {
glyph: glyph,
station: station, station: station,
_handlePm: _this._handlePm, _handlePm: _this._handlePm,
_handleAudi: _this._handleAudi, _handleAudi: _this._handleAudi,
glyph: _this.state.glyph[(_.keys(_message.thought.audience)).join(" ")],
unseen: lastIndex && lastIndex === k, unseen: lastIndex && lastIndex === k,
sameAs: _.isEqual(lastSaid, nowSaid) sameAs: _.isEqual(lastSaid, nowSaid)
}; };
@ -6293,10 +6294,13 @@ if (!window.util) {
_.merge(window.util, { _.merge(window.util, {
mainStations: ["court", "floor", "porch"], mainStations: ["court", "floor", "porch"],
mainStationPath: function(user) { mainStationPath: function(user) {
if (user == null) {
user = window.urb.user;
}
return "~" + user + "/" + (window.util.mainStation(user)); return "~" + user + "/" + (window.util.mainStation(user));
}, },
mainStation: function(user) { mainStation: function(user) {
if (!user) { if (user == null) {
user = window.urb.user; user = window.urb.user;
} }
switch (user.length) { switch (user.length) {
@ -6308,10 +6312,22 @@ _.merge(window.util, {
return "porch"; return "porch";
} }
}, },
getGlyph: function(glyphs, audi) {
return glyphs[audi.join(" ")] || (function() {
switch (false) {
case !!_.contains(audi, window.util.mainStationPath()):
return "*";
case audi.length !== 1:
return ":";
default:
return ";";
}
})();
},
clipAudi: function(audi) { clipAudi: function(audi) {
var ms, regx; var ms, regx;
audi = audi.join(" "); audi = audi.join(" ");
ms = window.util.mainStationPath(window.urb.user); ms = window.util.mainStationPath();
regx = new RegExp("/" + ms, "g"); regx = new RegExp("/" + ms, "g");
audi = audi.replace(regx, ""); audi = audi.replace(regx, "");
return audi.split(" "); return audi.split(" ");
@ -6319,7 +6335,7 @@ _.merge(window.util, {
expandAudi: function(audi) { expandAudi: function(audi) {
var ms; var ms;
audi = audi.join(" "); audi = audi.join(" ");
ms = window.util.mainStationPath(window.urb.user); ms = window.util.mainStationPath();
if (audi.indexOf(ms) === -1) { if (audi.indexOf(ms) === -1) {
if (audi.length > 0) { if (audi.length > 0) {
audi += " "; audi += " ";

View File

@ -2,10 +2,10 @@ if not window.util then window.util = {}
_.merge window.util, _.merge window.util,
mainStations: ["court","floor","porch"] mainStations: ["court","floor","porch"]
mainStationPath: (user) -> "~#{user}/#{window.util.mainStation(user)}" mainStationPath: (user = window.urb.user) ->
"~#{user}/#{window.util.mainStation(user)}"
mainStation: (user) -> mainStation: (user = window.urb.user) ->
if not user then user = window.urb.user
switch user.length switch user.length
when 3 when 3
return "court" return "court"
@ -14,16 +14,24 @@ _.merge window.util,
when 13 when 13
return "porch" return "porch"
getGlyph: (glyphs, audi)->
glyphs[audi.join " "] or switch
when not _.contains audi, window.util.mainStationPath()
"*"
when audi.length is 1
":"
else ";"
clipAudi: (audi) -> clipAudi: (audi) ->
audi = audi.join " " audi = audi.join " "
ms = window.util.mainStationPath window.urb.user ms = window.util.mainStationPath()
regx = new RegExp "/#{ms}","g" regx = new RegExp "/#{ms}","g"
audi = audi.replace regx,"" audi = audi.replace regx,""
audi.split " " audi.split " "
expandAudi: (audi) -> expandAudi: (audi) ->
audi = audi.join " " audi = audi.join " "
ms = window.util.mainStationPath window.urb.user ms = window.util.mainStationPath()
if audi.indexOf(ms) is -1 if audi.indexOf(ms) is -1
if audi.length > 0 if audi.length > 0
audi += " " audi += " "
@ -82,4 +90,4 @@ _.merge window.util,
if window.util.isScrolling() if window.util.isScrolling()
$('body').addClass 'scrolling' $('body').addClass 'scrolling'
else else
$('body').removeClass 'scrolling' $('body').removeClass 'scrolling'