mirror of
https://github.com/k4m4/movies-for-hackers.git
synced 2024-11-23 22:44:57 +00:00
He's only gone and bloody done it!
This commit is contained in:
parent
f177a45a92
commit
da850e6154
2
dist/css/app.css
vendored
2
dist/css/app.css
vendored
@ -1 +1 @@
|
|||||||
.container-fluid{max-width:1440px}th{text-transform:capitalize}
|
.container-fluid{max-width:1440px}h2{font-size:20px}th{text-transform:capitalize;background:#eef7fd}.react-bs-table{border:1px solid #ddd;border-radius:2px;margin:0}.table>tbody>tr>td,.table>tbody>tr>th,.table>tfoot>tr>td,.table>tfoot>tr>th,.table>thead>tr>td,.table>thead>tr>th{padding:1px 6px}
|
2
dist/js/app.js
vendored
2
dist/js/app.js
vendored
@ -1 +1 @@
|
|||||||
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),client=new XMLHttpRequest,objectifyMarkdownNotWomen=new marked.Renderer,moviesCollection,movies,cellCounter=0,lastHeading="",headers=["movie","genre","year","rating"],Table=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.movies=e.movies,o.columns=[],headers.map(function(e,t){var n=0==t;o.columns.push(React.createElement(TableHeaderColumn,{key:t,isKey:n,dataField:e,dataSort:!0},e))}),o}return _inherits(t,e),_createClass(t,[{key:"render",value:function(){return React.createElement(BootstrapTable,{data:this.movies,hover:!0},this.columns)}}]),t}(React.Component);objectifyMarkdownNotWomen.heading=function(e,t){lastHeading=e},objectifyMarkdownNotWomen.tablerow=function(e){cellCounter=0,movies.push({})},objectifyMarkdownNotWomen.tablecell=function(e,t){movies[movies.length-1][headers[cellCounter]]=e,cellCounter++},objectifyMarkdownNotWomen.table=function(e,t){movies[0][headers[0]].toLowerCase()==headers[0]&&movies.splice(0,1),null==movies[movies.length-1][headers[0]]&&movies.pop(),moviesCollection.push({heading:lastHeading,movies:movies}),movies=[{}]},client.open("GET",window.location.href+"README.md"),client.onreadystatechange=function(e){moviesCollection=[],movies=[{}],marked(client.responseText,{renderer:objectifyMarkdownNotWomen},function(){if(null!=moviesCollection[0]){var e=[];moviesCollection.map(function(t,o){e.push(React.createElement("div",{key:o},React.createElement("h1",null,t.heading),React.createElement(Table,{movies:t.movies})))}),ReactDOM.render(React.createElement("div",null,e),document.getElementById("root"))}})},client.send();
|
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),client=new XMLHttpRequest,objectifyMarkdownNotWomen=new marked.Renderer,moviesCollection,movies,cellCounter=0,lastHeading="",headers=["movie","genre","year","rating"],parseNowt=function(e,t){return e},parseTheImdb=function(e,t){if(null!=e)return e.replace("/10","")},Table=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.movies=e.movies,o.columns=[],headers.map(function(e,t){var n=0==t,r="rating"==e;o.columns.push(React.createElement(TableHeaderColumn,{key:t,isKey:n,dataFormat:r?parseTheImdb:parseNowt,dataField:e,dataSort:!0},e))}),o}return _inherits(t,e),_createClass(t,[{key:"render",value:function(){return React.createElement(BootstrapTable,{data:this.movies,hover:!0},this.columns)}}]),t}(React.Component);objectifyMarkdownNotWomen.heading=function(e,t){lastHeading=e},objectifyMarkdownNotWomen.tablerow=function(e){cellCounter=0,movies.push({})},objectifyMarkdownNotWomen.tablecell=function(e,t){movies[movies.length-1][headers[cellCounter]]=e,cellCounter++},objectifyMarkdownNotWomen.table=function(e,t){movies[0][headers[0]].toLowerCase()==headers[0]&&movies.splice(0,1),null==movies[movies.length-1][headers[0]]&&movies.pop(),moviesCollection.push({heading:lastHeading,movies:movies}),movies=[{}]},client.open("GET",window.location.href+"README.md"),client.onreadystatechange=function(e){document.getElementById("root").innerHTML="",moviesCollection=[],movies=[{}],marked(client.responseText,{renderer:objectifyMarkdownNotWomen},function(){if(null!=moviesCollection[0]){console.log(moviesCollection);var e=[];moviesCollection.map(function(t,o){e.push(React.createElement("div",{key:o},React.createElement("h2",null,t.heading),React.createElement(Table,{movies:t.movies})))}),ReactDOM.render(React.createElement("div",null,React.createElement("h1",null,"Movies For Hackers"),e),document.getElementById("root"))}})},client.send();
|
@ -13,6 +13,16 @@ var client = new XMLHttpRequest(),
|
|||||||
* React Table Component
|
* React Table Component
|
||||||
* Using https://github.com/AllenFang/react-bootstrap-table
|
* Using https://github.com/AllenFang/react-bootstrap-table
|
||||||
*/
|
*/
|
||||||
|
const parseNowt = (cell, row) => {
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
const parseTheImdb = (cell, row) => {
|
||||||
|
// Make it like 7.1 rather than 7.1/10, we all know what it's out of.
|
||||||
|
if (cell != null) {
|
||||||
|
return cell.replace('/10', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Table extends React.Component {
|
class Table extends React.Component {
|
||||||
// Runs on init
|
// Runs on init
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -25,9 +35,18 @@ class Table extends React.Component {
|
|||||||
|
|
||||||
// Create table headers (the rest is all handled by the plugin)
|
// Create table headers (the rest is all handled by the plugin)
|
||||||
headers.map((header, i) => {
|
headers.map((header, i) => {
|
||||||
let isFirstItem = (i == 0);
|
let isFirstItem = (i == 0),
|
||||||
|
parseImdb = (header == 'rating')
|
||||||
this.columns.push(
|
this.columns.push(
|
||||||
<TableHeaderColumn key={i} isKey={isFirstItem} dataField={header} dataSort={true}>{header}</TableHeaderColumn>
|
<TableHeaderColumn
|
||||||
|
key={i}
|
||||||
|
isKey={isFirstItem}
|
||||||
|
dataFormat={parseImdb ? parseTheImdb : parseNowt}
|
||||||
|
dataField={header}
|
||||||
|
dataSort={true}
|
||||||
|
>
|
||||||
|
{header}
|
||||||
|
</TableHeaderColumn>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -35,7 +54,10 @@ class Table extends React.Component {
|
|||||||
// Runs on render
|
// Runs on render
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<BootstrapTable data={this.movies} hover={true}>
|
<BootstrapTable
|
||||||
|
data={this.movies}
|
||||||
|
hover={true}
|
||||||
|
>
|
||||||
{this.columns}
|
{this.columns}
|
||||||
</BootstrapTable>
|
</BootstrapTable>
|
||||||
);
|
);
|
||||||
@ -80,7 +102,8 @@ objectifyMarkdownNotWomen.table = function(header, body) {
|
|||||||
// Ajax the markdown file with all movie data
|
// Ajax the markdown file with all movie data
|
||||||
client.open('GET', window.location.href + 'README.md');
|
client.open('GET', window.location.href + 'README.md');
|
||||||
client.onreadystatechange = function(e) {
|
client.onreadystatechange = function(e) {
|
||||||
// Wipe movies and collections as this'll run a bunch of times
|
// Wipe movies, collections and content as this'll run a bunch of times
|
||||||
|
document.getElementById("root").innerHTML = '';
|
||||||
moviesCollection = [];
|
moviesCollection = [];
|
||||||
movies = [{}];
|
movies = [{}];
|
||||||
|
|
||||||
@ -95,7 +118,7 @@ client.onreadystatechange = function(e) {
|
|||||||
if (moviesCollection[0] == null) {
|
if (moviesCollection[0] == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//console.log(moviesCollection);
|
console.log(moviesCollection);
|
||||||
//document.body.innerHTML = JSON.stringify(moviesCollection);
|
//document.body.innerHTML = JSON.stringify(moviesCollection);
|
||||||
|
|
||||||
// Create JSX for tables of each set of movies in moviesCollection
|
// Create JSX for tables of each set of movies in moviesCollection
|
||||||
@ -103,7 +126,7 @@ client.onreadystatechange = function(e) {
|
|||||||
moviesCollection.map((movies, i) => {
|
moviesCollection.map((movies, i) => {
|
||||||
moviesCollectionJSX.push(
|
moviesCollectionJSX.push(
|
||||||
<div key={i}>
|
<div key={i}>
|
||||||
<h1>{movies.heading}</h1>
|
<h2>{movies.heading}</h2>
|
||||||
<Table movies={movies.movies} />
|
<Table movies={movies.movies} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@ -111,6 +134,7 @@ client.onreadystatechange = function(e) {
|
|||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<div>
|
<div>
|
||||||
|
<h1>Movies For Hackers</h1>
|
||||||
{moviesCollectionJSX}
|
{moviesCollectionJSX}
|
||||||
</div>,
|
</div>,
|
||||||
document.getElementById("root")
|
document.getElementById("root")
|
||||||
|
@ -1,6 +1,28 @@
|
|||||||
.container-fluid {
|
.container-fluid {
|
||||||
max-width: 1440px;
|
max-width: 1440px;
|
||||||
}
|
}
|
||||||
|
h2 {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
th {
|
th {
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
|
background: #eef7fd;
|
||||||
|
}
|
||||||
|
.react-bs-table {
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 2px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.table {
|
||||||
|
// Cells
|
||||||
|
> thead,
|
||||||
|
> tbody,
|
||||||
|
> tfoot {
|
||||||
|
> tr {
|
||||||
|
> th,
|
||||||
|
> td {
|
||||||
|
padding: 1px 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user