김유현

Add 출근날 체크

......@@ -9,13 +9,16 @@
<br>
<div id = "payPerDay" class="in"></div>
<br>
<div style="font-weight: bold;" id = "moneyPerSec" class="in"></div>
<div style="font-weight: bold; font-size: large;" id = "moneyPerSec" class="in"></div>
<br>
<div id = "workDay" class="in"></div>
</div>
<div class="progress-bar"></div>
<h1 class="count"></h1>
</body>
<script charset="utf-8">
//url에서 변수 받아오는 함수
function getParam(sname) {
var params = location.search.substr(location.search.indexOf("?") + 1);
var sval = "";
......@@ -27,6 +30,7 @@
return sval;
}
//strig format 함수 (e.g. "{0}")
String.format = function() {
// The string containing the format items (e.g. "{0}")
// will and always has to be the first argument.
......@@ -43,19 +47,80 @@
return theString;
}
//document.getElementById("payDay").innerHTML = "pay day : " + getParam("payDay");
//출근날 체크 함수
function isTodayWork(workDay, workDayStr){
var Mon = "%EC%9B%94";
var Tue = "%ED%99%94";
var Wed = "%EC%88%98";
var Thu = "%EB%AA%A9";
var Fri = "%EA%B8%88";
var Sat = "%ED%86%A0";
var Sun = "%EC%9D%BC%0A";
if (workDay == 0){
if (workDayStr.indexOf(Sun) != -1){
return true;}
else {
return false;
}
}
else if (workDay == 1){
if (workDayStr.indexOf(Mon) != -1){
return true;}
else {
return false;
}
}
else if (workDay == 2){
if (workDayStr.indexOf(Thu) != -1){
return true;}
else {
return false;
}
}
else if (workDay == 3){
if (workDayStr.indexOf(Wed) != -1){
return true;}
else {
return false;
}
}
else if (workDay == 4){
if (workDayStr.indexOf(Thu) != -1){
return true;}
else {
return false;
}
}
else if (workDay == 5){
if (workDayStr.indexOf(Fri) != -1){
return true;}
else {
return false;
}
}
else if (workDay == 6){
if (workDayStr.indexOf(Sat) != -1){
return true;}
else {
return false;
}
}
}
//변수 정의
var salary = Number(getParam("salary"));
var workTime = Number(getParam("workTime"));
var offWork = Number(getParam("offWork"));
var workingDay = getParam("workDay");
var workingDayNum = getParam("workDay").length / 9;
var payPerDay = salary/(4*workingDayNum);
//document.getElementById("salary").innerHTML = "salary : " + salary;
document.getElementById("payPerDay").innerHTML = "The daily wage is " + payPerDay + "won";
//document.getElementById("workDay").innerHTML = "working day : " + getParam("workDay");
//document.getElementById("offWork").innerHTML = "time of work : " + offWork;
//document.getElementById("workedHour").innerHTML = "worked hour : " + String(offWork - workTime);
// moneyPerSec 초기값 계산
var nowTime = new Date();
var strWorkTime = workTime
if (strWorkTime < 10){
......@@ -65,19 +130,16 @@
var workStart = new Date(dayStr);
var diff = (nowTime.getTime() - workStart.getTime());
var moneyPerSec = diff*(payPerDay/(1000*60*60*(offWork - workTime)));
//일정 시간동안 반복 호출 함수
setInterval("dpTime()",1);
function dpTime(){
var now = new Date();
day = now.getDay();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
//if (hours > 12)
//{ hours -= 12;
// ampm = "오후 ";
//}else
//{ ampm = "오전 ";
//}
if (hours < 10){
hours = "0" + hours;
} if (minutes < 10){
......@@ -86,6 +148,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;
......@@ -100,11 +166,7 @@
}
}
//document.getElementById("workedHour").innerHTML = "Hours worked : " + parseInt(Number(getParam("offWork")))-parseInt(Number(getParam("workTime")));
//document.getElementById("workTime").innerHTML = "working time : " + escape(getParam("workTime"));
//document.getElementById("offWork").innerHTML = "time of work : " + getParam("offWork");
}
var body = document.querySelector('body'),
bar = document.querySelector('.progress-bar'),
......@@ -112,10 +174,16 @@
i = 0,
throttle = 0.4; // 0-1
(function draw() {
if(i <= 100) {
//var r = Math.random();
var now = new Date();
day = now.getDay();
if(i <= 100) {
requestAnimationFrame(draw);
if(isTodayWork(day, workingDay) != true){
bar.style.width = 0 + '%';
counter.innerHTML = '오늘 쉬는날';
}
else {
if(hours < workTime){
bar.style.width = 0 + '%';
counter.innerHTML = '출근 안했당';
......@@ -130,6 +198,8 @@
//if(r < throttle) { // Simulate d/l speed and uneven bitrate
// i = i + r;
//}
}
} else {;
bar.className += " done";
}
......