김유현

Almost final commit

......@@ -20,9 +20,7 @@ app.get('/graph', function(req, res){
var workDay = req.query.workDay
var workTime = req.query.workTime
var offWork = req.query.offWork
//console.log(payDay, salary,workDay,workTime, offWork);
res.sendFile(__dirname + '/public/graph.html');
//res.send(`payDay : ${payDay}, salary : ${salary}, workDay : ${workDay}, workTime : ${workTime}, offWork : ${offWork}`);
})
app.listen(3000, function(){
......
......@@ -135,11 +135,14 @@
//일정 시간동안 반복 호출 함수
setInterval("dpTime()",1);
function dpTime(){
// 실시간 날짜 변수 정의
var now = new Date();
day = now.getDay();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
// 시간, 분, 초 2자리로 출력
if (hours < 10){
hours = "0" + hours;
} if (minutes < 10){
......@@ -147,60 +150,73 @@
} if (seconds < 10){
seconds = "0" + seconds;
}
//현재 시간 웹에 넣기
document.getElementById("dpTime").innerHTML = "The current time is "+ hours + ":" + minutes + ":" + seconds;
//출근날이라면
if(isTodayWork(day, workingDay)){
document.getElementById("payPerDay").innerHTML = "The daily wage is " + payPerDay + "won";
if (hours < workTime){
var diff2 = (workStart.getTime() - now.getTime());
var hour2 = (diff2/(1000*60*60))%24 - ((diff2/(1000*60*60))%24)%1;
var min2 = (diff2/(1000*60))%60 - ((diff2/(1000*60))%60)%1;
var sec2 = (diff2/1000)%60;
//일당 받아 웹에 넣기
document.getElementById("payPerDay").innerHTML = "The daily wage is " + payPerDay + "won";
document.getElementById("moneyPerSec").innerHTML = "출근할 때까지 "+ String(hour2) + "시간" + String(min2) + "분" + String(sec2.toFixed(2)) + "초 남았당";
}
else{
moneyPerSec += payPerDay/(1000*60*60*(offWork - workTime));
document.getElementById("moneyPerSec").innerHTML = + moneyPerSec.toFixed(3) + "won earging today !!";
}
// 출근 시간 전이라면 출근 시간까지 얼마나 남았는지 계산하고 웹에 넣기
if (hours < workTime){
var diff2 = (workStart.getTime() - now.getTime());
var hour2 = (diff2/(1000*60*60))%24 - ((diff2/(1000*60*60))%24)%1;
var min2 = (diff2/(1000*60))%60 - ((diff2/(1000*60))%60)%1;
var sec2 = (diff2/1000)%60;
document.getElementById("moneyPerSec").innerHTML = "출근할 때까지 "+ String(hour2) + "시간" + String(min2) + "분" + String(sec2.toFixed(2)) + "초 남았당";
}
else{
//출근 했다면 실시간 버는 돈 계산하고 웹에 넣기
var diff3 = (now.getTime() - workStart.getTime());
moneyPerSec = diff3*(payPerDay/(1000*60*60*(offWork - workTime)));
document.getElementById("moneyPerSec").innerHTML = + moneyPerSec.toFixed(3) + "won earging today !!";
}
}
}
}
// 막대 그래프
var body = document.querySelector('body'),
bar = document.querySelector('.progress-bar'),
counter = document.querySelector('.count'),
i = 0,
throttle = 0.4; // 0-1
i = 0;
(function draw() {
//요일 , 시간 변수
var now = new Date();
day = now.getDay();
var day2 = now.getDay();
var hours2 = now.getHours();
//일을 100% 끝내지 못했다면
if(i <= 100) {
requestAnimationFrame(draw);
if(isTodayWork(day, workingDay) != true){
// 오늘이 쉬는 날이라면
if(isTodayWork(day2, workingDay) != true){
bar.style.width = 0 + '%';
counter.innerHTML = '오늘 쉬는날';
}
else {
if(hours < workTime){
// 출근날이라면
else {
//아직 출근 전이라면
if(hours2 < workTime){
bar.style.width = 0 + '%';
counter.innerHTML = '출근 안했당';
}
else{
}
//출근 했다면
else{
//실시간 버는 돈 백분율로 계산
i = (moneyPerSec / payPerDay) * 100;
bar.style.width = i.toFixed(4) + '%';
counter.innerHTML = i.toFixed(4) + '%';
}
bar.style.width = i.toFixed(4) + '%';
counter.innerHTML = i.toFixed(4) + '%';
}
//if(r < throttle) { // Simulate d/l speed and uneven bitrate
// i = i + r;
//}
}
} else {;
}
//일을 100% 끝내다면
else {;
bar.className += " done";
}
})();
......