diff --git a/src/app/feed-page.js b/src/app/feed-page.js
index 8a11b42..7475a2a 100644
--- a/src/app/feed-page.js
+++ b/src/app/feed-page.js
@@ -1,10 +1,6 @@
import React from 'react';
import Page from './page';
-import SearchResults from './search-results'
-import Search from './search'
-import SelectField from 'material-ui/SelectField';
-import MenuItem from 'material-ui/MenuItem';
import Feed from './feed';
export default class FeedPage extends Page {
@@ -12,81 +8,9 @@ export default class FeedPage extends Page {
super(props)
this.setTitle('Rats On The Boat - Content Search Engine');
}
- componentDidMount()
- {
- Search.instance().onSearchUpdate = () => this.forceUpdate()
- }
- componentWillUnmount()
- {
- Search.instance().onSearchUpdate = () => {}
- }
render() {
- const orderText = (text, field) => {
- if(field !== Search.instance().state.orderBy)
- return text;
-
- if(Search.instance().state.orderDesc)
- return text + ' ⇩'
- else
- return text + ' ⇧'
- }
-
return (
-
- {
- event.preventDefault(); // fix overclick on torrent
- if(value === 'none') {
- Search.instance().setState({orderBy: null}, () => {
- Search.instance().search(true)
- })
- return;
- }
-
- if(value === Search.instance().state.orderBy)
- {
- Search.instance().setState({orderDesc: !Search.instance().state.orderDesc}, () => {
- Search.instance().search(true)
- })
- return;
- }
-
- Search.instance().setState({
- orderBy: value,
- orderDesc: (value === 'seeders' || value === 'completed' || value === 'added') ? true : Search.instance().state.orderDesc
- }, () => {
- Search.instance().search(true)
- })
- }}
- >
-
-
-
-
-
-
-
-
- }
-
- moreTorrentsEnabled={Search.instance().moreSearchTorrents && !Search.instance().state.searchingIndicator}
- moreFilesEnabled={Search.instance().moreSearchFiles && !Search.instance().state.searchingIndicator}
- onMoreTorrents={() => Search.instance().moreTorrents()}
- onMoreFiles={() => Search.instance().moreFiles()}
- moreTorrentsIndicator={Search.instance().state.moreTorrentsIndicator}
- moreFilesIndicator={Search.instance().state.moreFilesIndicator}
- />
-
diff --git a/src/app/router.js b/src/app/router.js
index 023e0c1..d3eecc2 100644
--- a/src/app/router.js
+++ b/src/app/router.js
@@ -2,6 +2,7 @@
import PagesPie from './pages-pie.js';
import FeedPage from './feed-page.js'
+import SearchPage from './search-page.js'
import ActivityPage from './activity-page'
import TorrentPage from './torrent-page.js'
import DMCAPage from './dmca-page.js'
@@ -11,10 +12,18 @@ import DownloadPage from './download-page.js'
import ChangelogPage from './changelog-page.js'
import FiltersPage from './filters-page.js'
+const history = []
+let currentPage
+
let routers = {}
const router = (page, callback) => {
if(!callback)
{
+ currentPage = page ? page : '/'
+ if(history.length >= 10)
+ history.shift()
+ history.push(currentPage)
+
if(!page)
routers['/'].callback()
else
@@ -52,12 +61,34 @@ const router = (page, callback) => {
window.router = router;
+window.routerOpenPrev = () => {
+ console.log(history)
+ if(history.length < 2)
+ return
+ history.pop() // last page
+ router(history.pop())
+}
+
+window.routerFix = () => {
+ if(history.length >= 10)
+ history.shift()
+ history.push(currentPage)
+ currentPage = ''
+}
+
+window.routerCurrent = () => currentPage
router('/', () => {
//singleton
PagesPie.instance().open(FeedPage, {replace: 'all'});
});
+router('/search', () => {
+ //singleton
+ PagesPie.instance().open(SearchPage, {replace: 'all'});
+});
+
+
router('/torrent/:hash', (e) => {
//singleton
PagesPie.instance().open(TorrentPage, {
diff --git a/src/app/search-page.js b/src/app/search-page.js
new file mode 100644
index 0000000..a70627c
--- /dev/null
+++ b/src/app/search-page.js
@@ -0,0 +1,92 @@
+import React from 'react';
+import Page from './page';
+
+import SearchResults from './search-results'
+import Search from './search'
+import SelectField from 'material-ui/SelectField';
+import MenuItem from 'material-ui/MenuItem';
+
+export default class SearchPage extends Page {
+ constructor(props) {
+ super(props)
+ this.setTitle('Rats On The Boat - Content Search Engine');
+ }
+ componentDidMount()
+ {
+ Search.instance().onSearchUpdate = () => this.forceUpdate()
+ }
+ componentWillUnmount()
+ {
+ Search.instance().onSearchUpdate = () => {}
+ }
+ render() {
+ const orderText = (text, field) => {
+ if(field !== Search.instance().state.orderBy)
+ return text;
+
+ if(Search.instance().state.orderDesc)
+ return text + ' ⇩'
+ else
+ return text + ' ⇧'
+ }
+
+ return (
+
+
+ {
+ event.preventDefault(); // fix overclick on torrent
+ if(value === 'none') {
+ Search.instance().setState({orderBy: null}, () => {
+ Search.instance().search(true)
+ })
+ return;
+ }
+
+ if(value === Search.instance().state.orderBy)
+ {
+ Search.instance().setState({orderDesc: !Search.instance().state.orderDesc}, () => {
+ Search.instance().search(true)
+ })
+ return;
+ }
+
+ Search.instance().setState({
+ orderBy: value,
+ orderDesc: (value === 'seeders' || value === 'completed' || value === 'added') ? true : Search.instance().state.orderDesc
+ }, () => {
+ Search.instance().search(true)
+ })
+ }}
+ >
+
+
+
+
+
+
+
+
+ }
+
+ moreTorrentsEnabled={Search.instance().moreSearchTorrents && !Search.instance().state.searchingIndicator}
+ moreFilesEnabled={Search.instance().moreSearchFiles && !Search.instance().state.searchingIndicator}
+ onMoreTorrents={() => Search.instance().moreTorrents()}
+ onMoreFiles={() => Search.instance().moreFiles()}
+ moreTorrentsIndicator={Search.instance().state.moreTorrentsIndicator}
+ moreFilesIndicator={Search.instance().state.moreFilesIndicator}
+ />
+
+
+ );
+ }
+}
diff --git a/src/app/search.js b/src/app/search.js
index c672a6e..bb25c76 100644
--- a/src/app/search.js
+++ b/src/app/search.js
@@ -38,7 +38,7 @@ class Search extends Component {
}
search(oldSearch) {
- window.router('/')
+ window.router('/search')
this.setState({
searchingIndicator: true
});
@@ -257,6 +257,27 @@ class Search extends Component {
return (
+ {
+ ((this.searchTorrents && this.searchTorrents.length > 0) || (this.searchFiles && this.searchFiles.length > 0))
+ &&
+
+
+
+
+
+
+ }
+ iconStyle={{fill: '#27ce74'}}
+ onCheck={() => {
+ if(window.routerCurrent() !== '/search')
+ window.router('/search')
+ }}
+ style={{paddingTop: '0.6em', paddingLeft: '0.2em'}}
+ />
+
+ }
{
if(value == 'main') {
- window.router('/');
+ window.routerOpenPrev();
return;
}
@@ -338,7 +338,7 @@ export default class TorrentPage extends Page {
value={this.state.value}
onChange={this.handleChange}
>
-
+
diff --git a/src/app/torrent.js b/src/app/torrent.js
index dcdd9aa..ef67b9a 100644
--- a/src/app/torrent.js
+++ b/src/app/torrent.js
@@ -238,7 +238,7 @@ export default class Torrent extends Component {
return true;
}
*/
-
+ window.routerFix()
PagesPie.instance().open(TorrentPage, {replace: 'all', hash: torrent.hash, peer: torrent.peer})
}}
primaryText={