Skip to content

Commit 41c116c

Browse files
committed
First release.
0 parents  commit 41c116c

File tree

10 files changed

+338
-0
lines changed

10 files changed

+338
-0
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/dist/
2+
/node_modules/
3+
4+
yarn.lock

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 JayPY Code
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Eventer
2+
A simple widgets for Linux / MacOS / MS Windows. You want a countdown timer for the day(s) left of your event.
3+
For example: Next week, you'll go to a party at 6:00 PM. So you have a config file ( You can open and edit it with pressing F3 when "Eventer" is open ) and you'll have a JSON file and edit value of "Date" to your date and time. Today is 2020/02/23 and you should set for 2020/03/01 and a space and write 18:00. So you want go to a party, You must set a title for the event, like "BFF Party" and done. Back to Eventer and press F5 to read and refresh that config file in your system.
4+
5+
Your config file must be like:
6+
```
7+
{ "date": "2020/03/01 18:00", "title": "BFF Party", "background": "rgba(0, 0, 0, 0.35)", "color": "white" }
8+
```
9+
10+
11+
# Colours in Eventer
12+
You can make a beautiful window on your screen ( Playing with colours ). Again back to your config file with Pressing F3 when Eventer is open and you'll see two keys "background" and "color". You can edit both of them and write rgb, rgba, hex or colour name and etc. Then press F5 to refresh your config and see your changes.
13+
14+
Like:
15+
```
16+
{ "date": "2020/03/01 18:00", "title": "BFF Party", "background": "back", "color": "#fff" }
17+
```
18+
19+
# Build your own Eventer
20+
You know how much is size of released setup, More then 50MB and it's hard to upload and downlod but it's easy to build it. You can build it with *npm* and edit your app name, app icon and more things.
21+
22+
1) Download and install dependencies:
23+
```
24+
# npm i
25+
or
26+
# yarn install
27+
```
28+
2) And build it:
29+
```
30+
# npm build
31+
or
32+
# yarn build
33+
```

Diff for: app.js

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
const { app, BrowserWindow, Tray, ipcMain } = require('electron'),
2+
path = require('path');
3+
4+
let win = null;
5+
6+
function createWindow() {
7+
win = new BrowserWindow({
8+
maxWidth: 200,
9+
maxHeight: 200,
10+
frame: false,
11+
fullscreen: false,
12+
transparent: true,
13+
fullscreenable: false,
14+
alwaysOnTop: true,
15+
maximizable: false,
16+
webPreferences: {
17+
nodeIntegration: true
18+
}
19+
})
20+
21+
win.center();
22+
win.loadURL(path.join(__dirname, 'res', 'app.html'))
23+
24+
/*
25+
26+
let tray = new Tray(path.join(__dirname, 'res', 'event.png'));
27+
tray.on('click', ()=>{
28+
if(win.isVisible()) {
29+
win.hide();
30+
} else {
31+
win.show();
32+
}
33+
})
34+
35+
*/
36+
37+
38+
app.setLoginItemSettings({
39+
openAtLogin: true,
40+
path: app.getPath('exe')
41+
})
42+
}
43+
44+
function createHelp() {
45+
help = new BrowserWindow({
46+
width: 300,
47+
height: 310,
48+
fullscreen: false,
49+
fullscreenable: false,
50+
alwaysOnTop: true,
51+
maximizable: false,
52+
parent: win,
53+
webPreferences: {
54+
nodeIntegration: true
55+
}
56+
})
57+
58+
help.center()
59+
help.removeMenu()
60+
help.loadURL(path.join(__dirname, 'res', 'help.html'))
61+
}
62+
63+
app.whenReady().then(createWindow)
64+
65+
66+
ipcMain.on('f1', event=>{
67+
createHelp();
68+
event.returnValue = '';
69+
});

Diff for: package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "Eventer",
3+
"version": "0.0.1",
4+
"description": "",
5+
"main": "app.js",
6+
"scripts": {
7+
"start": "electron .",
8+
"build": "electron-builder"
9+
},
10+
"keywords": [],
11+
"author": "JayPY Code <jaypy.code@gmail.com>",
12+
"license": "MIT",
13+
"devDependencies": {
14+
"electron": "^8.0.1",
15+
"electron-builder": "^22.3.2"
16+
}
17+
}

Diff for: res/app.css

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
:root {
2+
--backgound: rgba(0, 0, 0, 0.35);
3+
--colour: white;
4+
}
5+
6+
*{
7+
user-select: none;
8+
overflow: hidden;
9+
}
10+
11+
body{
12+
margin: 0;
13+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
14+
}
15+
16+
div.mover{
17+
position: fixed;
18+
top: 0;
19+
left: 0;
20+
right: 0;
21+
bottom: 0;
22+
23+
-webkit-app-region: drag;
24+
}
25+
26+
div.container{
27+
width: 100vw;
28+
height: 100vh;
29+
30+
background-color: var(--backgound);
31+
color: var(--colour);
32+
border-radius: 0.4rem;
33+
34+
display: flex;
35+
text-align: center;
36+
justify-content: center;
37+
flex-direction: column;
38+
}
39+
40+
div.container div.day{
41+
font-size: 60px;
42+
}
43+
44+
div.container div.title{
45+
margin-top: 30px;
46+
}
47+
48+
@media only screen and (max-width: 100px) {
49+
div.container div.title,
50+
div.container div.text {
51+
display: none;
52+
}
53+
54+
div.container div.day{
55+
font-size: 45px;
56+
}
57+
}

