Skip to content
This repository has been archived by the owner on Jul 19, 2020. It is now read-only.

Commit

Permalink
feat: lecture notification alarm
Browse files Browse the repository at this point in the history
  • Loading branch information
junhoyeo committed May 5, 2019
1 parent 4df5688 commit 6638ac6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"default_popup": "index.html"
},
"permissions": [
"notifications",
"alarms",
"https://*/*"
]
}
Binary file added src/assets/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion src/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,29 @@ export default {
if ([-1, 5].indexOf(this.todayIndex) > -1) {
return 'μ‹ λ‚˜λŠ” 주말!';
}
if (lecture.start.isValid()) { return `${lecture.start.format('HH:mm')} ~ ${lecture.end.format('HH:mm')}`; }
if (lecture.start.isValid()) {
this.createAlarm(lecture)
return `${lecture.start.format('HH:mm')} ~ ${lecture.end.format('HH:mm')}`;
}
return (lecture.idx) ? 'μ˜€λŠ˜λ„ μˆ˜κ³ ν–ˆμ–΄!' : 'μ˜€λŠ˜λ„ ν™”μ΄νŒ…!';
},
createNotification(period, minute) {
chrome.notifications.clear('dimicigan');
chrome.notifications.create('dimicigan', {
iconUrl: './src/assets/logo.jpg',
type: 'basic',
title: `μˆ˜μ—… μ‹œκ°„ ${minute}λΆ„ μ „`,
message: `${period}κ΅μ‹œ μˆ˜μ—… μ‹œμž‘κΉŒμ§€ ${minute}λΆ„ λ‚¨μ•˜μ–΄μš”!`,
});
},
createAlarm(lecture) {
chrome.alarms.create('dimicigan', {when: lecture.start.subtract(5, 'minutes').valueOf()});
chrome.alarms.onAlarm.addListener(function( alarm ) {
this.createNotification(lecture.idx, 5)
});
},
},
};
</script>
Expand Down

0 comments on commit 6638ac6

Please sign in to comment.