Commit e5015dc3 authored by Zac Wood's avatar Zac Wood
Browse files

Cleaned out dist from git

parent 3bfce3f8
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.tsx");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./src/components/App.tsx":
/*!********************************!*\
!*** ./src/components/App.tsx ***!
\********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = __webpack_require__(/*! react */ "react");
const SectionList_1 = __webpack_require__(/*! ./SectionList */ "./src/components/SectionList.tsx");
const Search_1 = __webpack_require__(/*! ./Search */ "./src/components/Search.tsx");
class App extends React.Component {
constructor(props) {
super(props);
this.state = { currentSchedule: [] };
this.addSectionToCurrentScheduleIfUnique = this.addSectionToCurrentScheduleIfUnique.bind(this);
}
addSectionToCurrentScheduleIfUnique(section) {
if (!this.state.currentSchedule.find(sectionInSchedule => section === sectionInSchedule)) {
this.setState({
currentSchedule: [...this.state.currentSchedule, section],
});
}
}
render() {
return (React.createElement("div", null,
React.createElement("h1", null, "Schedules"),
React.createElement(Search_1.default, { addSearchResultCallback: this.addSectionToCurrentScheduleIfUnique }),
React.createElement(SectionList_1.default, { sections: this.state.currentSchedule })));
}
}
exports.default = App;
/***/ }),
/***/ "./src/components/Search.tsx":
/*!***********************************!*\
!*** ./src/components/Search.tsx ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = __webpack_require__(/*! react */ "react");
const section_1 = __webpack_require__(/*! ../section */ "./src/section.ts");
const SearchBar_1 = __webpack_require__(/*! ./SearchBar */ "./src/components/SearchBar.tsx");
const SectionList_1 = __webpack_require__(/*! ./SectionList */ "./src/components/SectionList.tsx");
class Search extends React.Component {
constructor(props) {
super(props);
this.state = { sections: [] };
this.searchForSections = this.searchForSections.bind(this);
}
searchForSections(crn) {
section_1.fetchSectionWithCRN(crn).then(section => this.setState({ sections: [section] }));
}
render() {
return (React.createElement("div", null,
React.createElement(SearchBar_1.default, { onSearch: this.searchForSections }),
React.createElement(SectionList_1.default, { sections: this.state.sections, selectSectionCallback: this.props.addSearchResultCallback })));
}
}
exports.default = Search;
/***/ }),
/***/ "./src/components/SearchBar.tsx":
/*!**************************************!*\
!*** ./src/components/SearchBar.tsx ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = __webpack_require__(/*! react */ "react");
class SearchBar extends React.Component {
constructor(props) {
super(props);
this.state = { searchTerm: '' };
this.onSearch = this.onSearch.bind(this);
this.updateSearchTerm = this.updateSearchTerm.bind(this);
}
updateSearchTerm(event) {
this.setState({
searchTerm: event.target.value,
});
}
onSearch(event) {
this.props.onSearch(this.state.searchTerm);
event.preventDefault();
}
render() {
return (React.createElement("form", { onSubmit: this.onSearch },
React.createElement("input", { type: "text", placeholder: "Enter CRN...", value: this.state.searchTerm, onChange: this.updateSearchTerm }),
React.createElement("input", { type: "submit", value: "Search" })));
}
}
exports.default = SearchBar;
/***/ }),
/***/ "./src/components/SectionList.tsx":
/*!****************************************!*\
!*** ./src/components/SectionList.tsx ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = __webpack_require__(/*! react */ "react");
class SectionList extends React.Component {
constructor(props) {
super(props);
this.renderSelectSectionColumn = this.renderSelectSectionColumn.bind(this);
this.getSectionWithCRN = this.getSectionWithCRN.bind(this);
}
render() {
return (React.createElement("table", null,
React.createElement("tbody", null,
React.createElement("tr", null,
React.createElement("th", null, "Course"),
React.createElement("th", null, "Section Name"),
React.createElement("th", null, "CRN"),
React.createElement("th", null, "Days"),
React.createElement("th", null, "Instructor"),
React.createElement("th", null, "Location"),
React.createElement("th", null, "Time"),
React.createElement("th", null)),
this.renderRowsForSections(this.props.sections))));
}
renderRowsForSections(sections) {
return sections.map(section => {
return (React.createElement("tr", { key: section.id },
React.createElement("td", null, section.name),
React.createElement("td", null, section.title),
React.createElement("td", null, section.crn),
React.createElement("td", null, section.days),
React.createElement("td", null, section.instructor),
React.createElement("td", null, section.location),
React.createElement("td", null, [section.startTime, section.endTime].join(' - ')),
this.renderSelectSectionColumn(section.crn)));
});
}
renderSelectSectionColumn(rowCRN) {
if (this.props.selectSectionCallback) {
const sectionWithCRN = this.getSectionWithCRN(rowCRN);
return (React.createElement("td", null,
React.createElement("button", { onClick: () => this.props.selectSectionCallback(sectionWithCRN) }, "Add to schedule")));
}
else {
return React.createElement("td", null);
}
}
getSectionWithCRN(crn) {
return this.props.sections.find(section => section.crn === crn);
}
}
exports.default = SectionList;
/***/ }),
/***/ "./src/index.tsx":
/*!***********************!*\
!*** ./src/index.tsx ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = __webpack_require__(/*! react */ "react");
const ReactDOM = __webpack_require__(/*! react-dom */ "react-dom");
const App_1 = __webpack_require__(/*! ./components/App */ "./src/components/App.tsx");
ReactDOM.render(React.createElement(App_1.default, null), document.getElementById('root'));
/***/ }),
/***/ "./src/section.ts":
/*!************************!*\
!*** ./src/section.ts ***!
\************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
function fetchSectionWithCRN(crn) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield fetch(`http://localhost:3001/api/search?crn=${crn}`);
const object = yield response.json();
return {
id: object.id,
name: object.name,
title: object.title,
crn: object.crn,
instructor: object.instructor,
location: object.location,
days: object.days,
startTime: object.start_time,
endTime: object.end_time,
};
});
}
exports.fetchSectionWithCRN = fetchSectionWithCRN;
/***/ }),
/***/ "react":
/*!************************!*\
!*** external "React" ***!
\************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = React;
/***/ }),
/***/ "react-dom":
/*!***************************!*\
!*** external "ReactDOM" ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ReactDOM;
/***/ })
/******/ });
//# sourceMappingURL=bundle.js.map
\ No newline at end of file
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/components/App.tsx","webpack:///./src/components/Search.tsx","webpack:///./src/components/SearchBar.tsx","webpack:///./src/components/SectionList.tsx","webpack:///./src/index.tsx","webpack:///./src/section.ts","webpack:///external \"React\"","webpack:///external \"ReactDOM\""],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;;;ACnEA,wDAA+B;AAE/B,mGAAwC;AACxC,oFAA8B;AAM9B,SAAU,SAAQ,KAAK,CAAC,SAAqB;IACzC,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;QAErC,IAAI,CAAC,mCAAmC,GAAG,IAAI,CAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnG,CAAC;IAED,mCAAmC,CAAC,OAAgB;QAChD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,C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L;aAAM;YACH,OAAO,+BAAM,CAAC;SACjB;IACL,CAAC;IAED,iBAAiB,CAAC,GAAW;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;IACpE,CAAC;CACJ;AA5DD,8BA4DC;;;;;;;;;;;;;;;ACpED,wDAA+B;AAC/B,mEAAsC;AAEtC,sFAAmC;AAEnC,QAAQ,CAAC,MAAM,CAAC,oBAAC,aAAG,OAAG,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;ACO1D,6BAA0C,GAAW;;QACjD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,wCAAwC,GAAG,EAAE,CAAC,CAAC;QAC5E,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAErC,OAAO;YACH,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,SAAS,EAAE,MAAM,CAAC,UAAU;YAC5B,OAAO,EAAE,MAAM,CAAC,QAAQ;SAC3B,CAAC;IACN,CAAC;CAAA;AAfD,kDAeC;;;;;;;;;;;;AC3BD,uB;;;;;;;;;;;ACAA,0B","file":"bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.tsx\");\n","import * as React from 'react';\nimport Section from '../section';\nimport SectionList from './SectionList';\nimport Search from './Search';\n\ninterface State {\n currentSchedule: Section[];\n}\n\nclass App extends React.Component<any, State> {\n constructor(props: any) {\n super(props);\n this.state = { currentSchedule: [] };\n\n this.addSectionToCurrentScheduleIfUnique = this.addSectionToCurrentScheduleIfUnique.bind(this);\n }\n\n addSectionToCurrentScheduleIfUnique(section: Section) {\n if (!this.state.currentSchedule.find(sectionInSchedule => section === sectionInSchedule)) {\n this.setState({\n currentSchedule: [...this.state.currentSchedule, section],\n });\n }\n }\n\n render() {\n return (\n <div>\n <h1>Schedules</h1>\n <Search addSearchResultCallback={this.addSectionToCurrentScheduleIfUnique} />\n <SectionList sections={this.state.currentSchedule} />\n </div>\n );\n }\n}\nexport default App;\n","import * as React from 'react';\nimport Section, { fetchSectionWithCRN } from '../section';\nimport SearchBar from './SearchBar';\nimport SectionList from './SectionList';\n\ninterface Props {\n addSearchResultCallback?: (section: Section) => void;\n}\n\ninterface State {\n sections: Section[];\n}\n\nexport default class Search extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props);\n\n this.state = { sections: [] };\n this.searchForSections = this.searchForSections.bind(this);\n }\n\n searchForSections(crn: string) {\n fetchSectionWithCRN(crn).then(section => this.setState({ sections: [section] }));\n }\n\n render() {\n return (\n <div>\n <SearchBar onSearch={this.searchForSections} />\n <SectionList\n sections={this.state.sections}\n selectSectionCallback={this.props.addSearchResultCallback}\n />\n </div>\n );\n }\n}\n","import * as React from 'react';\n\ninterface Props {\n onSearch: (searchTerm: string) => void;\n}\n\ninterface State {\n searchTerm: string;\n}\n\nexport default class SearchBar extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = { searchTerm: '' };\n\n this.onSearch = this.onSearch.bind(this);\n this.updateSearchTerm = this.updateSearchTerm.bind(this);\n }\n\n updateSearchTerm(event: any) {\n this.setState({\n searchTerm: event.target.value,\n });\n }\n\n onSearch(event: any) {\n this.props.onSearch(this.state.searchTerm);\n event.preventDefault();\n }\n\n render() {\n return (\n <form onSubmit={this.onSearch}>\n <input\n type=\"text\"\n placeholder=\"Enter CRN...\"\n value={this.state.searchTerm}\n onChange={this.updateSearchTerm}\n />\n <input type=\"submit\" value=\"Search\" />\n </form>\n );\n }\n}\n","import * as React from 'react';\nimport Section from '../section';\n\ninterface Props {\n sections: Section[];\n selectSectionCallback?: (section: Section) => void;\n}\n\nexport default class SectionList extends React.Component<Props, any> {\n constructor(props: Props) {\n super(props);\n\n this.renderSelectSectionColumn = this.renderSelectSectionColumn.bind(this);\n this.getSectionWithCRN = this.getSectionWithCRN.bind(this);\n }\n render() {\n return (\n <table>\n <tbody>\n <tr>\n <th>Course</th>\n <th>Section Name</th>\n <th>CRN</th>\n <th>Days</th>\n <th>Instructor</th>\n <th>Location</th>\n <th>Time</th>\n <th />\n </tr>\n {this.renderRowsForSections(this.props.sections)}\n </tbody>\n </table>\n );\n }\n\n renderRowsForSections(sections: Section[]): JSX.Element[] {\n return sections.map(section => {\n return (\n <tr key={section.id}>\n <td>{section.name}</td>\n <td>{section.title}</td>\n <td>{section.crn}</td>\n <td>{section.days}</td>\n <td>{section.instructor}</td>\n <td>{section.location}</td>\n <td>{[section.startTime, section.endTime].join(' - ')}</td>\n {this.renderSelectSectionColumn(section.crn)}\n </tr>\n );\n });\n }\n\n renderSelectSectionColumn(rowCRN: string): JSX.Element {\n if (this.props.selectSectionCallback) {\n const sectionWithCRN = this.getSectionWithCRN(rowCRN);\n return (\n <td>\n <button onClick={() => this.props.selectSectionCallback(sectionWithCRN)}>Add to schedule</button>\n </td>\n );\n } else {\n return <td />;\n }\n }\n\n getSectionWithCRN(crn: string): Section {\n return this.props.sections.find(section => section.crn === crn);\n }\n}\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\n\nimport App from './components/App';\n\nReactDOM.render(<App />, document.getElementById('root'));\n","export default interface Section {\n id: number;\n name: string;\n title: string;\n crn: string;\n instructor: string;\n location: string;\n days: string;\n startTime: string;\n endTime: string;\n}\n\nexport async function fetchSectionWithCRN(crn: string): Promise<Section> {\n const response = await fetch(`http://localhost:3001/api/search?crn=${crn}`);\n const object = await response.json();\n\n return {\n id: object.id,\n name: object.name,\n title: object.title,\n crn: object.crn,\n instructor: object.instructor,\n location: object.location,\n days: object.days,\n startTime: object.start_time,\n endTime: object.end_time,\n };\n}\n","module.exports = React;","module.exports = ReactDOM;"],"sourceRoot":""}
\ No newline at end of file
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