var injectIntl = require('react-intl').injectIntl;
var classNames = require('classnames');
var FormattedHTMLMessage = require('react-intl').FormattedHTMLMessage;
var FormattedMessage = require('react-intl').FormattedMessage;
var React = require('react');
var render = require('../../lib/render.jsx');
var Api = require('../../mixins/api.jsx');
var Page = require('../../components/page/page.jsx');
var Button = require('../../components/forms/button.jsx');
var Box = require('../../components/box/box.jsx');
var SubNavigation = require('../../components/subnavigation/subnavigation.jsx');
var Carousel = require('../../components/carousel/carousel.jsx');
var Select = require('../../components/forms/select.jsx');
var offset = 0;
var more = [];
var searchTerm = "";
require('./search.scss');
var Search = injectIntl(React.createClass({
type: 'Search',
mixins: [
Api
],
getInitialState: function () {
return {};
},
componentDidMount: function () {
var q = pathname.lastIndexOf("q=");
var and = pathname.indexOf("&");
if (q!=-1 && and!=-1) {
searchTerm = pathname.substring(q+2,and).toLowerCase();
};
this.getSearchResults(0);
},
getSearchResults: function () {
var termText = '';
if (searchTerm!="") {
termText = "&q="+searchTerm;
};
this.api({
uri: '/search/projects?limit=16'+termText
}, function (err, body) {
if (!err) this.setState({searchResults: body});
}.bind(this));
},
getSearchMore: function () {
var termText = '';
if (searchTerm!="") {
termText = "&q="+searchTerm;
};
offset+=16;
this.api({
uri: '/search/projects?limit=16&offset='+offset+termText
}, function (err, body) {
if (!err) this.setState({searchMore: body});
}.bind(this));
},
renderRows: function () {
var row2 = this.state.searchResults;
var row3 = this.state.searchResults;
var row4 = this.state.searchResults;
if (row2!=undefined) {
row2 = row2.slice(4,8);
row3 = row3.slice(8,12);
row4 = row4.slice(12,16);
}
var rows = [
,
,
,
,
]
if (this.state.searchMore!=undefined && more.length0) {
for (var i = 0; i);
}
}
return rows;
},
getTab: function(type) {
var allTab =
;
if (tab==type) {
allTab =
;
}
return allTab;
},
render: function () {
var projects = this.renderRows();
var classes = classNames(
'top-banner',
this.state.bgClass
);
return (