Skip to content

Commit

Permalink
update focus mode etc
Browse files Browse the repository at this point in the history
  • Loading branch information
RoderickQiu committed Jun 7, 2019
1 parent 0918582 commit cd441aa
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 82 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# wnr

**Download: [GitHub Release](https://github.com/RoderickQiu/wnr/releases) | [Softpedia](https://www.softpedia.com/get/Desktop-Enhancements/Clocks-Time-Management/wnr.shtml) | [百度网盘(提取码:swh3)](https://pan.baidu.com/s/1PDpnEkf-zKQKQIhUTO0ubQ)**
**Download: [GitHub Release](https://github.com/RoderickQiu/wnr/releases) | [Softpedia (Windows)](https://www.softpedia.com/get/Desktop-Enhancements/Clocks-Time-Management/wnr.shtml) | [百度网盘(提取码:swh3)](https://pan.baidu.com/s/1PDpnEkf-zKQKQIhUTO0ubQ)**

## Introduction

**[中文版](https://scris.top/wnr/)**

**The name is an abbr of "Work & Rest". It's a timer app with strong expansibility for computers.**
**The name is an abbr of "Work & Rest". It's a timer app with strong expansibility for computers _(Windows and macOS until now)_.**

![Preview](https://raw.githubusercontent.com/RoderickQiu/wnr/master/res/preview/preview-1-smaller.png)

Expand Down Expand Up @@ -44,7 +44,7 @@ As a timer app, wnr is simple but useful.

- multi-platform support

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

- with strong expansibility

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

---

_Copyright (c) 2019 **[Roderick Qiu](https://roderickqiu.scris.top)**_
_Copyright (c) 2019 **[Roderick Qiu](https://roderickqiu.scris.top)**, [Acknoledgements](https://wnr.scris.top/acknoledgements.html)._
2 changes: 1 addition & 1 deletion about.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</p>
<p class="extreme-small">
<a class="rest"
href="javascript:require('electron').shell.openExternal('https://wnr.scris.top/acknoledgements.html/')">Acknoledgements</a>
href="javascript:require('electron').shell.openExternal('https://wnr.scris.top/acknoledgements.html')">Acknoledgements</a>
</p>
<hr />
<p class="extreme-small">
Expand Down
23 changes: 21 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@
<input name="title" id="title" type="text" class="small" maxlength="11" /><br /><br />
<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 />
class="work lead" autofocus required /><input id="focus-work-set" class="focuscheck" type="checkbox"
onchange="focusworkset()" /><span class="focuser extreme-small work">
<script>document.write(i18n.__('focusmode1') + "<br />" + i18n.__('focusmode2'))</script></span>
</a><br /><br />
<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 />
class="rest lead" required /><input id="focus-rest-set" class="focuscheck" type="checkbox"
onchange="fullscreenset()" /><span class="focuser extreme-small rest">
<script>document.write(i18n.__('focusmode1') + "<br />" + i18n.__('focusmode2'))</script>
</span><br /><br />
<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 />
Expand All @@ -95,6 +101,7 @@
$('#rest-time').attr('title', i18n.__('resttime'));
$('#loop').attr('title', i18n.__('loop'));
$('#note').attr('title', i18n.__('note'));
$(".focuscheck").attr('title', i18n.__('fullscreentip'));
</script>
</div>
<div id="allsum" class="small font-weight-bold text-black-50">
Expand Down Expand Up @@ -134,6 +141,18 @@
$("#to-num-min").html("--");
}
}
if (store.get("fullscreen") == true) document.getElementById("focus-rest-set").checked = true;
else document.getElementById("focus-rest-set").checked = false;
function fullscreenset() {
if (document.getElementById("focus-rest-set").checked == true) store.set("fullscreen", true);
else store.set("fullscreen", false);
}
if (store.get("fullscreen-work") == true) document.getElementById("focus-work-set").checked = true;
else document.getElementById("focus-work-set").checked = false;
function focusworkset() {
if (document.getElementById("focus-work-set").checked == true) store.set("fullscreen-work", true);
else store.set("fullscreen-work", false);
}
</script>
</body>

Expand Down
12 changes: 8 additions & 4 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"winhider": "Hide the window to system tray",
"minimizer": "Minimize to taskbar",
"title": "please enter a title",
"worktime": "work for (minutes)",
"resttime": "then rest for (minutes)",
"worktime": "1. work for (minutes)",
"resttime": "2. rest for (minutes)",
"loop": "loop for (times)",
"note": "notes",
"tip": "Press Enter to submit.",
Expand Down Expand Up @@ -69,7 +69,7 @@
"autostart": "Start up with system: ",
"autotip": "If it is enabled, then every time your system starts, wnr starts.",
"fullscreenrest": "Fullscreen rest time: ",
"fullscreentip": "If it is enabled, when it's rest time, wnr will enter full-screen mode to prevent you from using computer.",
"fullscreentip": "If it is enabled, wnr will enter full-screen mode to prevent you from using computer.",
"autocheck": "Auto check for update: ",
"checktip": "If it is enabled, wnr will automatically check for update (every day).",
"otherthings": "Other Things",
Expand Down Expand Up @@ -108,5 +108,9 @@
"1minmsg": "Only a few amount of time left! ",
"dothings": "Options",
"tourguide": "Tourguide",
"about": "About wnr"
"about": "About wnr",
"focusmode1": "Full",
"focusmode2": "screen",
"wrongfolder": "Not in Applications folder",
"wrongfoldertip": "To use wnr in a convenient way, please move wnr to the system's Applications folder."
}
10 changes: 7 additions & 3 deletions locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"minimizer": "最小化至任务栏",
"title": "任务名称是什么?",
"worktime": "先工作多少分钟?",
"resttime": "然后再休息多少分钟",
"resttime": "再休息多少分钟",
"loop": "循环几次?",
"note": "还有什么想记的吗?",
"tip": "输入各个项目,然后按Enter键开始计时器",
Expand Down Expand Up @@ -69,7 +69,7 @@
"autostart": "开机自启设置:",
"autotip": "是否要让wnr开机时自动启动?",
"fullscreenrest": "专心休息设置:",
"fullscreentip": "如果你在休息时,还总是要看电脑,不妨开启专心休息模式(全屏休息模式)试一下?",
"fullscreentip": "如果你在休息或做别的事情的时候,还总是要看电脑,不妨开启专心模式(全屏模式)试一下?",
"autocheck": "自动更新设置:",
"checktip": "是否要wnr每天自动检测更新(如果联网)?如果有更新,将会提示您。",
"otherthings": "其他设置",
Expand Down Expand Up @@ -108,5 +108,9 @@
"1minmsg": "这一段时间只剩下1分钟了,好好规划一下暂时的收尾工作吧!",
"dothings": "操作",
"tourguide": "导览",
"about": "关于"
"about": "关于",
"focusmode1": "全屏",
"focusmode2": "专心",
"wrongfolder": "当前应用并不在应用程序文件夹中",
"wrongfoldertip": "把应用移到系统的应用程序文件夹中可以更方便地使用wnr。"
}
175 changes: 122 additions & 53 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function createWindow() {
height: 336,
frame: false,
resizable: false,
maximizable: false,
show: false,
hasShadow: true,
webPreferences: { nodeIntegration: true },
Expand Down Expand Up @@ -113,6 +114,19 @@ app.on('ready', () => {
if (tourWin != null) tourWin.isVisible() ? tourWin.hide() : tourWin.show();
})

if (process.platform == "darwin") {
if (!app.isInApplicationsFolder()) {
notifier.notify(
{
title: i18n.__('wrongfolder'),
message: i18n.__('wrongfoldertip'),
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
}
);
}
}

if (process.platform == "win32") tray = new Tray(path.join(__dirname, '\\res\\icons\\iconWin.ico'));
else if (process.platform != "darwin") tray = new Tray(path.join(__dirname, '\\res\\icons\\wnrIcon.png'));
contextMenu = Menu.buildFromTemplate([
Expand Down Expand Up @@ -163,64 +177,101 @@ app.on('ready', () => {
win.isVisible() ? win.hide() : win.show();
if (settingsWin != null) settingsWin.isVisible() ? settingsWin.hide() : settingsWin.show();
if (aboutWin != null) aboutWin.isVisible() ? aboutWin.hide() : aboutWin.show();
if (tourWin != null) tourWin.isVisible() ? tourWin.hide() : tourWin.show()
if (tourWin != null) tourWin.isVisible() ? tourWin.hide() : tourWin.show();
});//托盘菜单
}

if (process.platform === 'darwin') {
var template = [{
label: 'wnr',
submenu: [{
label: i18n.__('quit'),
accelerator: 'CmdOrCtrl+Q',
click: function () {
app.quit();
}
}]
}, {
label: i18n.__('dothings'),
submenu: [{
label: i18n.__('settings'),
click: function () {
settings();
}
}, {
label: i18n.__('tourguide'),
click: function () {
tourguide();
}
}, {
label: i18n.__('about'),
click: function () {
about();
}
}, {
type: 'separator'
}, {
label: i18n.__('website'),
click: function () {
shell.openExternal('https://wnr.scris.top/');
}
}, {
label: i18n.__('helppage'),
click: function () {
shell.openExternal('https://wnr.scris.top/help.html');
}
}, {
label: i18n.__('github'),
click: function () {
shell.openExternal('https://github.com/RoderickQiu/wnr/');
}
}]
}];
var osxMenu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(osxMenu);
app.dock.setMenu(osxMenu)
}// 应付macOS的顶栏空缺

macOSSolution(false)

})

function macOSSolution(isFullScreen) {
if (app.isReady()) {
if (process.platform === 'darwin') {
if (!isFullScreen)
var template = [{
label: 'wnr',
submenu: [{
label: i18n.__('quit'),
accelerator: 'CmdOrCtrl+Q',
click: function () {
app.quit();
}
}]
}, {
label: i18n.__('dothings'),
submenu: [{
label: i18n.__('settings'),
click: function () {
settings();
}
}, {
label: i18n.__('tourguide'),
click: function () {
tourguide();
}
}, {
label: i18n.__('about'),
click: function () {
about();
}
}, {
type: 'separator'
}, {
label: i18n.__('website'),
click: function () {
shell.openExternal('https://wnr.scris.top/');
}
}, {
label: i18n.__('helppage'),
click: function () {
shell.openExternal('https://wnr.scris.top/help.html');
}
}, {
label: i18n.__('github'),
click: function () {
shell.openExternal('https://github.com/RoderickQiu/wnr/');
}
}]
}];
else
var template = [{
label: 'wnr',
submenu: [{
label: i18n.__('quit'),
enabled: false
}]
}, {
label: i18n.__('dothings'),
submenu: [{
label: i18n.__('settings'),
enabled: false
}, {
label: i18n.__('tourguide'),
enabled: false
}, {
label: i18n.__('about'),
enabled: false
}, {
type: 'separator'
}, {
label: i18n.__('website'),
enabled: false
}, {
label: i18n.__('helppage'),
enabled: false
}, {
label: i18n.__('github'),
enabled: false
}]
}];
var osxMenu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(osxMenu);
app.dock.setMenu(osxMenu)
}// 应付macOS的顶栏空缺
}
}

app.on('activate', () => {
// 在macOS上,当单击dock图标并且没有其他窗口打开时,
// 通常在应用程序中重新创建一个窗口。
Expand All @@ -229,6 +280,12 @@ app.on('activate', () => {
}
})

ipcMain.on('focus-first', function () {
if (store.get("top") != true) win.setAlwaysOnTop(true);//全屏时恒定最上层
win.setFullScreen(true);
macOSSolution(true)
})

ipcMain.on('warninggiver-workend', function () {
if (win != null) {
win.show();
Expand All @@ -238,6 +295,11 @@ ipcMain.on('warninggiver-workend', function () {
if (store.get("fullscreen") == true) {
if (store.get("top") != true) win.setAlwaysOnTop(true);//全屏时恒定最上层
win.setFullScreen(true);
macOSSolution(true);
} else {
if (store.get("top") != true) win.setAlwaysOnTop(false);//取消不需要的恒定最上层
win.setFullScreen(false);
macOSSolution(false);
}
setTimeout(function () {
dialog.showMessageBox(win, {
Expand All @@ -255,9 +317,14 @@ ipcMain.on('warninggiver-restend', function () {
if (win != null) {
if (!win.isVisible()) win.show();
win.flashFrame(true);
if (store.get("fullscreen") == true) {
if (store.get("fullscreen-work") == true) {
if (store.get("top") != true) win.setAlwaysOnTop(true);//全屏时恒定最上层
win.setFullScreen(true);
macOSSolution(true);
} else {
if (store.get("top") != true) win.setAlwaysOnTop(false);//取消不需要的恒定最上层
win.setFullScreen(false);
macOSSolution(false);
}
setTimeout(function () {
dialog.showMessageBox(win, {
Expand All @@ -278,6 +345,7 @@ ipcMain.on('warninggiver-allend', function () {
if (store.get("fullscreen") == true) {
if (store.get("top") != true) win.setAlwaysOnTop(false);//取消不需要的恒定最上层
win.setFullScreen(false);
macOSSolution(false);
}
setTimeout(function () {
dialog.showMessageBox(win, {
Expand Down Expand Up @@ -442,6 +510,7 @@ ipcMain.on("timer-win", function (event, message) {
if (tray != null) {
contextMenu.items[2].enabled = true;
}

globalShortcut.register('CommandOrControl+Shift+Alt+' + store.get('hotkey2'), () => {
win.webContents.send('startorstop');
})
Expand Down
Binary file added res/icons/check-work.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cd441aa

Please sign in to comment.