이찬

0616 update

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
\ No newline at end of file
......@@ -43,39 +43,16 @@ const connection = mysql.createConnection({
connection.connect();
let DBdata = [];
function addZeroMonth(date) {
if ((date.getMonth() + 1) < 10) return `0${date.getMonth() + 1}`;
else return `${date.getMonth() + 1}`;
}
function addZeroDate(date) {
if (date.getDate() < 10) return `0${date.getDate()}`;
else return `${date.getDate()}`;
async function DBUpdate() {
await connection.query(
`INSERT INTO visiter VALUES (${date.getFullYear()}, ${date.getMonth()},${date.getDate()}, ${count});`
);
count = await 0;
}
var date = new Date();
function server_time() {
date.setSeconds(date.getSeconds() + 1);
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
if (hours < 10) {
hours = "0" + hours;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
console.log(hours + ":" + minutes + ":" + seconds);
}
app.get('/', (req, res) => {
var date = new Date();
var dateString = `${date.getFullYear()}-${addZeroMonth(date)}-${addZeroDate(date)}`;
var today = date.getYear() + " " + date.getMonth() + " " + date.getDate();
setInterval(() => {
......@@ -83,14 +60,8 @@ app.get('/', (req, res) => {
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
console.log(hours + ":" + minutes + ":" + seconds);
if (hours === 23 && minutes === 59 && seconds === 59) {
//수정해야하는 DB 푸쉬
DBdata.push({
"date": dateString,
"value": count
});
count = 0;
DBUpdate();
}
}, 1000);
console.log(req.session.lastVisit);
......@@ -112,6 +83,7 @@ app.get('/detail.html', (req, res) => {
res.end(data);
});
});
app.get('/api/visiters', (req,res)=>{
connection.query(
'SELECT * FROM visiter',
......@@ -123,7 +95,6 @@ app.get('/api/visiters', (req,res)=>{
app.get('/statistics.html', (req, res) => {
fs.readFile(path.join(__dirname, 'html', 'statistics.html'), (err, data) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(data);
......
import React from 'react'
import { post } from 'axios';
class DateAdd extends React.Component {
constructor(props) {
super(props);
this.state = {
date: '',
numOfVisiters:''
}
this.handleFormSubmit = this.handleFormSubmit.bind(this)
this.handleValueChange = this.handleValueChange.bind(this)
this.addDate = this.addDate.bind(this)
}
handleFormSubmit(e) {
e.preventDefault()
this.addCustomer()
.then((response) => {
console.log(response.data);
})
}
handleValueChange(e) {
let nextState = {};
nextState[e.target.name] = e.target.value;
this.setState(nextState);
}
addDate(){
const url = '/api/visiters';
const formData = new FormData();
formData.append('date', this.state.date)
formData.append('numOfVisiters', this.state.numOfVisiters)
const config = {
headers: {
'content-type': 'multipart/form-data'
}
}
return post(url, formData, config)
}
render() {
return (
<form onSubmit={this.handleFormSubmit}>
<h1> 날짜 추가 </h1>
날짜: <input type="text" name="date" value={this.state.date} onChange={this.handleValueChange} /><br/>
방문자 : <input type="text" name="numOfVisiters" value={this.state.numOfVisiters} onChange={this.handleValueChange} /><br/>
<button type="submit">추가하기</button>
</form>
)
}
}
export default DateAdd
......@@ -10,7 +10,7 @@
gtag('config', 'UA-168785509-1');
</script>
<link rel="shortcut icon" type="image⁄x-icon" href="../favicon.png">
<link rel="shortcut icon" type="image⁄x-icon" href="../img/favicon.png">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="악질 직업 생성기">
......
......@@ -10,7 +10,7 @@
gtag('config', 'UA-168785509-1');
</script>
<link rel="shortcut icon" type="image⁄x-icon" href="../favicon.png">
<link rel="shortcut icon" type="image⁄x-icon" href="../img/favicon.png">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="악질 직업 생성기">
......
......@@ -10,7 +10,7 @@
gtag('config', 'UA-168785509-1');
</script>
<link rel="shortcut icon" type="image⁄x-icon" href="../favicon.png">
<link rel="shortcut icon" type="image⁄x-icon" href="../img/favicon.png">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="악질 직업 생성기">
......@@ -48,11 +48,10 @@
</div>
<div id="supersecret-document">
<div class="container">
<img class="naruto" src="../statistic.png" alt="이거 보여주려고 어그로 끌었다..." style="max-width: 100%; height: auto; display: block; margin-left: auto; margin-right: auto;">
<img class="naruto" src="../img/statistic.png" alt="이거 보여주려고 어그로 끌었다..." style="max-width: 100%; height: auto; display: block; margin-left: auto; margin-right: auto;">
<p style="font-size: 150%;">미안하다 이거 보여주려고 어그로끌었다.. 나루토 사스케 싸움수준 ㄹㅇ실화냐? 진짜 세계관최강자들의 싸움이다.. 그찐따같던 나루토가 맞나? 진짜 나루토는 전설이다..진짜옛날에 맨날나루토봘는데 왕같은존재인 호카게 되서 세계최강 전설적인 영웅이된나루토보면 진짜내가다 감격스럽고 나루토 노래부터 명장면까지 가슴울리는장면들이 뇌리에 스치면서 가슴이 웅장해진다.. 그리고 극장판 에 카카시앞에 운석날라오는 거대한 걸 사스케가 갑자기 순식간에 나타나서 부숴버리곤 개간지나게 나루토가 없다면 마을을 지킬 자는 나밖에 없다 라며 바람처럼 사라진장면은 진짜 나루토처음부터 본사람이면 안울수가없더라 진짜 너무 감격스럽고 보루토를 최근에 알았는데 미안하다.. 지금20화보는데 진짜 나루토세대나와서 너무 감격스럽고 모두어엿하게 큰거보니 내가 다 뭔가 알수없는 추억이라해야되나 그런감정이 이상하게 얽혀있다.. 시노는 말이많아진거같다 좋은선생이고..그리고 보루토왜욕하냐 귀여운데 나루토를보는것같다 성격도 닮았어 그리고버루토에 나루토사스케 둘이싸워도 이기는 신같은존재 나온다는게 사실임?? 그리고인터닛에 쳐봣는디 이거 ㄹㅇㄹㅇ 진짜팩트냐?? 저적이 보루토에 나오는 신급괴물임?ㅡ 나루토사스케 합체한거봐라 진짜 ㅆㅂ 이거보고 개충격먹어가지고 와 소리 저절로 나오더라 ;; 진짜 저건 개오지는데.. 저게 ㄹㅇ이면 진짜 꼭봐야돼 진짜 세계도 파괴시키는거아니야 .. 와 진짜 나루토사스케가 저렇게 되다니 진짜 눈물나려고했다.. 버루토그라서 계속보는중인데 저거 ㄹㅇ이냐..? 하.. ㅆㅂ 사스케 보고싶다.. 진짜언제 이렇게 신급 최강들이 되었을까 옛날생각나고 나 중딩때생각나고 뭔가 슬프기도하고 좋기도하고 감격도하고 여러가지감정이 복잡하네.. 아무튼 나루토는 진짜 애니중최거명작임..</p>
</div>
</div>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script>
google.charts.load('current', {packages:['corechart']});
......@@ -62,6 +61,7 @@
<script src="../js/contents.js"></script>
<script src="../js/generate.js"></script>
<script src="../js/statistics.js"></script>
<script async src="https://apis.google.com/js/client.js"></script>
</body>
</html>
\ No newline at end of file
......
......@@ -4,7 +4,7 @@ var objects = [
// 아래의 jobs 배열과 합쳐져 result가 나옴
var jobs = [
'방문판매원', '관찰자', '심리치료사', '조향사', '비서', '요리사', '대표상담사', '교수', 'av배우', '파일럿', '의사', '수의사', '가수', '미식가', '청소부', '국회의원', '유튜버', '대통령비서', '바리스타', '앱개발자', '빅데이터분석가', '경제학자', '과학자', '수학자', '스튜디어스', '간호사', '타투이스트', '웹디자이너', '패션디자이너', '건축공학자', '토목공학자', '경찰', '소방관', '부동산중계인', '고등학교선생님', '중학교선생님', '초등학교선생님', '교장선생님', '교감선생님', '스트리머', '택시운전기사', '정보보안전문가', '건축설계사', '카지노딜러', '경영학자', '화가', '백댄서', '아이돌', '배우', '영화감독', '카메라감독', '사립탐정', '검사', '변호사', '프로게이머', '자영업자'
'방문판매원', '관찰자', '심리치료사', '조향사', '비서', '요리사', '대표상담사', '교수', '영화배우', '파일럿', '의사', '수의사', '가수', '미식가', '청소부', '국회의원', '유튜버', '대통령비서', '바리스타', '앱개발자', '빅데이터분석가', '경제학자', '과학자', '수학자', '스튜디어스', '간호사', '타투이스트', '웹디자이너', '패션디자이너', '건축공학자', '토목공학자', '경찰', '소방관', '부동산중계인', '고등학교선생님', '중학교선생님', '초등학교선생님', '교장선생님', '교감선생님', '스트리머', '택시운전기사', '정보보안전문가', '건축설계사', '카지노딜러', '경영학자', '화가', '백댄서', '아이돌', '배우', '영화감독', '카메라감독', '사립탐정', '검사', '변호사', '프로게이머', '자영업자'
]
// 아래의 behavior 배열과 합쳐짐
......
var date = new Date();
function addZeroMonth(date) {
if ((date + 1) < 10) return `0${date + 1}`;
else return `${date + 1}`;
}
function addZeroDate(date) {
if (date < 10) return `0${date}`;
else return `${date}`;
}
am4core.ready(async function () {
fetch('/api/visiters')
......@@ -9,12 +22,12 @@ am4core.ready(async function () {
for (var i = 0; i < myJson.length; i++) {
const temp = {
"date": myJson[i].date,
"date": `${myJson[i].year}-${addZeroMonth(myJson[i].month)}-${addZeroDate(myJson[i].day)}`,
"value": myJson[i].numOfVisiters
};
data.push(temp);
}
console.log(data);
// Create chart instance
var chart = am4core.create("chartdiv", am4charts.XYChart);
......
This diff is collapsed. Click to expand it.
{
"name": "abc",
"version": "1.0.0",
"description": "<h1>악질 미래 직업 생성기</h1>\r <h4>본 과제는 [악질이름생성기](https://name.ho9.me/)에서 영감을 받아 만들었습니다.<h5>\r <br>\r <br>\r <h3>최근 사촌동생이 재밌다고 보내준 [악질이름생성기](https://name.ho9.me/)는 간단하게 사용할 수 있고 동시에 금방 즐길 수 있는 인스턴트 엔터테이먼트였다. 나도 그렇지만 최근 많은 사람들이 이렇게 \r 간단하게 즐길 수 있는 서비스를 선호하는 편이다. 위 사이트같이 간단한 사이트는 금방 새로운 사이트로 변신할 수 있으며, 또 금방 퍼질 수 있는 속성을 가졌다. 따라서 새로운 버전을 만들어 유포함과 동시에 이러한 인스턴트 엔터테이먼트가 할 얼마나 이용될 수 있는지 통계해보고자 이 사이트를 만들기로 하였다.</h3>",
"main": "app.js",
"dependencies": {
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"cookie-session": "^1.4.0",
"express": "^4.17.1",
"fs": "0.0.1-security",
"moment": "^2.26.0",
"mysql": "^2.18.1",
"path": "^0.12.7",
"react": "^16.13.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "ssh://git@khuhub.khu.ac.kr:12959/2019102216/opensource_term_project.git"
},
"author": "",
"license": "ISC"
}
......@@ -19,9 +19,7 @@ function addZeroDate(date) {
var dateString = `${date.getFullYear()}-${addZeroMonth(date)}-${addZeroDate(date)}`;
if(date.getHours() === 0) {
dateArray.push()
}
var dataArray =[];
......@@ -30,3 +28,57 @@ if(currentTime.currrntHour === 23 && currentTime.currrntMinute === 59 && current
}
console.log(dateString);
var cookieSession = require('cookie-session')
var count =0;
app.set('trust proxy', 1) // trust first proxy
app.use(cookieSession({
name: 'session',
keys: ['key1', 'key2']
}))
app.use(function (req, res, next) {
var date = new Date();
var today=date.getYear()+" "+date.getMonth()+" "+date.getDate();
// Update views
console.log(req.session.lastVisit);
if(req.session.lastVisit != today){
req.session.lastVisit = today;
count++;
}
if(date.getHours() === 23 && date.getMinutes===59 && date.getSeconds===59 && date.getMilliseconds===999) {
dateArray.push(count);
count=0;
}
// Write response
res.end(count + 'visit')
})
var now = new Date();
setInterval("server_time()", 1000);
function server_time()
{
now.setSeconds(now.getSeconds()+1);
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
if (hours < 10){
hours = "0" + hours;
}
if (minutes < 10){
minutes = "0" + minutes;
}
if (seconds < 10){
seconds = "0" + seconds;
}
console.log(hours + ":" + minutes + ":" + seconds);
}
\ No newline at end of file
......