<!DOCTYPE html>
<html lang="ko">
<head>
<title>SaveBox | Scrappers </title>
<meta property="og:title" content="Scrappers"/>
<meta property="og:description" content="์ค์๊ฐ ๋ด์ค ๋ญํน ํ์ธ & ์ ์ฅ"/>
<meta property="og:image" content="{{ url_for('static', filename='ogimg.png') }}"/>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<!-- JS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<!-- ๊ตฌ๊ธํฐํธ -->
<link href="https://fonts.googleapis.com/css?family=Stylish&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Black+Han+Sans&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Sunflower:wght@300&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif+KR&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@500&display=swap" rel="stylesheet">
<style>
:root {
--color-black: black;
--color-white: white;
--font-large: 48px;
--font-medium: 24px;
--font-kind: Black Han Sans, sans-serif;
}
/* navbar */
@media screen and (max-width: 700px) {
nav {
width: 700px;
}
div.card {
width: 670px;
display: inline-block;
margin: 15px 15px 15px 15px;
}
div.center {
width:680px;
display:block;
text-align:center;
}
img.card-img-top{
width:670px;
height:400px;
}
}
nav {
background-color:black;
padding: 40px 40px;
color: var(--color-white);
font-size: var(--font-large);
font-weight: bold;
display: flex;
flex-direction: column;
align-items: center;
}
nav ul {
width: 200px;
padding: 0;
margin-bottom: 0;
font-weight: normal;
}
nav li {
list-style: none;
font-size: var(--font-medium);
}
nav a {
color: white;
padding: 5px;
margin: 0px 10px 0px 10px;
}
nav a:hover {
cursor: pointer;
color: black;
background: white;
border-radius: 4px;
text-decoration: none;
transform: scale(1.1);
transition: transform 200ms ease-in-out ;
}
.navbar_list {
display: flex;
flex-direction: row;
justify-content: space-evenly;
}
/* home */
.home {
padding: 100px 20px;
text-align: center;
}
.logo img {
width: 100px;
height: 100px;
color: white;
}
.logo_Btn {
border: none;
background: none;
outline: none;
}
.logo_Btn:hover {
transform: translateY(6px) rotate(0.8turn);
transition: all 500ms ease-in-out;
}
.logo_Btn:active {
transform: scale(1.1);
}
.logo_Btn:focus {
outline: 0;
}
/*.col-sm-6 col-md-4 {*/
/* width: 100%;*/
/*}*/
/*@media screen and (max-width: 768px) {*/
/* nav {*/
/* }*/
.warp {
margin:auto;
}
.card {
width: 600px;
display:inline-block;
margin:15px;
}
.card-box {
align-items: center;
}
.center {
margin-top:10px;
display:block;
text-align:center;
}
.card-img-top{
width:600px;
height:400px;
}
</style>
</head>
<body>
<!-- HTML body structuring -->
<!-- logo(?) & title & category (Home, Category, and Saved)-->
<div class="warp">
<nav id="navbar" style="font-family:'Black Han Sans'">Scrappers
<div class="logo">
<button class="logo_Btn" onclick="reload09()"><span style="font-size: 80px;">๐ซ</span></button>
</div>
<!-- ํ์ฌ ๋ ์ง ์๊ฐ ํ๊ธฐํด์ ์
ํ
์ดํธ ์๊ฐ ์๋ ค์ฃผ๊ธฐ -->
<p id="datetime"></p>
<ul class="navbar_list">
<a href="{{ url_for('home') }}">
<li>Home</li>
</a>
<a href="{{ url_for('saveBox') }}">
<li>Saved</li>
</a>
</ul>
</nav>
</div>
<!--style="outline:none; background:none; border:none; color:pink;"-->
<div class="center">
<button class="btn btn-info" onclick="sort_recent()" style="font-family:'Stylish'">Recent</button>
<button class="btn btn-info" onclick="sort_Review()">๐ฌ</button>
<button class="btn btn-info" onclick="sort_like()">๐ฅ</button>
</div>
<div class="card-box" id="save-box" style=''> </div>
<script>
function reload09() {
window.location.reload()
}
$(document).ready(function () {
showArticles(), readReview()
});
function showArticles() {
$.ajax({
type: "GET",
url: "/showSaveNews",
data: {},
success: function (response) {
let list = response['list_saveBox']
for (let i = 0; i < list.length; i++) {
let title = list[i]['title']
let img = list[i]['img']
let url = list[i]['url']
let newspaper = list[i]['newspaper']
let like_counts = list[i]['like_counts']
let review_counts = list[i]['review_counts']
let temp_html = `
<div class="card" style="">
<img class="card-img-top"
src="${img}"
alt="Card image cap">
<div class="card-body">
<a target="_blank" href="${url}" class="card-title" style="font-family: 'Noto Serif KR', serif; font-size:20px;">${title}</a>
<p style="font-family:'Black Han Sans'; color:lightslategrey; font-size:20px;">${newspaper}</p>
<div class="input-group mb-3">
<input type="text" id="${url}_input" class="form-control" placeholder="..." aria-label="Recipient's username" aria-describedby="button-addon2">
<button style="width:60px;" type="button" class="btn btn-dark" onclick="makeReview('${url}')"><span style="font-family:'Black Han Sans'">์์ฑ</span></button>
<button type="button" id="${url}_save" style="border:none; outline:none; background:none; font-size:25px;" onclick="readReview('${url}')" style="width:60px;">๐ฌ<span style = "color:#7986cb;"><b>${review_counts}</b></span></button>
<button style="border:none; outline:none; background:none; font-size:25px;" onclick="incrementLikes('${url}')">๐ฅ <b><span style="color:#f50057;">${like_counts}</span></b></button>
</div>
<table class="table">
<thead>
<tr>
<th scope="col" style="font-family:'Noto Serif KR'"><b>comment</b></th>
</tr>
<tbody id="${url}_comment" class="9999">
</tbody>
</thead>
</table>
`
$('#save-box').append(temp_html)
}
}
})
}
function sort_like() {
$.ajax({
type: 'GET',
url: '/showSaveNews/like_sort',
data: {},
success: function (response) {
$('#save-box').html("");
let list = response['list_saveBox']
for (let i = 0; i < list.length; i++) {
let title = list[i]['title']
let img = list[i]['img']
let url = list[i]['url']
let newspaper = list[i]['newspaper']
let like_counts = list[i]['like_counts']
let review_counts = list[i]['review_counts']
let temp_html = `
<div class="card" style="">
<img class="card-img-top"
src="${img}"
alt="Card image cap">
<div class="card-body">
<a target="_blank" href="${url}" class="card-title" style="font-family: 'Noto Serif KR', serif; font-size:20px;">${title}</a>
<p style="font-family:'Black Han Sans'; color:lightslategrey; font-size:20px;">${newspaper}</p>
<div class="input-group mb-3">
<input type="text" id="${url}_input" class="form-control" placeholder="..." aria-label="Recipient's username" aria-describedby="button-addon2">
<button style="width:60px;" type="button" class="btn btn-dark" onclick="makeReview('${url}')"><span style="font-family:'Black Han Sans'">์์ฑ</span></button>
<button type="button" id="${url}_save" style="border:none; outline:none; background:none; font-size:25px;" onclick="readReview('${url}')" style="width:60px;">๐ฌ<span style = "color:#7986cb;"><b>${review_counts}</b></span></button>
<button style="border:none; outline:none; background:none; font-size:25px;" onclick="incrementLikes('${url}')">๐ฅ <b><span style="color:#f50057;">${like_counts}</span></b></button>
</div>
<table class="table">
<thead>
<tr>
<th scope="col" style="font-family:'Noto Serif KR'"><b>comment</b></th>
</tr>
<tbody id="${url}_comment" onload="readReview('${url}')" class="9999">
</tbody>
</thead>
</table>
`
$('#save-box').append(temp_html)
}
}
});
}
function sort_recent() {
$.ajax({
type: "GET",
url: "/showSaveNews/recent",
data: {},
success: function (response) {
$('#save-box').html("");
let list = response['list_saveBox']
for (let i = list.length-1; i >= 0; i--) {
let title = list[i]['title']
let img = list[i]['img']
let url = list[i]['url']
let newspaper = list[i]['newspaper']
let like_counts = list[i]['like_counts']
let review_counts = list[i]['review_counts']
let temp_html = `
<div class="card" style="">
<img class="card-img-top"
src="${img}"
alt="Card image cap">
<div class="card-body">
<a target="_blank" href="${url}" class="card-title" style="font-family: 'Noto Serif KR', serif; font-size:20px;">${title}</a>
<p style="font-family:'Black Han Sans'; color:lightslategrey; font-size:20px;">${newspaper}</p>
<div class="input-group mb-3">
<input type="text" id="${url}_input" class="form-control" placeholder="..." aria-label="Recipient's username" aria-describedby="button-addon2">
<button style="width:60px;" type="button" class="btn btn-dark" onclick="makeReview('${url}')"><span style="font-family:'Black Han Sans'">์์ฑ</span></button>
<button type="button" id="${url}_save" style="border:none; outline:none; background:none; font-size:25px;" onclick="readReview('${url}')" style="width:60px;">๐ฌ<span style = "color:#7986cb;"><b>${review_counts}</b></span></button>
<button style="border:none; outline:none; background:none; font-size:25px;" onclick="incrementLikes('${url}')">๐ฅ <b><span style="color:#f50057;">${like_counts}</span></b></button>
</div>
<table class="table">
<thead>
<tr>
<th scope="col" style="font-family:'Noto Serif KR'"><b>comment</b></th>
</tr>
<tbody id="${url}_comment" onload="readReview('${url}')" class="9999">
</tbody>
</thead>
</table>
`
$('#save-box').append(temp_html)
}
}
})
}
function sort_Review() {
$.ajax({
type: "GET",
url: "/showSaveNews/review",
data: {},
success: function (response) {
$('#save-box').html("");
let list = response['list_saveBox']
for (let i = list.length-1; i >= 0; i--) {
let title = list[i]['title']
let img = list[i]['img']
let url = list[i]['url']
let newspaper = list[i]['newspaper']
let like_counts = list[i]['like_counts']
let review_counts = list[i]['review_counts']
let temp_html = `
<div class="card" style="">
<img class="card-img-top"
src="${img}"
alt="Card image cap">
<div class="card-body">
<a target="_blank" href="${url}" class="card-title" style="font-family: 'Noto Serif KR', serif; font-size:20px;">${title}</a>
<p style="font-family:'Black Han Sans'; color:lightslategrey; font-size:20px;">${newspaper}</p>
<div class="input-group mb-3">
<input type="text" id="${url}_input" class="form-control" placeholder="..." aria-label="Recipient's username" aria-describedby="button-addon2">
<button style="width:60px;" type="button" class="btn btn-dark" onclick="makeReview('${url}')"><span style="font-family:'Black Han Sans'">์์ฑ</span></button>
<button type="button" id="${url}_save" style="border:none; outline:none; background:none; font-size:25px;" onclick="readReview('${url}')" style="width:60px;">๐ฌ<span style = "color:#7986cb;"><b>${review_counts}</b></span></button>
<button style="border:none; outline:none; background:none; font-size:25px;" onclick="incrementLikes('${url}')">๐ฅ <b><span style="color:#f50057;">${like_counts}</span></b></button>
</div>
<table class="table">
<thead>
<tr>
<th scope="col" style="font-family:'Noto Serif KR'"><b>comment</b></th>
</tr>
<tbody id="${url}_comment" onload="readReview('${url}')" class="9999">
</tbody>
</thead>
</table>
`
$('#save-box').append(temp_html)
}
}
})
}
function incrementLikes(url) {
$.ajax({
type: 'POST',
url: '/showSaveNews/like',
data: {url_give: url},
success: function (response) {
alert(response['msg']);
window.location.reload();
}
});
}
function makeReview(url) {
let temp = document.getElementById(url + "_input")
// let temp3 = document.getElementById(url)
// url์ ๊ทธ๋ฅ url๋ก ํด์ ๋์ด๊ฐ
let comment = $(temp).val()
if (comment == '') {
console.log('๋๊ธ ๋ฏธ์์ฑ')
} else {
// ์ธํ๋ฐ์ค๋ ์ด๋ ๊ฒ val() ํด์ผ ๊ฐ์ ๊ฐ์ง๊ณ ์ด
$.ajax({
type: "POST",
url: "/review",
data: {
review_give: comment,
url_give: url,
},
// ์ง๊ธ ํ์ด์ฌ์ผ๋ก ๋ณด๋ด๋ ๊ฐ๋ค.
success: function (response) {
console.log(comment)
alert(response["msg"]);
window.location.reload();
}
})
}
}
// ๋๊ธ์ฐฝ ํ์ธ
function readReview(url) {
console.log(url)
// let save = document.getElementById(url + "_save")
// $(url).trigger("click");
$.ajax({
type: 'POST',
url: '/reviews',
data: {
url_give: url,
},
success: function (response) {
let reviewsBox = document.getElementById(url + "_comment")
let reviews = response['all_reviews']
for (let i = 0; i < reviews.length; i++) {
let showReview = reviews[i]['review']
let temp_html = `
<tr>
<td style="font-family:'Noto Serif KR'">${showReview}</td>
</tr>
`
$(reviewsBox).append(temp_html)}
document.getElementById(url + "_save").disabled = true;
}
})
}
</script>
</section>
</body>
</html>
Front/Html & Css