diff --git a/src/App.js b/src/App.js
index 646e589..4beed12 100644
--- a/src/App.js
+++ b/src/App.js
@@ -14,29 +14,38 @@ class App extends React.Component {
this.state = {page: "default"};
// bind this to the method for being able to call methods such as this.setstate
- this.showVideo = this.showVideo.bind(this);
- this.hideVideo = this.hideVideo.bind(this);
+ this.changeRootElement = this.changeRootElement.bind(this);
+ this.returnToLastElement = this.returnToLastElement.bind(this);
}
- videoelement = null;
+ newElement = null;
MainBody() {
let page;
if (this.state.page === "default") {
- page = ;
+ page = ;
this.mypage = page;
} else if (this.state.page === "random") {
- page = ;
+ page = ;
this.mypage = page;
} else if (this.state.page === "settings") {
page = ;
this.mypage = page;
} else if (this.state.page === "categories") {
- page = ;
+ page = ;
this.mypage = page;
} else if (this.state.page === "video") {
// show videoelement if neccessary
- page = this.videoelement;
+ page = this.newElement;
console.log(page);
} else if (this.state.page === "lastpage") {
@@ -86,19 +95,18 @@ class App extends React.Component {
);
}
- showVideo(element) {
- this.videoelement = element;
+ changeRootElement(element) {
+ this.newElement = element;
this.setState({
page: "video"
});
}
- hideVideo() {
+ returnToLastElement() {
this.setState({
page: "lastpage"
});
- this.element = null;
}
}
diff --git a/src/App.test.js b/src/App.test.js
index e2a7b33..a4bbdb1 100644
--- a/src/App.test.js
+++ b/src/App.test.js
@@ -21,7 +21,7 @@ describe('', function () {
it('simulate video view change ', function () {
const wrapper = shallow();
- wrapper.instance().showVideo(
);
+ wrapper.instance().changeRootElement();
expect(wrapper.find("#testit")).toHaveLength(1);
});
@@ -29,11 +29,11 @@ describe('', function () {
it('test hide video again', function () {
const wrapper = shallow();
- wrapper.instance().showVideo();
+ wrapper.instance().changeRootElement();
expect(wrapper.find("#testit")).toHaveLength(1);
- wrapper.instance().hideVideo();
+ wrapper.instance().returnToLastElement();
expect(wrapper.find("HomePage")).toHaveLength(1);
});
@@ -43,11 +43,11 @@ describe('', function () {
wrapper.find(".nav-link").findWhere(t => t.text() === "Random Video" && t.type() === "div").simulate("click");
- wrapper.instance().showVideo();
+ wrapper.instance().changeRootElement();
expect(wrapper.find("#testit")).toHaveLength(1);
- wrapper.instance().hideVideo();
+ wrapper.instance().returnToLastElement();
expect(wrapper.find("RandomPage")).toHaveLength(1);
});
diff --git a/src/elements/PageTitle/PageTitle.test.js b/src/elements/PageTitle/PageTitle.test.js
index 47b0a80..5d57908 100644
--- a/src/elements/PageTitle/PageTitle.test.js
+++ b/src/elements/PageTitle/PageTitle.test.js
@@ -13,7 +13,7 @@ describe('', function () {
const wrapper = shallow(heyimachild);
const children = wrapper.children();
- expect(children.at(children.length-2).text()).toBe("heyimachild");
+ expect(children.at(children.length - 2).text()).toBe("heyimachild");
});
it('renders pagetitle prop', function () {
diff --git a/src/elements/Preview/Preview.js b/src/elements/Preview/Preview.js
index 77cbf4e..ea016db 100644
--- a/src/elements/Preview/Preview.js
+++ b/src/elements/Preview/Preview.js
@@ -60,9 +60,10 @@ class Preview extends React.Component {
itemClick() {
console.log("item clicked!" + this.state.name);
- this.props.viewbinding.showVideo();
+ this.props.viewbinding.changeRootElement(
+ );
}
}
diff --git a/src/elements/Tag/Tag.js b/src/elements/Tag/Tag.js
index 40e3ffb..b853838 100644
--- a/src/elements/Tag/Tag.js
+++ b/src/elements/Tag/Tag.js
@@ -1,6 +1,7 @@
import React from "react";
import "./Tag.css"
+import VideoContainer from "../VideoContainer/VideoContainer";
class Tag extends React.Component {
constructor(props, context) {
@@ -10,12 +11,33 @@ class Tag extends React.Component {
}
render() {
- // todo onclick events correctlyy
return (
-
);
}
+
+ TagClick() {
+ const tag = this.props.children.toString().toLowerCase();
+
+ const updateRequest = new FormData();
+ updateRequest.append('action', 'getMovies');
+ updateRequest.append('tag', tag);
+
+ // fetch all videos available
+ fetch('/api/videoload.php', {method: 'POST', body: updateRequest})
+ .then((response) => response.json()
+ .then((result) => {
+ this.props.contentbinding(
+ , tag
+ );
+ }))
+ .catch(() => {
+ console.log("no connection to backend");
+ });
+ }
}
export default Tag;
diff --git a/src/pages/CategoryPage/CategoryPage.js b/src/pages/CategoryPage/CategoryPage.js
index c584295..ef6c2da 100644
--- a/src/pages/CategoryPage/CategoryPage.js
+++ b/src/pages/CategoryPage/CategoryPage.js
@@ -31,10 +31,10 @@ class CategoryPage extends React.Component {
Default Tags:
- All
- FullHd
- LowQuality
- HD
+ All
+ FullHd
+ LowQuality
+ HD