Skip to content

Commit 16cd953

Browse files
committed
make more flexible alarmtip
1 parent e691ec9 commit 16cd953

7 files changed

Lines changed: 93 additions & 18 deletions

File tree

locales/en.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,25 @@
223223
"onemintip-tip": "When a period of time will end in a minute we will send you a notification, so that you can pause your work comfortably.",
224224
"nap-in-timing": "Nap setting",
225225
"nap-in-timing-tip": "Notify you to take a nap for several seconds every several minutes when working.",
226+
"dropdown-5min": "5 min",
226227
"dropdown-10min": "Every 10 min",
227228
"dropdown-15min": "Every 15 min",
228229
"dropdown-20min": "Every 20 min",
230+
"dropdown-30min": "30 min",
231+
"dropdown-60min": "60 min",
229232
"alarmtip": "Notify when you are not using wnr",
230-
"alarmtip-tip": "After you've paused / stopped using wnr for more than 10 min, we will notify you.",
233+
"alarmtip-tip": "After you have not used or paused wnr for the set duration, we will notify you.",
234+
"alarmtip-settings": "Notify when you are not using wnr",
235+
"alarmtip-settings-tip": "After you have not used or paused wnr for the set duration, we will notify you.",
236+
"alarmtip-duration": "Remind after",
237+
"alarmtip-duration-tip": "Notify when wnr has been unused or paused for longer than the selected time.",
238+
"alarmtip-duration-3min": "3 min",
239+
"alarmtip-duration-5min": "5 min",
240+
"alarmtip-duration-10min": "10 min",
241+
"alarmtip-duration-15min": "15 min",
242+
"alarmtip-duration-20min": "20 min",
243+
"alarmtip-duration-30min": "30 min",
244+
"alarmtip-duration-60min": "60 min",
231245
"personalization-notification": "Custom notifications",
232246
"personalization-notification-tip": "Define the words shown at notifications to motivate yourself. Clear textboxes to remove personalized text. Use \"//\" as to separate different sentences and each time you will be given a random choice.",
233247
"personalization-notification-label-begin": "\"",

locales/zh-CN.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,25 @@
262262
"onemintip-tip": "在每段时间还剩 1 分钟时发出提示,提醒你暂时收尾这段工作。",
263263
"nap-in-timing": "计时中途提醒(小憩设置)",
264264
"nap-in-timing-tip": "在工作一段时间后以系统通知的形式提醒你小憩几秒。",
265+
"dropdown-5min": "5 分钟",
265266
"dropdown-10min": "每 10 分钟",
266267
"dropdown-15min": "每 15 分钟",
267268
"dropdown-20min": "每 20 分钟",
269+
"dropdown-30min": "30 分钟",
270+
"dropdown-60min": "60 分钟",
268271
"alarmtip": "未使用 wnr 时发出提醒",
269-
"alarmtip-tip": "在连续不使用或连续暂停 wnr 达 10 分钟后提醒你立刻开始下一段计划。",
272+
"alarmtip-tip": "在连续不使用或连续暂停 wnr 达到所设时间后提醒你立刻开始下一段计划。",
273+
"alarmtip-settings": "未使用 wnr 时发出提醒",
274+
"alarmtip-settings-tip": "在连续不使用或连续暂停 wnr 达到所设时间后提醒你立刻开始下一段计划。",
275+
"alarmtip-duration": "提醒间隔",
276+
"alarmtip-duration-tip": "超过所选时间未使用或暂停 wnr 时发出提醒。",
277+
"alarmtip-duration-3min": "3 分钟",
278+
"alarmtip-duration-5min": "5 分钟",
279+
"alarmtip-duration-10min": "10 分钟",
280+
"alarmtip-duration-15min": "15 分钟",
281+
"alarmtip-duration-20min": "20 分钟",
282+
"alarmtip-duration-30min": "30 分钟",
283+
"alarmtip-duration-60min": "60 分钟",
270284
"personalization-notification": "通知文本个性化",
271285
"personalization-notification-tip": "自定义这些通知文本,让它们更加能激励你前行!清空以复位。输入\"//\"来分割数条语句,每次随机出现。",
272286
"personalization-notification-label-begin": "",

