Skip to content

Commit

Permalink
updated & optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
RoderickQiu committed May 11, 2019
1 parent 304fadf commit a78934a
Show file tree
Hide file tree
Showing 13 changed files with 209 additions and 116 deletions.
7 changes: 7 additions & 0 deletions .vscode/wnr.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@
"i18n.__('$1')"
],
"description": "Get the i18n value defined."
},
"log": {
"prefix": "log",
"body": [
"ipc.send(\"logger\",\"$1\");"
],
"description": "Log to console."
}
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ As a timer app, wnr is simple but useful.

- multi-platform support

- multi-language support
- multi-language support ***(you can help to contribute!)***

- with strong expansibility

Expand All @@ -56,6 +56,8 @@ Please go and see the [GitHub Project](https://github.com/RoderickQiu/wnr/projec

- Need Help: [Go to Help Page](https://wnr.scris.top/help.html) or [Contact Me](https://roderickqiu.scris.top/)

- Any issues or pull requests are appreciated.

---

_Copyright (c) 2019 **[Roderick Qiu](https://roderickqiu.scris.top)**_
8 changes: 6 additions & 2 deletions about.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
<script>if (typeof module === 'object') { window.module = module; module = undefined; }</script>
<!-- solve the electron-jquery conflict -->
<script>
if (typeof module === 'object') {
window.module = module; module = undefined;
}
</script>
<!-- solve the electron-jquery conflict, style changed due to a vscode problem -->
<script src="res/lib/jquery-3.3.1.min.js"></script>
<script src="res/lib/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="res/lib/bootstrap.min.css" />
Expand Down
46 changes: 34 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
<script>if (typeof module === 'object') { window.module = module; module = undefined; }</script>
<!-- solve the electron-jquery conflict -->
<script>
if (typeof module === 'object') {
window.module = module; module = undefined;
}
</script>
<!-- solve the electron-jquery conflict, style changed due to a vscode problem -->
<script src="res/lib/jquery-3.3.1.min.js"></script>
<script src="res/lib/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="res/lib/bootstrap.min.css" />
Expand Down Expand Up @@ -67,11 +71,14 @@
<div id="set" class="justify-content-center">
<form action="timer.html" method="GET">
<input name="title" id="title" type="text" class="small" maxlength="11" /><br /><br />
<input name="work-time" id="work-time" type="number" onkeyup="allset()" style="ime-mode:Disabled"
<input name="work-time" id="work-time" type="number" onkeyup="allset()"
oninput="if (value.length > 4) value = value.slice(0, 4)" style="ime-mode:Disabled"
class="work lead" autofocus required /><br /><br />
<input name="rest-time" id="rest-time" type="number" onkeyup="allset()" style="ime-mode:Disabled"
<input name="rest-time" id="rest-time" type="number" onkeyup="allset()"
oninput="if (value.length > 4) value = value.slice(0, 4)" style="ime-mode:Disabled"
class="rest lead" required /><br /><br />
<input name="loop" id="loop" type="number" onkeyup="allset()" style="ime-mode:Disabled" class="small"
<input name="loop" id="loop" type="number" onkeyup="allset()"
oninput="if (value.length > 3) value = value.slice(0, 3)" style="ime-mode:Disabled" class="small"
required /><br /><br />
<!-- control that only numbers are OK -->
<input name="note" id="note" type="text" class="small" maxlength="39" />
Expand All @@ -91,25 +98,40 @@
</div>
<div id="allsum" class="small font-weight-bold text-black-50">
<script>document.write(i18n.__('allsum1'));</script> <span id="allsum-num">---</span>
<script>document.write(i18n.__('allsum2'));</script>
<script>document.write(i18n.__('allsum2'));</script> <span id="to-num-h">--</span>:<span
id="to-num-min">--</span>
</div>
</div>
<script>
var timecnt, myDate, h, min;
function sumget() {
timecnt = (parseInt($("#work-time").val()) + parseInt($("#rest-time").val())) * parseInt($("#loop").val());
$("#allsum-num").html(timecnt);
myDate = new Date();
h = myDate.getHours() + parseInt(timecnt / 60);
min = myDate.getMinutes() + timecnt % 60;
if (min >= 60) min -= 60, h++;
while (h >= 24) h -= 24;
$("#to-num-h").html(h);
if (min >= 10) $("#to-num-min").html(min);
else $("#to-num-min").html("0" + min);
}
isTimerWindow(false);
$("#work-time").val(store.get("worktime"));
$("#rest-time").val(store.get("resttime"));
$("#loop").val(store.get("looptime"));
if ((parseInt($("#work-time").val()) + parseInt($("#rest-time").val())) * parseInt($("#loop").val()))
$("#allsum-num").html((parseInt($("#work-time").val()) + parseInt($("#rest-time").val())) * parseInt($("#loop").val()));
if ((parseInt($("#work-time").val()) + parseInt($("#rest-time").val())) * parseInt($("#loop").val())) sumget();
if (process.platform == "darwin") {
$("#win-hider").css("display", "none");
$("#no-use-space").css("display", "none");
}
function allset() {
if ((parseInt($("#work-time").val()) + parseInt($("#rest-time").val())) * parseInt($("#loop").val()))
$("#allsum-num").html((parseInt($("#work-time").val()) + parseInt($("#rest-time").val())) * parseInt($("#loop").val()));
else $("#allsum-num").html("---");
return (/[0-9]/.test(String.fromCharCode(event.keyCode)));
if ((parseInt($("#work-time").val()) + parseInt($("#rest-time").val())) * parseInt($("#loop").val())) sumget();
else {
$("#allsum-num").html("---");
$("#to-num-h").html("--");
$("#to-num-min").html("--");
}
}
</script>
</body>
Expand Down
6 changes: 4 additions & 2 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"resettip": "Set it to \"0\" to delete the former setting.",
"globalset": "Global Settings",
"langset": "Language: ",
"langtip": "If the checkbox is checked, wnr will display in English, and vice versa.",
"langtip": "If the checkbox is checked, wnr will display in English, or else in Chinese.",
"soundnotify": "Play sound to notify: ",
"soundtip": "If it is enabled, then every time your time is ended, a notice sound is played.",
"alwaysontop": "Always on top: ",
Expand Down Expand Up @@ -103,5 +103,7 @@
"alarmtip": "Long time no see... ",
"alarmtipmsg": "Open wnr and have a healthier schedule! ",
"allsum1": "all together",
"allsum2": "minutes"
"allsum2": "minutes, to ",
"1min": "Only 1 minute left",
"1minmsg": "Only a few amount of time left! "
}
8 changes: 5 additions & 3 deletions locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"resttime": "然后再休息多少分钟?",
"loop": "循环几次?",
"note": "还有什么想记的吗?",
"tip": "输入各个项目,然后按Enter键开始计时器",
"tip": "输入各个项目,然后按Enter键开始计时器",
"backindex": "放弃当前时间计划并返回首页",
"skipper": "提前跳过当前的时间",
"notenough": "请合法输入工作时间、休息时间和循环次数。",
"notenough": "请合法输入工作时间、休息时间和循环次数。暂时不支持1分钟及以下的时间。",
"toolong": "长度太长的计划暂时不能添加。",
"back": "返回首页",
"ended": "已完成",
Expand Down Expand Up @@ -103,5 +103,7 @@
"alarmtip": "你已经很久没有开始一个新计划了。",
"alarmtipmsg": "打开wnr,开始一个新计划吧!",
"allsum1": "共计",
"allsum2": "分钟"
"allsum2": "分钟,到",
"1min": "时间仅剩1分钟",
"1minmsg": "这一段时间只剩下1分钟了,好好规划一下暂时的收尾工作吧!"
}
11 changes: 11 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,17 @@ ipcMain.on('tourguide', function () {
);
})

ipcMain.on('1min', function () {
notifier.notify(
{
title: i18n.__('1min'),
message: i18n.__('1minmsg'),
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
}
);
})

ipcMain.on("progress-bar-set", function (event, message) {
if (win != null) win.setProgressBar(1 - message)
})
Expand Down
Loading

0 comments on commit a78934a

Please sign in to comment.