Skip to content

Commit

Permalink
πŸ”€ Merge pull request #9 from HiBixby/develop
Browse files Browse the repository at this point in the history
πŸ”– v0.1.2
  • Loading branch information
HiBixby authored Feb 3, 2023
2 parents d85a50c + af0b95f commit ccaf86c
Show file tree
Hide file tree
Showing 21 changed files with 267 additions and 123 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

🚧 WIP 🚧

[DEMO](https://hibixby.github.io/WhaleHae/)
## How to use
1. [웨일 μŠ€ν† μ–΄μ—μ„œ μ„€μΉ˜ν•˜κΈ° (v0.1.1)](https://store.whale.naver.com/detail/gmpkjmenbbmjcmcjpclkedbfbhmogbhp)

2. [개발 버전 μ²΄ν—˜ (v0.1.2-alpha)](https://hibixby.github.io/WhaleHae/)

- 개발 버전은 μ²΄ν—˜μ€ Github pagesλ₯Ό μ‚¬μš©ν•˜λ―€λ‘œ Chrome.apiλ₯Ό μ‚¬μš©ν•  수 μ—†μ–΄μ„œ 일뢀 κΈ°λŠ₯이 μž‘λ™ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

## What I used

Expand Down
9 changes: 9 additions & 0 deletions docs/assets/index-1fc6866e.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/assets/index-4cb2d004.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/assets/index-8e967823.css

This file was deleted.

9 changes: 0 additions & 9 deletions docs/assets/index-c0adee32.js

This file was deleted.

83 changes: 63 additions & 20 deletions docs/background.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,68 @@
console.log("background.js loaded!");

chrome.alarms.onAlarm.addListener((alarm) => {
console.log("Alarm!!!");
let passedAlarmCnt = 0;
const CreateTab = (link) => {
//링크가 null이 μ•„λ‹ˆλΌλ©΄ νƒ­ μ—΄κΈ°
if (link !== null) {
chrome.tabs.create({
url: link,
});
}
};
const CreateNotificationOptions = (message) => {
let notificationOptions = {
type: "basic",
iconUrl: "logo.png",
title: "웨, 일해",
message: "🐳제λͺ©μ—†μŒπŸ³",
priority: 2,
};
if (message !== null) {
notificationOptions.message = message;
}
return notificationOptions;
};
const CreateNotification = (NOTIFICATION_ID, message) => {
chrome.notifications.create(
NOTIFICATION_ID,
CreateNotificationOptions(message)
);
};
const UpdateNotification = (NOTIFICATION_ID, message) => {
chrome.notifications.update(
NOTIFICATION_ID,
CreateNotificationOptions(message),
(wasUpdated) => {
console.log("wasUpdated:", wasUpdated);
}
);
};
const FindIndexOfTodo = (id, result) => {
for (index in result.todos) {
if (id === result.todos[index].id.toString()) return index;
}
};

chrome.alarms.onAlarm.addListener(async (alarm) => {
console.log("Alarm executed!", alarm);
const id = alarm.name;
chrome.storage.local.get(["todos"]).then((result) => {
for (index in result.todos) {
if (id === result.todos[index].id.toString()) {
const message = result.todos[index].title;
chrome.notifications.create(id.toString(), {
type: "basic",
iconUrl: "logo.png",
title: "웨, 일해",
message: message ? message : "🐳제λͺ© μ—†μŒπŸ³",
priority: 2,
});
if (result.todos[index].link !== null) {
chrome.tabs.create({
url: result.todos[index].link,
});
}
}
const result = await chrome.storage.local.get(["todos"]);
console.log("result is...", result);
const index = FindIndexOfTodo(id, result);
//μ‹œκ°„μ΄ μ§€λ‚œ μ•ŒλžŒμΌ λ•Œ
if (Date.now() > result.todos[index].date + 60000) {
passedAlarmCnt++;
const NOTIFICATION_ID = "hasPassedAlarms";
const message = `자리λ₯Ό λΉ„μš΄ λ™μ•ˆ ${passedAlarmCnt}개의 μ•Œλ¦Όμ΄ μ‹€ν–‰λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.`;
if (passedAlarmCnt === 1) {
CreateNotification(NOTIFICATION_ID, message);
} else {
UpdateNotification(NOTIFICATION_ID, message);
}
});
//정상 μ•ŒλžŒμΌ λ•Œ
} else {
const message = result.todos[index].title;
CreateNotification(id, message);
CreateTab(result.todos[index].link);
}
});
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<link rel="stylesheet" href="./main.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>웨, 일해</title>
<script type="module" crossorigin src="./assets/index-c0adee32.js"></script>
<link rel="stylesheet" href="./assets/index-8e967823.css">
<script type="module" crossorigin src="./assets/index-1fc6866e.js"></script>
<link rel="stylesheet" href="./assets/index-4cb2d004.css">
</head>
<body>
<div id="app">
Expand Down
9 changes: 9 additions & 0 deletions docs/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
html,
body {
height: 100%;
}

body {
margin: 0;
}

.logo-container {
height: 100vh;
width: 100vw;
Expand Down
2 changes: 1 addition & 1 deletion docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "웨,일해(Whale Hae)",
"description": "μ›¨μΌλŒ€ν•™ 1νŒ€ - 일정 관리 및 링크 μžλ™ μ‹€ν–‰",
"version": "0.1.1",
"version": "0.1.2",
"sidebar_action": {
"default_page": "index.html",
"default_icon": {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "whale-hae",
"version": "0.1.0",
"version": "0.1.2",
"private": true,
"scripts": {
"dev": "vite",
Expand Down
Loading

0 comments on commit ccaf86c

Please sign in to comment.