locales/zh-TW.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,25 @@
255255
"onemintip-tip": "在每段時間還剩 1 分鐘時發出提示,提醒你暫時收尾這段工作。",
256256
"nap-in-timing": "計時中途提醒(小憩設置)",
257257
"nap-in-timing-tip": "在工作一段時間後以系統通知的形式提醒你小憩幾秒。",
258+
"dropdown-5min": "5 分鐘",
258259
"dropdown-10min": "每 10 分鐘",
259260
"dropdown-15min": "每 15 分鐘",
260261
"dropdown-20min": "每 20 分鐘",
262+
"dropdown-30min": "30 分鐘",
263+
"dropdown-60min": "60 分鐘",
261264
"alarmtip": "未使用 wnr 時發出提醒",
262-
"alarmtip-tip": "在連續不使用或連續暫停 wnr 達 10 分鐘後提醒你立刻開始下一段計劃。",
265+
"alarmtip-tip": "在連續不使用或連續暫停 wnr 達到所設時間後提醒你立刻開始下一段計劃。",
266+
"alarmtip-settings": "未使用 wnr 時發出提醒",
267+
"alarmtip-settings-tip": "在連續不使用或連續暫停 wnr 達到所設時間後提醒你立刻開始下一段計劃。",
268+
"alarmtip-duration": "提醒間隔",
269+
"alarmtip-duration-tip": "超過所選時間未使用或暫停 wnr 時發出提醒。",
270+
"alarmtip-duration-3min": "3 分鐘",
271+
"alarmtip-duration-5min": "5 分鐘",
272+
"alarmtip-duration-10min": "10 分鐘",
273+
"alarmtip-duration-15min": "15 分鐘",
274+
"alarmtip-duration-20min": "20 分鐘",
275+
"alarmtip-duration-30min": "30 分鐘",
276+
"alarmtip-duration-60min": "60 分鐘",
263277
"personalization-notification": "通知文本個性化",
264278
"personalization-notification-tip": "自定義這些通知文本,讓它們更加能激勵你前行!清空以復位。輸入\"//\"來分割數條語句,每次隨機出現。",
265279
"personalization-notification-label-begin": "",

main.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ function createWindow() {
162162
});
163163
}
164164

165+
function getAlarmtipDurationMs() {
166+
const idx = store.get('alarmtip-duration');
167+
const minutes = [3, 5, 10, 15, 20, 30, 60];
168+
const n = (idx >= 0 && idx < minutes.length) ? minutes[idx] : 10;
169+
return n * 60 * 1000;
170+
}
171+
165172
function alarmSet() {
166173
resetAlarm = setTimeout(function () {
167174
if (store.get('alarmtip') !== false && isAlarmDialogClosed && isAlarmTipOn) {
@@ -173,7 +180,7 @@ function alarmSet() {
173180
}
174181
customDialog("on", i18n.__('alarm-for-not-using-wnr-dialog-box-title'), i18n.__('alarm-for-not-using-wnr-dialog-box-content'), "isAlarmDialogClosed = true;win.show();win.moveTop();alarmSet();");
175182
}
176-
}, 600000)//alarm you for using wnr
183+
}, getAlarmtipDurationMs())
177184
}
178185

