-
-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from hovancik/topic
New stuff for 0.4.0
- Loading branch information
Showing
24 changed files
with
636 additions
and
150 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
npm-debug.log | ||
.DS_Store | ||
dist |
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
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
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,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Time to take a break!</title> | ||
<link rel="stylesheet" type="text/css" href="css/app.css"> | ||
</head> | ||
<body> | ||
<div class="microbreak"> | ||
<div class="break-idea"></div> | ||
<div class="break-text"></div> | ||
<a id="close">...nah, I'll just keep going on</a> | ||
</div> | ||
<script> | ||
require('./break.js') | ||
</script> | ||
</body> | ||
</html> |
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,12 @@ | ||
const {ipcRenderer} = require('electron') | ||
|
||
document.getElementById('close').addEventListener('click', function (e) { | ||
ipcRenderer.send('finish-break', false) | ||
}) | ||
|
||
ipcRenderer.on('breakIdea', (event, message) => { | ||
let breakIdea = document.getElementsByClassName('break-idea')[0] | ||
breakIdea.innerHTML = message[0] | ||
let breakText = document.getElementsByClassName('break-text')[0] | ||
breakText.innerHTML = message[1] | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,73 @@ | ||
const Scheduler = require('./utils/scheduler') | ||
|
||
class BreaksPlanner { | ||
constructor (settings, microbreakFunc, breakFunc) { | ||
this.settings = settings | ||
this.microbreakFunc = microbreakFunc | ||
this.breakFunc = breakFunc | ||
this.breakNumber = 0 | ||
this.scheduler = null | ||
} | ||
|
||
get nextBreak () { | ||
let shouldBreak = this.settings.get('break') | ||
let shouldMicrobreak = this.settings.get('microbreak') | ||
let interval = this.settings.get('microbreakInterval') | ||
if (!shouldBreak && shouldMicrobreak) { | ||
this.scheduler = new Scheduler(this.microbreakFunc, interval) | ||
} else if (shouldBreak && !shouldMicrobreak) { | ||
this.scheduler = new Scheduler(this.breakFunc, interval * (this.settings.get('breakInterval') + 1)) | ||
} else if (shouldBreak && shouldMicrobreak) { | ||
this.breakNumber = this.breakNumber + 1 | ||
let breakInterval = this.settings.get('breakInterval') + 1 | ||
if (this.breakNumber % breakInterval === 0) { | ||
this.scheduler = new Scheduler(this.breakFunc, interval) | ||
} else { | ||
this.scheduler = new Scheduler(this.microbreakFunc, interval) | ||
} | ||
} | ||
return this.scheduler | ||
} | ||
|
||
skipToMicrobreak () { | ||
this.scheduler.cancel() | ||
let shouldBreak = this.settings.get('break') | ||
let shouldMicrobreak = this.settings.get('microbreak') | ||
let breakInterval = this.settings.get('breakInterval') + 1 | ||
if (shouldBreak && shouldMicrobreak) { | ||
if (this.breakNumber % breakInterval === 0) { | ||
this.breakNumber = 1 | ||
} | ||
} | ||
this.scheduler = new Scheduler(this.microbreakFunc, 100) | ||
return this.scheduler | ||
} | ||
|
||
skipToBreak () { | ||
this.scheduler.cancel() | ||
let shouldBreak = this.settings.get('break') | ||
let shouldMicrobreak = this.settings.get('microbreak') | ||
if (shouldBreak && shouldMicrobreak) { | ||
let breakInterval = this.settings.get('breakInterval') + 1 | ||
this.breakNumber = breakInterval | ||
} | ||
this.scheduler = new Scheduler(this.breakFunc, 100) | ||
return this.scheduler | ||
} | ||
|
||
pause () { | ||
this.scheduler.cancel() | ||
this.breakNumber = 0 | ||
} | ||
|
||
resume () { | ||
return this.nextBreak | ||
} | ||
|
||
reset () { | ||
this.pause() | ||
this.resume() | ||
} | ||
} | ||
|
||
module.exports = BreaksPlanner |
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
Oops, something went wrong.