-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69604ef
commit ce221fe
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<!DOCTYPE html> | ||
<html lang="ko"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>StudyVueJs</title> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> | ||
<script src="https://code.jquery.com/jquery-3.2.1.min.js | ||
"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> | ||
<script src="https://unpkg.com/vue"></script> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
<div class="page-header"> | ||
<h1> | ||
<span>POMODORO</span> | ||
<button type="button" class="btn btn-default" @click="start()"><span class="glyphicon glyphicon-play"></span></button> | ||
</h1> | ||
</div> | ||
<div class="well"> | ||
<div class="pomodoro-timer"> | ||
<span>{{minute}}</span>:<span>{{second}}</span> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</body> | ||
<script> | ||
const STATE = { | ||
WORK : "work" | ||
, REST : "reset" | ||
}; | ||
const MINUTES_WORKIG_TIME = 25; | ||
const MINUTES_REST_TIME = 5; | ||
const ONE_SECOND = 1000; | ||
|
||
var data = { | ||
minute : MINUTES_WORKIG_TIME | ||
, second : 0 | ||
, state : STATE.WORK | ||
, timestamp : 0 | ||
}; | ||
|
||
new Vue({ | ||
el : "#app" | ||
, data : data | ||
, methods : { | ||
start : function() { | ||
this._tick(); | ||
this.interval = setInterval(this._tick, ONE_SECOND); | ||
} | ||
, _tick : function() { | ||
if(this.second !== 0) { | ||
this.second--; | ||
return; | ||
} | ||
|
||
if(this.minute !== 0) { | ||
this.minute --; | ||
this.second = 59; | ||
return; | ||
} | ||
|
||
this.state = (this.state === STATE.WORK)? STATE.REST : STATE.WORK; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
switch (this.state) { | ||
case STATE.WORK : | ||
this.minute = MINUTES_WORKIG_TIME; | ||
break; | ||
|
||
case STATE.REST : | ||
this.minute = MINUTES_REST_TIME; | ||
break; | ||
} | ||
} | ||
} | ||
}) | ||
</script> | ||
</html> |
실수로 조건문을 생략해버림, 그래서 상태변경이 제대로 변경되지 않으므로 참고
if(this.minute === 0 && this.second === 0 ) {