Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions diary.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>日记</title>
<script src="./diary.js"></script>
</head>
<body>
<script>
const DAY = new Date().getDay()
const IS_OVERTIME = true

const todayDiary = new Diary(DAY, IS_OVERTIME)
todayDiary.getUP()
todayDiary.goToWork()
</script>
</body>
</html>
38 changes: 38 additions & 0 deletions diary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @Author: FunnyTedZhao
* @Date: 2019-06-22 10:04:43
* @Last Modified by: FunnyTedZhao
* @Last Modified time: 2019-06-22 11:45:55
*/

/**
* 日记类
* @class Diary
*/
class Diary {
constructor (day, isOvertime = false) {
this.day = day
this.isWork = (this.day > 0 && this.day < 6) ? true : (isOvertime ? true : false)
}

/**
* 起床函数
* @function getUP
* @param {Boolean} isOvertime
*/
getUP () {
const _wakeUpTime = this.isWork ? '闹钟响了' : '自然醒了'
document.write(`${_wakeUpTime},我该起床了!</br>`)
}

/**
* 上班函数
* @function goToWork
*/
goToWork (askForLeave = null) {
const _reasons = ['病假', '事假', '年假', '调休']
this.isWork = _reasons.includes(askForLeave) ? false : true
const _doSomething = this.isWork ? '身体健康,吃嘛嘛香!好好上班,努力挣钱!' : '有些事情,请假一天。好好休息,调整身心!'
document.write(`${_doSomething}</br>`)
}
}