mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-11 16:09:31 +03:00
parent
c5e7c7cc33
commit
36eacf4a30
151
web/talk/main.js
151
web/talk/main.js
@ -201,13 +201,6 @@ Persistence = _persistence({
|
|||||||
type: "station-listen"
|
type: "station-listen"
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
createStation: function(station) {
|
|
||||||
Dispatcher.handleViewAction({
|
|
||||||
station: station,
|
|
||||||
type: "station-create"
|
|
||||||
});
|
|
||||||
return Persistence.createStation(station);
|
|
||||||
},
|
|
||||||
listen: function() {
|
listen: function() {
|
||||||
return Persistence.listen();
|
return Persistence.listen();
|
||||||
},
|
},
|
||||||
@ -224,8 +217,12 @@ Persistence = _persistence({
|
|||||||
'cabal': 'cabal'
|
'cabal': 'cabal'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
createStation: function(name) {
|
createStation: function(station) {
|
||||||
return Persistence.createStation(name);
|
Dispatcher.handleViewAction({
|
||||||
|
station: station,
|
||||||
|
type: "station-create"
|
||||||
|
});
|
||||||
|
return Persistence.createStation(station);
|
||||||
},
|
},
|
||||||
setSources: function(station, sources) {
|
setSources: function(station, sources) {
|
||||||
return Persistence.setSources(station, window.urb.ship, sources);
|
return Persistence.setSources(station, window.urb.ship, sources);
|
||||||
@ -305,7 +302,7 @@ module.exports = recl({
|
|||||||
|
|
||||||
|
|
||||||
},{}],5:[function(require,module,exports){
|
},{}],5:[function(require,module,exports){
|
||||||
var Member, a, clas, div, h2, h3, label, pre, recl, ref, util,
|
var Member, a, clas, div, h2, h3, label, pre, recl, ref, rele, util,
|
||||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||||
|
|
||||||
util = require('../util.coffee');
|
util = require('../util.coffee');
|
||||||
@ -314,6 +311,8 @@ clas = require('classnames');
|
|||||||
|
|
||||||
recl = React.createClass;
|
recl = React.createClass;
|
||||||
|
|
||||||
|
rele = React.createElement;
|
||||||
|
|
||||||
ref = React.DOM, div = ref.div, pre = ref.pre, a = ref.a, label = ref.label, h2 = ref.h2, h3 = ref.h3;
|
ref = React.DOM, div = ref.div, pre = ref.pre, a = ref.a, label = ref.label, h2 = ref.h2, h3 = ref.h3;
|
||||||
|
|
||||||
Member = require('./MemberComponent.coffee');
|
Member = require('./MemberComponent.coffee');
|
||||||
@ -356,9 +355,16 @@ module.exports = recl({
|
|||||||
}
|
}
|
||||||
return this.props._handlePm(user);
|
return this.props._handlePm(user);
|
||||||
},
|
},
|
||||||
|
abbreviate: function(s) {
|
||||||
|
if (s.length <= 80) {
|
||||||
|
return s;
|
||||||
|
} else {
|
||||||
|
return (s.slice(0, 77)) + "...";
|
||||||
|
}
|
||||||
|
},
|
||||||
renderSpeech: function(arg) {
|
renderSpeech: function(arg) {
|
||||||
var app, com, exp, fat, lin, mor, tax, url, x;
|
var app, comment, exp, fat, lin, mor, post, tax, url, x;
|
||||||
lin = arg.lin, app = arg.app, exp = arg.exp, tax = arg.tax, url = arg.url, mor = arg.mor, fat = arg.fat, com = arg.com;
|
lin = arg.lin, app = arg.app, exp = arg.exp, tax = arg.tax, url = arg.url, mor = arg.mor, fat = arg.fat, comment = arg.comment, post = arg.post;
|
||||||
switch (false) {
|
switch (false) {
|
||||||
case !(lin || app || exp || tax):
|
case !(lin || app || exp || tax):
|
||||||
return (lin || app || exp || tax).txt;
|
return (lin || app || exp || tax).txt;
|
||||||
@ -368,11 +374,14 @@ module.exports = recl({
|
|||||||
target: "_blank",
|
target: "_blank",
|
||||||
key: "speech"
|
key: "speech"
|
||||||
}, url.txt);
|
}, url.txt);
|
||||||
case !com:
|
case !comment:
|
||||||
return div({}, com.txt, div({}, a({
|
return div({}, a({
|
||||||
className: "btn",
|
href: comment.url
|
||||||
href: com.url
|
}, this.abbreviate(comment.txt)));
|
||||||
}, "Go to thread")));
|
case !post:
|
||||||
|
return div({}, a({
|
||||||
|
href: post.url
|
||||||
|
}, post.title));
|
||||||
case !mor:
|
case !mor:
|
||||||
return mor.map(this.renderSpeech);
|
return mor.map(this.renderSpeech);
|
||||||
case !fat:
|
case !fat:
|
||||||
@ -432,13 +441,13 @@ module.exports = recl({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
var aude, audi, bouquet, className, comment, delivery, k, mainStation, name, path, ref1, speech, style, thought, txt, type, url, v;
|
var aude, audi, bouquet, className, comment, delivery, glyph, k, mainStation, name, path, post, ref1, ref2, speech, style, thought, title, txt, type, url, v;
|
||||||
thought = this.props.thought;
|
thought = this.props.thought;
|
||||||
delivery = _.uniq(_.pluck(thought.audience, "delivery"));
|
delivery = _.uniq(_.pluck(thought.audience, "delivery"));
|
||||||
speech = thought.statement.speech;
|
speech = thought.statement.speech;
|
||||||
bouquet = thought.statement.bouquet;
|
bouquet = thought.statement.bouquet;
|
||||||
if (speech == null) {
|
if (speech == null) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
name = this.props.name ? this.props.name : "";
|
name = this.props.name ? this.props.name : "";
|
||||||
aude = _.keys(thought.audience);
|
aude = _.keys(thought.audience);
|
||||||
@ -466,21 +475,47 @@ module.exports = recl({
|
|||||||
href: url
|
href: url
|
||||||
}, path);
|
}, path);
|
||||||
speech = {
|
speech = {
|
||||||
com: {
|
comment: {
|
||||||
txt: txt,
|
txt: txt,
|
||||||
url: url
|
url: url
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
className = clas('gram', (this.props.sameAs ? "same" : "first"), (delivery.indexOf("received") !== -1 ? "received" : "pending"), {
|
if (_.filter(bouquet, ["fora-post"]).length > 0) {
|
||||||
|
post = true;
|
||||||
|
ref2 = speech.mor;
|
||||||
|
for (k in ref2) {
|
||||||
|
v = ref2[k];
|
||||||
|
if (v.fat) {
|
||||||
|
url = v.fat.taf.url.txt;
|
||||||
|
txt = v.fat.tor.text;
|
||||||
|
}
|
||||||
|
if (v.app) {
|
||||||
|
title = v.app.txt.replace("forum post: ", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
audi = a({
|
||||||
|
href: url
|
||||||
|
}, title);
|
||||||
|
speech = {
|
||||||
|
post: {
|
||||||
|
txt: txt,
|
||||||
|
url: url,
|
||||||
|
title: title
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
className = clas('gram', (this.props.sameAs ? "same" : "first"), ((indexOf.call(delivery, "received") >= 0) ? "received" : "pending"), {
|
||||||
'new': this.props.unseen
|
'new': this.props.unseen
|
||||||
}, {
|
}, {
|
||||||
comment: comment
|
comment: comment,
|
||||||
|
post: post
|
||||||
}, this.classesInSpeech(speech));
|
}, this.classesInSpeech(speech));
|
||||||
style = {
|
style = {
|
||||||
height: this.props.height,
|
height: this.props.height,
|
||||||
marginTop: this.props.marginTop
|
marginTop: this.props.marginTop
|
||||||
};
|
};
|
||||||
|
glyph = this.props.glyph || "*";
|
||||||
return div({
|
return div({
|
||||||
className: className,
|
className: className,
|
||||||
'data-index': this.props.index,
|
'data-index': this.props.index,
|
||||||
@ -491,12 +526,12 @@ module.exports = recl({
|
|||||||
key: "meta"
|
key: "meta"
|
||||||
}, label({
|
}, label({
|
||||||
className: "type " + type,
|
className: "type " + type,
|
||||||
"data-glyph": this.props.glyph || "*"
|
"data-glyph": glyph
|
||||||
}), h2({
|
}), h2({
|
||||||
className: 'author planet',
|
className: 'author planet',
|
||||||
onClick: this._handlePm,
|
onClick: this._handlePm,
|
||||||
key: "member"
|
key: "member"
|
||||||
}, React.createElement(Member, {
|
}, rele(Member, {
|
||||||
ship: this.props.ship,
|
ship: this.props.ship,
|
||||||
glyph: this.props.glyph,
|
glyph: this.props.glyph,
|
||||||
key: "member"
|
key: "member"
|
||||||
@ -613,12 +648,10 @@ module.exports = recl({
|
|||||||
sortedMessages: function(messages) {
|
sortedMessages: function(messages) {
|
||||||
var station;
|
var station;
|
||||||
station = this.state.station;
|
station = this.state.station;
|
||||||
return _.sortBy(messages, (function(_this) {
|
return _.sortBy(messages, function(message) {
|
||||||
return function(message) {
|
message.pending = message.thought.audience[station];
|
||||||
message.pending = message.thought.audience[station];
|
return message.key;
|
||||||
return message.key;
|
});
|
||||||
};
|
|
||||||
})(this));
|
|
||||||
},
|
},
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
return Infinite = window.Infinite;
|
return Infinite = window.Infinite;
|
||||||
@ -718,16 +751,20 @@ module.exports = recl({
|
|||||||
sameAs = _.isEqual(lastSaid, nowSaid);
|
sameAs = _.isEqual(lastSaid, nowSaid);
|
||||||
lastSaid = nowSaid;
|
lastSaid = nowSaid;
|
||||||
lineNums = 1;
|
lineNums = 1;
|
||||||
speechArr = [];
|
speech = message.thought.statement.speech;
|
||||||
context.font = FONT_SIZE + 'px bau';
|
context.font = speech.fat == null ? (FONT_SIZE * 0.9) + 'px scp' : FONT_SIZE + 'px bau';
|
||||||
if (message.thought.statement.speech.lin != null) {
|
speechArr = (function() {
|
||||||
speechArr = message.thought.statement.speech.lin.txt.split(/(\s|-)/);
|
switch (false) {
|
||||||
} else if (message.thought.statement.speech.url != null) {
|
case speech.lin == null:
|
||||||
speechArr = message.thought.statement.speech.url.txt.split(/(\s|-)/);
|
return speechArr = speech.lin.txt.split(/(\s|-)/);
|
||||||
} else if (message.thought.statement.speech.fat != null) {
|
case speech.url == null:
|
||||||
context.font = (FONT_SIZE * 0.9) + 'px scp';
|
return speechArr = speech.url.txt.split(/(\s|-)/);
|
||||||
speechArr = message.thought.statement.speech.fat.taf.exp.txt.split(/(\s|-)/);
|
case speech.fat == null:
|
||||||
}
|
return speech.fat.taf.exp.txt.split(/(\s|-)/);
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
})();
|
||||||
_.reduce(_.tail(speechArr), function(base, word) {
|
_.reduce(_.tail(speechArr), function(base, word) {
|
||||||
if (context.measureText(base + word).width > speechLength) {
|
if (context.measureText(base + word).width > speechLength) {
|
||||||
lineNums += 1;
|
lineNums += 1;
|
||||||
@ -754,7 +791,6 @@ module.exports = recl({
|
|||||||
height = null;
|
height = null;
|
||||||
marginTop = null;
|
marginTop = null;
|
||||||
}
|
}
|
||||||
speech = message.thought.statement.speech;
|
|
||||||
audience = (_.keys(message.thought.audience)).join(" ");
|
audience = (_.keys(message.thought.audience)).join(" ");
|
||||||
mez = rele(Message, _.extend({}, message, {
|
mez = rele(Message, _.extend({}, message, {
|
||||||
station: station,
|
station: station,
|
||||||
@ -856,7 +892,7 @@ module.exports = recl({
|
|||||||
return this.setState(this.stateFromStore());
|
return this.setState(this.stateFromStore());
|
||||||
},
|
},
|
||||||
componentWillReceiveProps: function(nextProps) {
|
componentWillReceiveProps: function(nextProps) {
|
||||||
if (this.props.open === true && nextProps.open === false) {
|
if (this.props.open && nextProps.open === false) {
|
||||||
return this.setState({
|
return this.setState({
|
||||||
open: null
|
open: null
|
||||||
});
|
});
|
||||||
@ -1064,7 +1100,7 @@ Audience = recl({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_autoCompleteAudience: function() {
|
_autoCompleteAudience: function() {
|
||||||
var aud, g, i, j, len, len1, ref1, ref2, s, stations, txt;
|
var aud, g, i, j, len, len1, modulo, ref1, ref2, s, stations, txt;
|
||||||
txt = $('#audience .input').text().trim();
|
txt = $('#audience .input').text().trim();
|
||||||
if (this.tabAudList == null) {
|
if (this.tabAudList == null) {
|
||||||
this.tabAudList = [];
|
this.tabAudList = [];
|
||||||
@ -1097,7 +1133,10 @@ Audience = recl({
|
|||||||
} else {
|
} else {
|
||||||
this.tabAudIndex++;
|
this.tabAudIndex++;
|
||||||
}
|
}
|
||||||
this.tabAudIndex = (this.tabAudIndex % this.tabAudList.length + this.tabAudList.length) % this.tabAudList.length;
|
modulo = function(a, b) {
|
||||||
|
return ((a % b) + a) % b;
|
||||||
|
};
|
||||||
|
this.tabAudIndex = modulo(this.tabAudIndex, this.tabAudList.length);
|
||||||
} else {
|
} else {
|
||||||
this.tabAudIndex = 0;
|
this.tabAudIndex = 0;
|
||||||
}
|
}
|
||||||
@ -1251,7 +1290,7 @@ module.exports = recl({
|
|||||||
return this.set();
|
return this.set();
|
||||||
},
|
},
|
||||||
_autoComplete: function() {
|
_autoComplete: function() {
|
||||||
var i, msg, name, obj, ptxt, ref1, ref2, tindex, txt;
|
var i, modulo, msg, name, obj, ptxt, ref1, ref2, tindex, txt;
|
||||||
txt = this.$message.text();
|
txt = this.$message.text();
|
||||||
tindex = txt.lastIndexOf('~');
|
tindex = txt.lastIndexOf('~');
|
||||||
if (tindex === -1) {
|
if (tindex === -1) {
|
||||||
@ -1281,7 +1320,10 @@ module.exports = recl({
|
|||||||
} else {
|
} else {
|
||||||
this.tabIndex++;
|
this.tabIndex++;
|
||||||
}
|
}
|
||||||
this.tabIndex = (this.tabIndex % this.tabList.length + this.tabList.length) % this.tabList.length;
|
modulo = function(a, b) {
|
||||||
|
return ((a % b) + a) % b;
|
||||||
|
};
|
||||||
|
this.tabIndex = modulo(this.tabIndex, this.tabList.length);
|
||||||
} else {
|
} else {
|
||||||
this.tabIndex = 0;
|
this.tabIndex = 0;
|
||||||
}
|
}
|
||||||
@ -1785,13 +1827,14 @@ MessageStore = _.merge(new EventEmitter, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
convertDate: function(time) {
|
convertDate: function(time) {
|
||||||
var d;
|
var date, t;
|
||||||
time = time.substr(1).split(".");
|
time = time.substr(1).split(".");
|
||||||
time[1] = this.leadingZero(time[1]);
|
time[1] = this.leadingZero(time[1]);
|
||||||
time[2] = this.leadingZero(time[2]);
|
time[2] = this.leadingZero(time[2]);
|
||||||
d = new moment(time[0] + "-" + time[1] + "-" + time[2] + "T" + time[4] + ":" + time[5] + ":" + time[6] + "Z");
|
t = time;
|
||||||
d.tz("Europe/London");
|
date = new moment(t[0] + "-" + t[1] + "-" + t[2] + "T" + t[4] + ":" + t[5] + ":" + t[6] + "Z");
|
||||||
return d;
|
date.tz("Europe/London");
|
||||||
|
return date;
|
||||||
},
|
},
|
||||||
getListening: function() {
|
getListening: function() {
|
||||||
return _listening;
|
return _listening;
|
||||||
@ -1804,8 +1847,10 @@ MessageStore = _.merge(new EventEmitter, {
|
|||||||
if (_.keys(_messages).length === 0) {
|
if (_.keys(_messages).length === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
messages = _.sortBy(_messages, function(_message) {
|
messages = _.sortBy(_messages, function(arg) {
|
||||||
return _message.thought.statement.time;
|
var time;
|
||||||
|
time = arg.thought.statement.time;
|
||||||
|
return time;
|
||||||
});
|
});
|
||||||
return _.keys(messages[messages.length - 1].thought.audience);
|
return _.keys(messages[messages.length - 1].thought.audience);
|
||||||
},
|
},
|
||||||
@ -2125,7 +2170,7 @@ module.exports = util = {
|
|||||||
var station;
|
var station;
|
||||||
if (document.location.search) {
|
if (document.location.search) {
|
||||||
station = document.location.search.replace(/^\?/, '');
|
station = document.location.search.replace(/^\?/, '');
|
||||||
if (station.indexOf('dbg.nopack') !== -1) {
|
if (station.indexOf('dbg.') !== -1) {
|
||||||
return station = util.mainStation();
|
return station = util.mainStation();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user