Skip to content

Commit

Permalink
p3x-robot sunday release 2018-5-5 18:48:48
Browse files Browse the repository at this point in the history
  • Loading branch information
p3x-robot committed May 5, 2018
1 parent 62bfde2 commit f175d72
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 57 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -6,7 +6,7 @@



# 📚 P3X Onenote Linux v1.3.12-501
# 📚 P3X Onenote Linux v1.3.14-510

This is an open-source project. Star this repository if you like it, or even donate! Thank you so much! :)

Expand Down Expand Up @@ -143,7 +143,7 @@ https://github.com/patrikx3/onenote/issues/14

---

[**P3X-ONENOTE**](https://pages.corifeus.com/onenote) Build v1.3.12-501
[**P3X-ONENOTE**](https://pages.corifeus.com/onenote) Build v1.3.14-510

[![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact)

Expand Down
2 changes: 1 addition & 1 deletion artifacts/npm.md
Expand Up @@ -27,7 +27,7 @@ Though, I am using it, but some distros are different and I only use Linux Mint

---

[**P3X-ONENOTE**](https://pages.corifeus.com/onenote) Build v1.3.12-501
[**P3X-ONENOTE**](https://pages.corifeus.com/onenote) Build v1.3.14-510

[![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact)

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "p3x-onenote",
"version": "1.3.12-501",
"version": "1.3.14-510",
"description": "📚 P3X Onenote Linux",
"main": "src/electron/app.js",
"corifeus": {
Expand Down
18 changes: 11 additions & 7 deletions src/electron/app.js
Expand Up @@ -12,12 +12,16 @@ global.p3x = {
disableHide: true,
iconFile: `${__dirname}/asset/256x256.png`,
tray: undefined,
mainWindow: undefined,
window: {
onenote: undefined,
},
action: undefined,
menus: undefined,
createMenu: undefined,
mainMenu: undefined,
setVisible: undefined,
createWindow: undefined,
createWindow: {
onenote: undefined,
},
}
}

Expand All @@ -31,16 +35,16 @@ if (global.p3x.onenote.disableHide === undefined) {
// loading
global.p3x.onenote.action = require('./main/action');
global.p3x.onenote.menus = require('./main/menus');
global.p3x.onenote.createMenu = require('./main/create/menu')
global.p3x.onenote.createTray = require('./main/create/tray')
global.p3x.onenote.mainMenu = require('./main/create/menu')
global.p3x.onenote.mainTray = require('./main/create/tray')
global.p3x.onenote.setVisible = require('./main/set-visible')
global.p3x.onenote.createWindow = require('./main/create/window')
global.p3x.onenote.createWindow.onenote = require('./main/create/window/onenote')


/*
const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) => {
global.p3x.onenote.setVisible(true);
global.p3x.onenote.mainWindow.webContents.reload();
global.p3x.onenote.window.onenote.webContents.reload();
})
if (isSecondInstance) {
Expand Down
14 changes: 7 additions & 7 deletions src/electron/main/action.js
Expand Up @@ -4,27 +4,27 @@ const action = {
setProxy: require('./actions/set-proxy'),

restart: () => {
global.p3x.onenote.mainWindow.webContents.send('p3x-onenote-action', {
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'restart'
})
},
home: () => {
global.p3x.onenote.mainWindow.show();
global.p3x.onenote.mainWindow.webContents.send('p3x-onenote-action', {
global.p3x.onenote.window.onenote.show();
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'home'
})
},
corporate: () => {
global.p3x.onenote.mainWindow.show();
global.p3x.onenote.mainWindow.webContents.send('p3x-onenote-action', {
global.p3x.onenote.window.onenote.show();
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'corporate'
})
},
toggleVisible: () => {
if (global.p3x.onenote.mainWindow === undefined) {
if (global.p3x.onenote.window.onenote === undefined) {
return;
}
global.p3x.onenote.setVisible(!global.p3x.onenote.mainWindow.isVisible());
global.p3x.onenote.setVisible(!global.p3x.onenote.window.onenote.isVisible());
},
quit: function () {
app.isQuiting = true;
Expand Down
7 changes: 1 addition & 6 deletions src/electron/main/actions/set-proxy.js
@@ -1,10 +1,5 @@
let mainWindow;
const setProxy = () => {
if (mainWindow === undefined) {
mainWindow = global.p3x.onenote.mainWindow;
}

mainWindow.webContents.send('p3x-onenote-action-set-proxy')
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action-set-proxy')
}

module.exports = setProxy;
6 changes: 3 additions & 3 deletions src/electron/main/app-events.js
@@ -1,6 +1,6 @@
const { app } = require('electron')

app.on('ready', global.p3x.onenote.createWindow);
app.on('ready', global.p3x.onenote.createWindow.onenote);

app.on('window-all-closed', function () {

Expand All @@ -10,7 +10,7 @@ app.on('window-all-closed', function () {
});

app.on('activate', function () {
if (global.p3x.onenote.mainWindow === null) {
global.p3x.onenote.createWindow();
if (global.p3x.onenote.window.onenote === null) {
global.p3x.onenote.createWindow.onenote();
}
});
12 changes: 6 additions & 6 deletions src/electron/main/create/menu.js
Expand Up @@ -2,9 +2,9 @@ const { dialog, Menu } = require('electron')
const menus = require('../menus');
const action = require('../action');

const createTray = require('./tray')
const mainTray = require('./tray')

function createMenu() {
function mainMenu() {

const minimizationBehaviorLabel = !global.p3x.onenote.disableHide ? global.p3x.onenote.lang.label.disableHide.no : global.p3x.onenote.lang.label.disableHide.yes

Expand All @@ -24,14 +24,14 @@ function createMenu() {

const message = global.p3x.onenote.disableHide ? global.p3x.onenote.lang.label.disableHide.message.yes : global.p3x.onenote.lang.label.disableHide.message.no

dialog.showMessageBox(global.p3x.onenote.mainWindow, {
dialog.showMessageBox(global.p3x.onenote.window.onenote, {
type: 'info',
title: global.p3x.onenote.lang.dialog.minimizationBehavior.title,
message: message,
buttons: [ global.p3x.onenote.lang.button.ok ]
})
createMenu()
createTray()
mainMenu()
mainTray()
}
},
{
Expand Down Expand Up @@ -103,4 +103,4 @@ function createMenu() {
Menu.setApplicationMenu(menu)
}

module.exports = createMenu;
module.exports = mainMenu;
4 changes: 2 additions & 2 deletions src/electron/main/create/tray.js
Expand Up @@ -3,7 +3,7 @@ const { Menu, Tray } = require('electron')
const menus = require('../menus');
const action = require('../action');

function createTray() {
function mainTray() {
if (global.p3x.onenote.tray === undefined) {
global.p3x.onenote.tray = new Tray(global.p3x.onenote.iconFile)
global.p3x.onenote.tray.setToolTip(global.p3x.onenote.title)
Expand All @@ -13,4 +13,4 @@ function createTray() {
global.p3x.onenote.tray.setContextMenu(contextMenu)
}

module.exports = createTray;
module.exports = mainTray;
Expand Up @@ -2,39 +2,39 @@ const { BrowserWindow, app } = require('electron');

function createWindow() {

global.p3x.onenote.mainWindow = new BrowserWindow({
global.p3x.onenote.window.onenote = new BrowserWindow({
icon: global.p3x.onenote.iconFile,
toolbar: false,
title: global.p3x.onenote.title,
});

global.p3x.onenote.setVisible(true);

global.p3x.onenote.mainWindow.loadURL(`file://${__dirname}/../../window/onenote/index.html`);
global.p3x.onenote.window.onenote.loadURL(`file://${__dirname}/../../../window/onenote/index.html`);

global.p3x.onenote.mainWindow.on('minimize', function (event) {
global.p3x.onenote.window.onenote.on('minimize', function (event) {
event.preventDefault()
global.p3x.onenote.setVisible(false, true);
});

global.p3x.onenote.mainWindow.on('close', function (event) {
global.p3x.onenote.window.onenote.on('close', function (event) {
if (!app.isQuiting) {
event.preventDefault()
global.p3x.onenote.setVisible(false);
}
return false;
});

global.p3x.onenote.mainWindow.on('focus', () => {
global.p3x.onenote.mainWindow.webContents.send('p3x-onenote-action', {
global.p3x.onenote.window.onenote.on('focus', () => {
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'focus'
})
})


const windowBounds = global.p3x.onenote.conf.get('window-bounds');
if (windowBounds !== null && windowBounds !== undefined) {
global.p3x.onenote.mainWindow.setBounds(windowBounds);
global.p3x.onenote.window.onenote.setBounds(windowBounds);
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/electron/main/ipc-main.js
Expand Up @@ -2,11 +2,11 @@ const { ipcMain } = require('electron')

ipcMain.on('did-finish-load', function () {
const toWebview = global.p3x.onenote.conf.get('webview-onenote');
global.p3x.onenote.mainWindow.webContents.send('p3x-onenote-onload-user', toWebview);
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-onload-user', toWebview);
});

ipcMain.on('p3x-onenote-save', function (event, data) {
// console.log('p3x-onenote-save', data)
global.p3x.onenote.conf.set('webview-onenote', data);
global.p3x.onenote.conf.set('window-bounds', global.p3x.onenote.mainWindow.getBounds());
global.p3x.onenote.conf.set('window-bounds', global.p3x.onenote.window.onenote.getBounds());
})
4 changes: 2 additions & 2 deletions src/electron/main/menus.js
Expand Up @@ -4,8 +4,8 @@ const menus = {
default: () => {

let visible = false;
if (global.p3x.onenote.mainWindow !== undefined) {
visible = global.p3x.onenote.mainWindow.isVisible() ? true : false;
if (global.p3x.onenote.window.onenote !== undefined) {
visible = global.p3x.onenote.window.onenote.isVisible() ? true : false;
}

let menus = [
Expand Down
16 changes: 8 additions & 8 deletions src/electron/main/set-visible.js
Expand Up @@ -12,25 +12,25 @@ function setVisible(visible = true, force = false) {
}
*/

if (global.p3x.onenote.mainWindow !== undefined) {
if (global.p3x.onenote.window.onenote !== undefined) {

if (visible || (global.p3x.onenote.mainWindow.isMinimized() && !force)) {
if (visible || (global.p3x.onenote.window.onenote.isMinimized() && !force)) {
visible = true;
global.p3x.onenote.mainWindow.show();
global.p3x.onenote.window.onenote.show();
} else {
global.p3x.onenote.mainWindow.minimize()
global.p3x.onenote.window.onenote.minimize()
if (!global.p3x.onenote.disableHide) {
global.p3x.onenote.mainWindow.hide();
global.p3x.onenote.window.onenote.hide();
}
}
}
global.p3x.onenote.conf.set('visible', visible);
global.p3x.onenote.createMenu();
global.p3x.onenote.createTray()
global.p3x.onenote.mainMenu();
global.p3x.onenote.mainTray()


if (visible || force) {
global.p3x.onenote.mainWindow.webContents.send('p3x-onenote-action', {
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'focus'
})
}
Expand Down
13 changes: 13 additions & 0 deletions src/electron/window/onenote/action/load-proxy.js
@@ -0,0 +1,13 @@
const loadProxy = () => {
//console.log('load proxy');
const webview = global.p3x.onenote.webview;
const session = webview.getWebContents().session;
const proxy = global.p3x.onenote.data.proxy.trim();
session.setProxy({
proxyRules: proxy
}, () => {
webview.reload();
})
}

module.exports = loadProxy;
3 changes: 2 additions & 1 deletion src/electron/window/onenote/action/set-proxy.js
Expand Up @@ -19,8 +19,9 @@ module.exports = (data) => {
callback: function (value) {
try {
global.p3x.onenote.data.proxy = value;
console.log('set-proxy', global.p3x.onenote.data.proxy)
//console.log('set-proxy', global.p3x.onenote.data.proxy)
ipcRenderer.send('p3x-onenote-save', global.p3x.onenote.data);
require('./load-proxy')()
} catch(e) {
console.error(e)
}
Expand Down
6 changes: 5 additions & 1 deletion src/electron/window/onenote/ipc/handler.js
Expand Up @@ -10,13 +10,17 @@ const handler = (options) => {
if (data !== null) {
global.p3x.onenote.data = data;
}
console.log('p3x-onenote-onload-user', data)

//console.log('p3x-onenote-onload-user', data)

if (typeof(global.p3x.onenote.data) === 'object' && global.p3x.onenote.data.hasOwnProperty('url') && global.p3x.onenote.data.url !== 'about:blank') {
webview.src = global.p3x.onenote.data.url;
} else {
webview.src = 'https://www.onenote.com/notebooks'
}
if (global.p3x.onenote.data.proxy.trim() !== '') {
require('../action/load-proxy')();
}
})

ipcRenderer.on('p3x-onenote-action', function(event, data) {
Expand Down
2 changes: 1 addition & 1 deletion src/translation/english/index.js
@@ -1,5 +1,5 @@
const translation = {
title: 'P3X OneNote',
title: 'P3X Linux OneNote',
label: {
disableHide: {
yes: 'Enable hiding the main window',
Expand Down

0 comments on commit f175d72

Please sign in to comment.