io.sockets.on('connection', function(socket) {
var group = 'fnatic';
var url = 'http://steamcommunity.com/groups/' + group + '#members';
request(url, function(err, resp, body){
$ = cheerio.load(body);
links = $('a');
var users = [];
$(links).each(function(i, link){
// console.log($(link).attr('href'));
users.push($(link).attr('href'));
});
socket.emit('hatler', users);
});
});
JSON.stringify([
creditGetImage,
creditGetItemTitle,
creditGetPrice,
creditResultShow,
creditResultShowSecond
], null, 4);
var ArticleContent = React.createClass({
renderContent: function(){
if (typeof this.props.content == 'string'){
// 1. цельная строка без абзацев спокойно рендерится
return <p>{this.props.content}</p>
} else {
return (
<div>
{
this.props.content.map(function(item, i){
// 2. массив строк: каждая строка выводится в консоль, но не рендерится
console.log(item);
return <p key={i}>{item}</p>
}).join('');
}
</div>
);
}
},
render: function(){
return (
<div>
{this.renderContent()}
</div>
);
}
});
Array.prototype.map.call(document.getElementsByTagName('a'), function(link) {
return link.href;
}).filter(function(url) {
return url.endsWith('.pdf');
});
checkPrice(items).then(console.log.bind(console, "Call result: "));
function checkPrice(items) {
return Promise.all(items.map(function(item, index, array) {
return new Promise(function(resolve) {
market.getItemsPrice(730, item.market_hash_name, function(data) {
var price = parseFloat(data[item.market_hash_name].lowest_price.replace("$",""));
resolve(price);
console.log("Function result: " + price);
});
});
})).then(function(prices) {
//сумма всех полученных цен
return prices.reduce(function(result, price) {
result += price;
return result;
}, 0);
});
}