added like feature

tag beginnings
This commit is contained in:
lukas 2020-05-24 16:16:45 +02:00
parent 45d2838fa1
commit eb9a855467
4 changed files with 140 additions and 13 deletions

View File

@ -1,9 +1,27 @@
.myvideo { .myvideo {
width: 80%; width: 100%;
margin-left: 10%;
float: left; float: left;
} }
.videoleftbanner{
float: left;
width: 100%;
height: 100%;
background-color: #e5e5ff;
border-radius: 40px;
}
.likefield{
margin-top: 15px;
margin-left: 15px;
margin-right: 15px;
height: 30px;
background-color: #9e5353;
border-radius: 10px;
text-align: center;
color: white;
}
.previewcontainer { .previewcontainer {
margin-left: 10%; margin-left: 10%;
width: 80%; width: 80%;

View File

@ -7,15 +7,55 @@
<link rel="stylesheet" href="css/index.css"> <link rel="stylesheet" href="css/index.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
<script src="js/plyr.js"></script> <script src="js/plyr.js"></script>
<script src="js/index.js"></script> <script src="js/index.js"></script>
</head> </head>
<body> <body>
<h1>lukis pornhub</h1> <h1>lukis pornhub</h1>
<div class="videopagewrapper hideit"> <div class="videopagewrapper hideit">
<div class="closebutton">Close</div> <div class="row">
<div class="videowrapper"></div> <div class="col-sm-2">
<div class="videoleftbanner">
<div class="likefield">Likes: 10</div>
</div>
</div>
<div class="col-sm-8">
<div class="videowrapper"></div>
</div>
<div class="col-sm-2">
<div class="closebutton">Close</div>
<div class="videorightbanner"></div>
</div>
</div>
<div class="row">
<div class="col-sm-5">
</div>
<div class="col-sm-2">
<button id="likebtn">Like it!</button>
<button id="tagbutton">Like it!</button>
</div>
<div class="col-sm-5">
</div>
</div>
</div> </div>

View File

@ -1,6 +1,7 @@
let videos; let videos;
let loadindex = 0; let loadindex = 0;
let scrollposition = 0; let scrollposition = 0;
let loadedvideoid = -1;
$(document).ready(function () { $(document).ready(function () {
$.post('php/videoload.php', 'action=getMovies', function (data) { $.post('php/videoload.php', 'action=getMovies', function (data) {
@ -13,6 +14,8 @@ $(document).ready(function () {
}, 'json'); }, 'json');
$(".closebutton").click(function () { $(".closebutton").click(function () {
$("#likebtn").off();
$("#tagbutton").off();
$(".videopagewrapper").hide(); $(".videopagewrapper").hide();
$(".previewcontainer").show(); $(".previewcontainer").show();
// scroll back to last scroll position // scroll back to last scroll position
@ -23,7 +26,7 @@ $(document).ready(function () {
$(window).scroll(function () { $(window).scroll(function () {
if ($(window).scrollTop() >= (($(document).height() - $(window).height() - 60))) { if ($(window).scrollTop() >= (($(document).height() - $(window).height() - 60))) {
if ($(".videowrapper").html() == "") { if ($(".videowrapper").html() === "") {
loadPreviewBlock(6); loadPreviewBlock(6);
} }
} }
@ -51,7 +54,8 @@ function loadPreview(src) {
preview.click(function () { preview.click(function () {
console.log("preview clicked"); console.log("preview clicked");
scrollposition = $(window).scrollTop(); scrollposition = $(window).scrollTop();
loadVideo($(this).attr("movie_id")); loadedvideoid = $(this).attr("movie_id");
loadVideo(loadedvideoid);
}); });
$(".previewcontainer").append(preview); $(".previewcontainer").append(preview);
}, 'text'); }, 'text');
@ -73,6 +77,53 @@ function loadVideo(movieid) {
], ],
poster: data.thumbnail poster: data.thumbnail
}; };
$(".likefield").html("Likes: " + data.likes);
$.post('php/videoload.php', 'action=getTags&movieid=' + loadedvideoid, function (data) {
for (const tag in data.tags) {
$(".videoleftbanner").append(`<div>${tag}</div>`);
}
console.log(data);
}, "json");
$("#likebtn").click(function () {
console.log("likebtn clicked");
$.post('php/videoload.php', 'action=addLike&movieid=' + loadedvideoid, function (data) {
console.log(data);
}, "json");
});
$("#tagbutton").click(function () {
console.log("tagbrn clicked");
Swal.mixin({
input: 'text',
confirmButtonText: 'Next &rarr;',
showCancelButton: true,
progressSteps: ['1', '2', '3']
}).queue([
{
title: 'Question 1',
text: 'Chaining swal2 modals is easy'
},
'Question 2',
'Question 3'
]).then((result) => {
if (result.value) {
const answers = JSON.stringify(result.value)
Swal.fire({
title: 'All done!',
html: `
Your answers:
<pre><code>${answers}</code></pre>
`,
confirmButtonText: 'Lovely!'
})
}
})
});
$(".videopagewrapper").show(); $(".videopagewrapper").show();
$(".previewcontainer").hide(); $(".previewcontainer").hide();
}, "json"); }, "json");

View File

@ -18,7 +18,7 @@ if (isset($_POST['action'])) {
echo(json_encode($rows)); echo(json_encode($rows));
break; break;
case "loadVideo": case "loadVideo":
$query = "SELECT movie_url,thumbnail FROM videos WHERE movie_id='" . $_POST['movieid'] . "'"; $query = "SELECT movie_url,thumbnail,likes FROM videos WHERE movie_id='" . $_POST['movieid'] . "'";
$result = $conn->query($query); $result = $conn->query($query);
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
@ -26,6 +26,7 @@ if (isset($_POST['action'])) {
$arr = array(); $arr = array();
$arr["thumbnail"] = $row["thumbnail"]; $arr["thumbnail"] = $row["thumbnail"];
$arr["movie_url"] = $row["movie_url"]; $arr["movie_url"] = $row["movie_url"];
$arr["likes"] = $row["likes"];
echo(json_encode($arr)); echo(json_encode($arr));
break; break;
@ -39,7 +40,6 @@ if (isset($_POST['action'])) {
if ($result->num_rows == 1) { if ($result->num_rows == 1) {
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
echo '{"data":"' . $row["Size"] . 'MB"}'; echo '{"data":"' . $row["Size"] . 'MB"}';
} }
@ -55,14 +55,32 @@ if (isset($_POST['action'])) {
break; break;
case "getTags": case "getTags":
$query = "SELECT * FROM video_tags INNER JOIN tags t on video_tags.tag_id = t.tag_id WHERE video_id='" . $_POST['movieid'] . "'"; $movieid = $_POST['movieid'];
#$query = "SELECT thumbnail FROM videos WHERE movie_id='" . $_POST['movieid'] . "'";
$query = "SELECT tag_name FROM video_tags
INNER JOIN tags t on video_tags.tag_id = t.tag_id
WHERE video_id='$movieid'";
$result = $conn->query($query); $result = $conn->query($query);
$row = $result->fetch_assoc();
echo($row["thumbnail"]); $rows = array();
$rows['tags'] = array();
while ($r = mysqli_fetch_assoc($result)) {
array_push($rows['tags'], $r['tag_name']);
}
echo(json_encode($rows));
break;
case "addLike":
$movieid = $_POST['movieid'];
$query = "update videos set likes = likes + 1 where movie_id = '$movieid'";
if ($conn->query($query) === TRUE) {
echo('{"result":"success"}');
} else {
echo('{"result":"' . $conn->error . '"}');
}
break; break;
} }
} else { } else {