Diff for: res/app.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link rel="stylesheet" href="./app.css">
7+
</head>
8+
<body>
9+
<div class="container">
10+
<div class="day" id="day"></div>
11+
<div class="text" id="text"></div>
12+
<div class="title" id="title"></div>
13+
</div>
14+
<div class="mover"></div>
15+
<script src="./app.js"></script>
16+
</body>
17+
</html>

Diff for: res/app.js

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
const electron = require('electron'),
2+
fs = require('fs'),
3+
path = require('path');
4+
5+
let
6+
day = document.getElementById('day'),
7+
text = document.getElementById('text'),
8+
title = document.getElementById('title');
9+
10+
let
11+
remote = electron.remote,
12+
app = remote.app,
13+
win = remote.getCurrentWindow(),
14+
appData = remote.app.getPath('appData'),
15+
Path = path.join(appData, 'Eventer', '.eventer.json');
16+
17+
let timeout = null;
18+
19+
function setDate(Time="", Title="Untitled"){
20+
let end = new Date(Time),
21+
now = new Date(),
22+
tomorrow = new Date(
23+
`${now.getFullYear()}/
24+
${now.getMonth() + 1}/
25+
${now.getDate()}
26+
${end.getHours()}:${end.getMinutes()}`
27+
);
28+
29+
if(tomorrow.getTime() - now.getTime() <= 0) {
30+
tomorrow.setDate(tomorrow.getDate() + 1);
31+
}
32+
33+
34+
let time = end.getTime() - now.getTime(),
35+
days = time / (1000 * 3600 * 24);
36+
37+
days = parseInt(days) || 0;
38+
39+
40+
switch (days) {
41+
case 0:
42+
day.innerText = 'Ended !';
43+
break;
44+
case 1:
45+
day.innerText = 'Today';
46+
default:
47+
day.innerText = days;
48+
text.innerText = `day${days <= 1?'':'s'} left`;
49+
timeout = setTimeout(() => {
50+
refresh();
51+
}, tomorrow.getTime());
52+
}
53+
title.innerText = Title;
54+
}
55+
56+
function setTheme(background='rgba(0, 0, 0, 0.35)', colour='white'){
57+
document.documentElement.style.setProperty('--background', background);
58+
document.documentElement.style.setProperty('--color', colour);
59+
}
60+
61+
function refresh(){
62+
clearTimeout(timeout);
63+
if(fs.existsSync(Path)){
64+
let data = JSON.parse(fs.readFileSync(Path).toString());
65+
setDate(data.date, data.title);
66+
setTheme(data.background, data.color);
67+
} else {
68+
fs.writeFileSync(Path, `{ "date": "", "title": "", "background": "rgba(0, 0, 0, 0.35)", "color": "white" }`);
69+
setDate();
70+
}
71+
}
72+
73+
window.onload = ()=>{
74+
refresh();
75+
}
76+
77+
window.addEventListener('keyup', event=>{
78+
event.preventDefault();
79+
80+
switch (event.keyCode) {
81+
case 112:
82+
electron.ipcRenderer.sendSync('f1', null);
83+
break;
84+
case 113:
85+
if(win.getSize()[0] == 200) {
86+
win.setSize(100, 100);
87+
} else {
88+
win.setSize(200, 200);
89+
}
90+
break;
91+
case 114:
92+
electron.shell.openItem(Path);
93+
break;
94+
case 115:
95+
app.exit();
96+
break;
97+
case 116:
98+
refresh();
99+
break;
100+
default:
101+
break;
102+
}
103+
})

Diff for: res/event.png

6.6 KB
Loading

Diff for: res/help.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Eventer - Help</title>
7+
<link rel="stylesheet" href="./app.css">
8+
</head>
9+
<body style="padding: 0 10px;">
10+
<h2>Help <span style="font-size: 0.8rem; font-weight: normal;">keys shortcut</span></h2>
11+
<p><strong>F1</strong> - <span>Show this help winodw again.</span></p>
12+
<p><strong>F2</strong> - <span>Toggle Eventer small or big.</span></p>
13+
<p><strong>F3</strong> - <span>Open config file.</span></p>
14+
<p><strong>F4</strong> - <span>Exit from Eventer.</span></p>
15+
<p><strong>F5</strong> - <span>Read and refresh config file.</span></p>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)