From e47a1dee85ae502b84267fc59ecb7bd6d4a8d469 Mon Sep 17 00:00:00 2001 From: ownsterDev <56941965+ownsterDev@users.noreply.github.com> Date: Wed, 19 May 2021 11:00:57 -0400 Subject: [PATCH] ready for packaging --- README.md | 14 ++++++++++---- index.html | 4 +++- index.js | 21 ++++++++++++++++----- split.js | 9 ++++++++- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f8a2997..1f64f33 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,17 @@ Small password generator "utility" for Windows, Mac, & *possibly* Linux. -## Install +# Usage -No installer yet. +Simply start the app. It automatically generates a password on startup. However, it does not copy to clipboard. -## Reference +**To copy to clipboard**, simply click `Copy`. You should get a notification saying that it was copied. + +## "tray mode" + +Right-click the tray icon, then hover over `Password` a click `Generate new and copy`. That will generate a new password (cannot be seen until pasted) and copy it to clipboard. It will also send a notification. + +# Reference https://github.com/dwyl/english-words @@ -16,7 +22,7 @@ https://www.npmjs.com/package/hsimp https://www.tekuris.com/products/arcana/ -## Building from source +# Building from source ```sh npm install diff --git a/index.html b/index.html index b184263..4d3cec8 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,9 @@

Nothing to see here.

-

Automatically copies to clipboard.

+ + +

© Owen Magill 2021

\ No newline at end of file diff --git a/index.js b/index.js index 9177997..0daa052 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, Tray, Menu, clipboard } = require('electron') +const { app, BrowserWindow, Tray, Menu, clipboard, shell, Notification } = require('electron') const fs = require('fs') const path = require('path') @@ -35,12 +35,14 @@ function createWindow() { win.hide() } }, + { + type: 'separator' + }, { label: 'Quit PPG', type: 'normal', - role: 'quit', click() { - app.quit() + app.exit() } } ] @@ -66,6 +68,9 @@ function createWindow() { win.webContents.openDevTools() } }, + { + type: 'separator' + }, { label: 'New window', type: 'normal', @@ -81,7 +86,9 @@ function createWindow() { type: 'submenu', submenu: [ { - label: 'GitHub' + label: 'GitHub', click() { + shell.openExternal('https://github.com/cmexdev/ppg') + } } ] } @@ -131,8 +138,12 @@ app.on('ready', () => { { label: 'Password', type: 'submenu', submenu: [ { - label: 'New', type: 'normal', click() { + label: 'Generate new and copy', type: 'normal', click() { clipboard.writeText(genPassword()) + new Notification({ + title: 'PPG copied to clipboard!', + body: 'Your new password was copied to your clipboard.', + }).show() } } ] diff --git a/split.js b/split.js index 50bda37..2f9c9d0 100644 --- a/split.js +++ b/split.js @@ -8,9 +8,16 @@ window.addEventListener('DOMContentLoaded', () => { document.getElementById('gennew').addEventListener('click', () => { var val = gen() document.getElementById('gen').value = val[0] - clipboard.writeText(val[0]) document.getElementById('time').textContent = 'It\'d take a computer around ' + val[1].time + ' to crack this password. You\'re all set.' }) + + document.getElementById('gencopy').addEventListener('click', () => { + clipboard.writeText(document.getElementById('gen').value) + + new window.Notification('PPG copied to clipboard!', { + body: 'Your new password was copied to your clipboard.' + }) + }) }) function gen() {