179186
function relaunchSolution() {

preferences-items.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,22 @@ if (store.get("islocked") !== true) {
157157
def: 0,
158158
after: napAfter
159159
}, {
160-
type: "selection",
161-
id: "alarmtip",
162-
def: true
160+
type: "collapse",
161+
id: "alarmtip-settings",
162+
inner: [
163+
{
164+
type: "selection",
165+
id: "alarmtip",
166+
def: true,
167+
tipped: false
168+
}, {
169+
type: "dropdown",
170+
id: "alarmtip-duration",
171+
choices: ['3min', '5min', '10min', '15min', '20min', '30min', '60min'],
172+
def: 2,
173+
after: alarmtipDurationAfter
174+
}
175+
]
163176
}, {
164177
type: "dropdown",
165178
id: "sound",
@@ -308,6 +321,10 @@ function napAfter(val) {
308321
}
309322
}
310323

324+
function alarmtipDurationAfter(val) {
325+
}
326+
327+
311328
function looseModeAfter(val) {
312329
switch (val) {
313330
case 0:

preferences-renderer.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,21 @@ function dropdownSolution(obj, parent) {
111111
</div>
112112
<br/>
113113
`);
114+
let choiceLabel = function (key) {
115+
return (id === 'alarmtip-duration') ? i18n.__('alarmtip-duration-' + key) : i18n.__('dropdown-' + key);
116+
};
114117
for (let i in choices) {
118+
let label = choiceLabel(choices[i]);
115119
$('#dropdown-' + id).append(`
116-
<a class='dropdown-item' href="javascript:dropdownTrigger('${ id }',${ i }, '${ i18n.__('dropdown-' + choices[i]) }',${ relaunch },${ after })">
117-
${ i18n.__('dropdown-' + choices[i]) }
120+
<a class='dropdown-item' href="javascript:dropdownTrigger('${ id }',${ i }, '${ label.replace(/'/g, "\\'") }',${ relaunch },${ after })">
121+
${ label }
118122
</a>
119123
`);
120124
}
121-
if (!store.has(id)) $('#dropdown-button-' + id).html(i18n.__('dropdown-' + choices[def]));
125+
if (!store.has(id)) $('#dropdown-button-' + id).html(choiceLabel(choices[def]));
122126
else {
123-
$('#dropdown-button-' + id).html(i18n.__('dropdown-' + choices[store.get(id)]));
124-
console.log(i18n.__('dropdown-' + choices[store.get(id)]), "CHOICE", id, store.get(id));
127+
$('#dropdown-button-' + id).html(choiceLabel(choices[store.get(id)]));
128+
console.log(choiceLabel(choices[store.get(id)]), "CHOICE", id, store.get(id));
125129
}
126130
}
127131

timer.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -916,12 +916,17 @@ <h3>
916916
$("#stopper").html("<i class='iconfont icon-play' aria-hidden='true'></i>");
917917
isClockWorking = 0;//to stop
918918
ipc.send("tray-image-change", "stop");
919-
if (store.get("alarmtip") !== false) pausingTimeout = setInterval(function () {
920-
ipc.send("notify", {
921-
title: i18n.__('alarm-for-not-using-wnr-dialog-box-title'),
922-
msg: i18n.__('alarm-for-not-using-wnr-dialog-box-content')
923-
});
924-
}, 600000);
919+
if (store.get("alarmtip") !== false) {
920+
var alarmtipMinutes = [3, 5, 10, 15, 20, 30, 60];
921+
var alarmtipIdx = store.get("alarmtip-duration");
922+
var alarmtipMs = ((alarmtipIdx >= 0 && alarmtipIdx < alarmtipMinutes.length) ? alarmtipMinutes[alarmtipIdx] : 10) * 60 * 1000;
923+
pausingTimeout = setInterval(function () {
924+
ipc.send("notify", {
925+
title: i18n.__('alarm-for-not-using-wnr-dialog-box-title'),
926+
msg: i18n.__('alarm-for-not-using-wnr-dialog-box-content')
927+
});
928+
}, alarmtipMs);
929+
}
925930
if (hasFloating) {
926931
if (methodFromStart === 3) {
927932
ipc.send("floating-heartbeat", {

0 commit comments

Comments
 (0)