Skip to content

Commit

Permalink
filter on TagPage
Browse files Browse the repository at this point in the history
  • Loading branch information
hjyssg committed Feb 24, 2019
1 parent b3d0ca9 commit 05cb1f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/client/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class App extends Component {

const renderExplorer = (props) => { return (<ExplorerPage {...props} filterText={this.filterText} cookies={cookies} />)};

const renderTagPage = (props) => { return (<TagPage mode="tag" {...props} cookies={cookies}/>)};
const renderAuthorPage = (props) => { return (<TagPage mode="author" {...props} cookies={cookies}/>)};
const renderTagPage = (props) => { return (<TagPage mode="tag" filterText={this.filterText} {...props} cookies={cookies}/>)};
const renderAuthorPage = (props) => { return (<TagPage mode="author" filterText={this.filterText} {...props} cookies={cookies}/>)};

const result = (
<Switch>
Expand Down Expand Up @@ -73,7 +73,9 @@ class App extends Component {
}

const isOneBook = window.location.pathname.includes("/onebook");
const isExplorer = window.location.pathname.includes("/explorer")
const isExplorer = window.location.pathname.includes("/explorer");
const isTag = window.location.pathname.includes("/tagPage");
const isAuthor = window.location.pathname.includes("/author");

const topNav = !isOneBook && (
<div className="topnav container">
Expand All @@ -85,7 +87,7 @@ class App extends Component {
<div className="search-bar">
<input className="search-input" type="text" placeholder="Search.."/>
<button onClick={this.onSearchClick.bind(this)} title="Search"><i className="fa fa-search"></i></button>
{isExplorer && <button onClick={this.onFilterClick.bind(this)} title="Filter Files"><i className="fa fa-filter"></i></button>}
{(isExplorer || isTag || isAuthor) && <button onClick={this.onFilterClick.bind(this)} title="Filter Files"><i className="fa fa-filter"></i></button>}
</div>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/client/OneBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ export default class OneBook extends Component {

handleKeyDown(event) {
const key = event.key.toLowerCase();
if (key === "arrowright" || key === "d") {
if (key === "arrowright" || key === "d" || key === "l") {
this.changePage(this.state.index + 1);
} else if (key === "arrowleft" || key === "a") {
} else if (key === "arrowleft" || key === "a" || key === "j") {
this.changePage(this.state.index - 1);
}else if(key === "enter"){
this.toggleFullScreen();
Expand Down
12 changes: 12 additions & 0 deletions src/client/TagPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ export default class TagPage extends Component {
keys.sort((a, b) => items[b] - items[a]);
}

// if(this.props.mode === "tag"){
//pick comiket in first page

var filterText = this.props.filterText && this.props.filterText.toLowerCase();
if(filterText){
keys = keys.filter(e => {
return e.toLowerCase().indexOf(filterText) > -1;
});
keys.sort((a, b) => a.localeCompare(b));
}

keys = keys.slice((this.pageIndex-1) * this.perPage, this.pageIndex * this.perPage);

const tagItems = keys.map((tag) => {
Expand Down Expand Up @@ -154,4 +165,5 @@ TagPage.propTypes = {

TagPage.propTypes = {
openDirFunc: PropTypes.func,
filterText: PropTypes.string
};

0 comments on commit 05cb1f1

Please sign in to comment.