Commit a96a3591 authored by Jed Simson's avatar Jed Simson

Adhere to src/build/dist folder structure

parent 987a066b
This diff is collapsed.
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var SubredditField = React.createClass({displayName: "SubredditField",
getInitialState: function() {
return {default: 'programming',
subreddit: 'programming'};
},
handleChange: function(event) {
var oldValue = this.state.subreddit;
this.setState({subreddit: event.target.value});
this.props.onChange(event, oldValue);
},
render: function() {
return (
React.createElement("fieldset", {className: "form-group"},
React.createElement("label", {htmlFor: "subreddit"}, React.createElement("strong", null, " Subreddit ")),
React.createElement("div", {className: "input-group"},
React.createElement("span", {className: "input-group-addon"}, "/r/"),
React.createElement("input", {
type: "text",
id: "subreddit",
className: "form-control",
placeholder: this.state.default,
onChange: this.handleChange})
)
)
);
}
});
var RangeField = React.createClass({displayName: "RangeField",
getInitialState: function() {
return {default: 'today',
range: 'today'};
},
handleChange: function(event) {
var oldValue = this.state.range;
var newValue = event.target.value;
newValue = newValue.split(' ').join('+');
this.setState({range: newValue});
this.props.onChange(event, oldValue);
},
render: function() {
return (
React.createElement("fieldset", {className: "form-group"},
React.createElement("label", {for: "range"}, React.createElement("strong", null, " Range ")),
React.createElement("input", {
type: "text",
id: "range",
className: "form-control",
placeholder: this.state.default,
onChange: this.handleChange})
)
);
}
});
var SortField = React.createClass({displayName: "SortField",
getInitialState: function() {
return {default: 'hot',
sort: 'hot'};
},
handleChange: function(event) {
var oldValue = this.state.sort;
this.setState({sort: event.target.value});
this.props.onChange(event, oldValue);
},
render: function() {
return (
React.createElement("fieldset", {className: "form-group"},
React.createElement("label", {for: "sort"}, React.createElement("strong", null, " Sort ")),
React.createElement("select", {className: "form-control", id: "sort", defaultValue: this.state.default, onChange: this.handleChange},
React.createElement("option", {value: "hot"}, "Hot"),
React.createElement("option", {value: "top"}, "Top"),
React.createElement("option", {value: "new"}, "New"),
React.createElement("option", {value: "controversial"}, "Controversial")
)
)
);
}
});
var LimitField = React.createClass({displayName: "LimitField",
getInitialState: function() {
return {default: '100',
limit: '100'};
},
handleChange: function(event) {
var oldValue = this.state.limit;
this.setState({limit: event.target.value});
this.props.onChange(event, oldValue);
},
render: function() {
return (
React.createElement("fieldset", {className: "form-group"},
React.createElement("label", {for: "limit"}, React.createElement("strong", null, " Limit ")),
React.createElement("input", {type: "number", min: "1", className: "form-control", id: "limit", onChange: this.handleChange, defaultValue: this.state.default})
)
);
}
});
module.exports = {
SubredditField: SubredditField,
RangeField: RangeField,
SortField: SortField,
LimitField: LimitField
};
},{}]},{},[1]);
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var Information = React.createClass({displayName: "Information",
render: function() {
return (
React.createElement("div", null,
React.createElement("br", null),
React.createElement("h1", null, "Reddit Slider"),
React.createElement("hr", null),
React.createElement("p", null, "Please enter your query using the options below..."),
React.createElement("p", null, "The range field accepts values like:"),
React.createElement("ul", null,
React.createElement("li", null, "\"Today\""),
React.createElement("li", null, "\"June 20 2016 to now\""),
React.createElement("li", null, "\"May 18 8:00am to May 18 2:00pm\""),
React.createElement("li", null, "\"1 year ago\"")
)
)
);
}
});
module.exports = Information;
},{}]},{},[1]);
var SubredditField = React.createClass({
getInitialState: function() {
return {default: 'programming',
subreddit: 'programming'};
},
handleChange: function(event) {
var oldValue = this.state.subreddit;
this.setState({subreddit: event.target.value});
this.props.onChange(event, oldValue);
},
render: function() {
return (
<fieldset className="form-group">
<label htmlFor="subreddit"><strong>&nbsp;Subreddit&nbsp;</strong></label>
<div className="input-group">
<span className="input-group-addon">/r/</span>
<input
type="text"
id="subreddit"
className="form-control"
placeholder={this.state.default}
onChange={this.handleChange}/>
</div>
</fieldset>
);
}
});
var RangeField = React.createClass({
getInitialState: function() {
return {default: 'today',
range: 'today'};
},
handleChange: function(event) {
var oldValue = this.state.range;
var newValue = event.target.value;
newValue = newValue.split(' ').join('+');
this.setState({range: newValue});
this.props.onChange(event, oldValue);
},
render: function() {
return (
<fieldset className="form-group">
<label for="range"><strong>&nbsp;Range&nbsp;</strong></label>
<input
type="text"
id="range"
className="form-control"
placeholder={this.state.default}
onChange={this.handleChange}/>
</fieldset>
);
}
});
var SortField = React.createClass({
getInitialState: function() {
return {default: 'hot',
sort: 'hot'};
},
handleChange: function(event) {
var oldValue = this.state.sort;
this.setState({sort: event.target.value});
this.props.onChange(event, oldValue);
},
render: function() {
return (
<fieldset className="form-group">
<label for="sort"><strong>&nbsp;Sort&nbsp;</strong></label>
<select className="form-control" id="sort" defaultValue={this.state.default} onChange={this.handleChange}>
<option value="hot">Hot</option>
<option value="top">Top</option>
<option value="new">New</option>
<option value="controversial">Controversial</option>
</select>
</fieldset>
);
}
});
var LimitField = React.createClass({
getInitialState: function() {
return {default: '100',
limit: '100'};
},
handleChange: function(event) {
var oldValue = this.state.limit;
this.setState({limit: event.target.value});
this.props.onChange(event, oldValue);
},
render: function() {
return (
<fieldset className="form-group">
<label for="limit"><strong>&nbsp;Limit&nbsp;</strong></label>
<input type="number" min="1" className="form-control" id="limit" onChange={this.handleChange} defaultValue={this.state.default}/>
</fieldset>
);
}
});
module.exports = {
SubredditField: SubredditField,
RangeField: RangeField,
SortField: SortField,
LimitField: LimitField
};
const InformationSection = require('./InformationSection.js');
const SearchForm = require('./SearchForm.js');
const Container = React.createClass({
render: function() {
return (
<div className="container">
<div className="content" id="content">
<InformationSection />
<SearchForm />
</div>
</div>
);
}
});
ReactDOM.render(
<Container />,
document.getElementById('react-mount-point')
);
var SubredditField = require('./SubredditField.js');
var RangeField = require('./RangeField.js');
var SortField = require('./SortField.js');
var LimitField = require('./LimitField.js');
module.exports = {
SubredditField: SubredditField,
RangeField: RangeField,
SortField: SortField,
LimitField: LimitField
};
var Information = React.createClass({
const InformationSection = React.createClass({
render: function() {
return (
<div>
......@@ -19,4 +19,4 @@ var Information = React.createClass({
}
});
module.exports = Information;
module.exports = InformationSection;
const LimitField = React.createClass({
getInitialState: function() {
return {default: '100',
limit: '100'};
},
handleChange: function(event) {
let oldValue = this.state.limit;
let newValue = event.target.value;
newValue = newValue == '' ? this.state.default : newValue;
this.setState({limit: newValue});
this.props.onChange(event, oldValue, newValue);
},
render: function() {
return (
<fieldset className="form-group">
<label for="limit"><strong>&nbsp;Limit&nbsp;</strong></label>
<input type="number" min="1" className="form-control" id="limit" onChange={this.handleChange} defaultValue={this.state.default}/>
</fieldset>
);
}
});
module.exports = LimitField;
const RangeField = React.createClass({
getInitialState: function() {
return {default: 'today',
range: 'today'};
},
handleChange: function(event) {
let oldValue = this.state.range;
let newValue = event.target.value;
newValue = newValue.split(' ').join('+');
newValue = newValue == '' ? this.state.default : newValue;
this.setState({range: newValue});
this.props.onChange(event, oldValue, newValue);
},
render: function() {
return (
<fieldset className="form-group">
<label for="range"><strong>&nbsp;Range&nbsp;</strong></label>
<input
type="text"
id="range"
className="form-control"
placeholder={this.state.default}
onChange={this.handleChange}/>
</fieldset>
);
}
});
module.exports = RangeField;
const ResultsPanel = React.createClass({
getInitialState: function() {
return {loading: false, submissions: [], info: '', showResults: false, hasError: false};
},
isLoading: function() {
this.setState({
hasError: false,
error: null,
loading: true,
submissions: [],
info: '',
showResults: true
});
},
render: function() {
let noSubmissions = this.state.submissions.length == 0;
if (!noSubmissions) {
var submissions = this.state.submissions.map(function(submission) {
return (
<a key={submission['timestamp']} target="_blank" href={submission['href']} className="list-group-item">
<h5 className="list-group-item-heading">{submission['info']}</h5>
<p className="list-group-item-text text-muted"><em>{submission['date']}</em></p>
</a>
);
});
}
if (this.state.showResults) {
return (
<div className="card" id="results-card">
<div className="card-block">
<h4 className="card-title">Results</h4>
{!noSubmissions ? <div id="info" className="alert alert-info">{this.state.info}</div> : null}
</div>
<div className="card-block">
<div className="list-group" id="results">
{this.state.hasError ? <div className="alert alert-danger">{this.state.error.msg}</div> : null}
{!noSubmissions ? submissions : null}
{this.state.loading ? <div id="loading"><strong>Loading...</strong></div> : null}
</div>
</div>
</div>
);
} else {
return null;
}
}
});
module.exports = ResultsPanel;
var Information = require('./information.js')
var {SubredditField, RangeField, SortField, LimitField} = require('./fields.js')
const ResultsPanel = require('./ResultsPanel.js');
const {SubredditField, RangeField, SortField, LimitField} = require('./Fields.js');
var Container = React.createClass({
render: function() {
return (
<div className="container">
<div className="content" id="content">
<Information />
<SearchForm />
</div>
</div>
);
}
});
var SearchForm = React.createClass({
const SearchForm = React.createClass({
getInitialState: function() {
var queryParams = {subreddit: 'programming', range: 'today',
let queryParams = {subreddit: 'programming', range: 'today',
sort: 'hot', limit: '100'};
var query = this.serializeQuery(queryParams);
var urlBase = '/api/search/';
let query = this.serializeQuery(queryParams);
let urlBase = '/api/search/';
return {params: queryParams, query: query, url: urlBase};
},
serializeQuery: function(params) {
var query = params.subreddit + '/?range=' + params.range.split(' ').join('+') +
let query = params.subreddit + '/?range=' + params.range.split(' ').join('+') +
'&sort=' + params.sort + '&limit=' + params.limit;
return query;
......@@ -65,10 +51,10 @@ var SearchForm = React.createClass({
});
}.bind(this)).then(function(data) {
var resultsPanel = this.refs.resultsPanel;
var count = data['count'];
var time = data['time'];
var submissions = data['submissions'];
let resultsPanel = this.refs.resultsPanel;
let count = data['count'];
let time = data['time'];
let submissions = data['submissions'];
resultsPanel.setState({
submissions: submissions,
......@@ -84,17 +70,14 @@ var SearchForm = React.createClass({
event.preventDefault();
this.fetchResults();
},
handleChange: function(event, oldValue) {
var newValue = event.target.value;
var newParams = this.state.params;
newParams[event.target.id] = newValue
handleChange: function(event, oldValue, newValue) {
let newParams = this.state.params;
newParams[event.target.id] = newValue || event.target.value;
this.setState({
params: newParams,
query: this.serializeQuery(newParams)
});
console.log('Updated ' + event.target.id + ' state: ' + oldValue + ' => ' + newValue);
},
render: function() {
return (
......@@ -116,57 +99,4 @@ var SearchForm = React.createClass({
}
});
var ResultsPanel = React.createClass({
getInitialState: function() {
return {loading: false, submissions: [], info: '', showResults: false, hasError: false};
},
isLoading: function() {
this.setState({
hasError: false,
error: null,
loading: true,
submissions: [],
info: '',
showResults: true
});
},
render: function() {
var noSubmissions = this.state.submissions.length == 0;
if (!noSubmissions) {
var submissions = this.state.submissions.map(function(submission) {
return (
<a key={submission['timestamp']} target="_blank" href={submission['href']} className="list-group-item">
<h5 className="list-group-item-heading">{submission['info']}</h5>
<p className="list-group-item-text text-muted"><em>{submission['date']}</em></p>
</a>
);
});
}
if (this.state.showResults) {
return (
<div className="card" id="results-card">
<div className="card-block">
<h4 className="card-title">Results</h4>
{!noSubmissions ? <div id="info" className="alert alert-info">{this.state.info}</div> : null}
</div>
<div className="card-block">
<div className="list-group" id="results">
{this.state.hasError ? <div className="alert alert-danger">{this.state.error.msg}</div> : null}
{!noSubmissions ? submissions : null}
{this.state.loading ? <div id="loading"><strong>Loading...</strong></div> : null}
</div>
</div>
</div>
);
} else {
return null;
}
}
});
ReactDOM.render(
<Container />,
document.getElementById('react-mount-point')
);
module.exports = SearchForm;
const SortField = React.createClass({
getInitialState: function() {
return {default: 'hot',
sort: 'hot'};
},
handleChange: function(event) {
let oldValue = this.state.sort;
let newValue = event.target.value
newValue = newValue == '' ? this.state.default : newValue;
this.setState({sort: newValue});
this.props.onChange(event, oldValue, newValue);
},
render: function() {
return (
<fieldset className="form-group">
<label for="sort"><strong>&nbsp;Sort&nbsp;</strong></label>
<select className="form-control" id="sort" defaultValue={this.state.default} onChange={this.handleChange}>
<option value="hot">Hot</option>
<option value="top">Top</option>
<option value="new">New</option>
<option value="controversial">Controversial</option>
</select>
</fieldset>
);
}
});
module.exports = SortField;
const SubredditField = React.createClass({
getInitialState: function() {
return {default: 'programming',
subreddit: 'programming'};
},
handleChange: function(event) {
let oldValue = this.state.subreddit;
let newValue = event.target.value;
newValue = newValue == '' ? this.state.default : newValue;
this.setState({subreddit: newValue});
this.props.onChange(event, oldValue, newValue);
},
render: function() {
return (
<fieldset className="form-group">
<label htmlFor="subreddit"><strong>&nbsp;Subreddit&nbsp;</strong></label>
<div className="input-group">
<span className="input-group-addon">/r/</span>
<input
type="text"
id="subreddit"
className="form-control"
placeholder={this.state.default}
onChange={this.handleChange}/>
</div>
</fieldset>
);
}
});
module.exports = SubredditField;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment