mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-04 05:53:21 +00:00 
			
		
		
		
	Merge pull request #53 from jedahan/fix-npm-test
Fix npm-test (xo code style)
This commit is contained in:
		@@ -1,27 +1,28 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
const path = require('path');
 | 
					const path = require('path');
 | 
				
			||||||
const electron = require('electron');
 | 
					const electron = require('electron');
 | 
				
			||||||
const {app, shell} = require('electron');
 | 
					const {app} = require('electron');
 | 
				
			||||||
const electronLocalshortcut = require('electron-localshortcut');
 | 
					const electronLocalshortcut = require('electron-localshortcut');
 | 
				
			||||||
const ipc = require('electron').ipcMain;
 | 
					const ipc = require('electron').ipcMain;
 | 
				
			||||||
const Configstore = require('configstore');
 | 
					const Configstore = require('configstore');
 | 
				
			||||||
const JsonDB = require('node-json-db');
 | 
					const JsonDB = require('node-json-db');
 | 
				
			||||||
 | 
					const SpellChecker = require('simple-spellchecker');
 | 
				
			||||||
const tray = require('./tray');
 | 
					const tray = require('./tray');
 | 
				
			||||||
const appMenu = require('./menu');
 | 
					const appMenu = require('./menu');
 | 
				
			||||||
const link = require ('./link_helper');
 | 
					const link = require('./link-helper');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {linkIsInternal} = link;
 | 
					const {linkIsInternal} = link;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const db = new JsonDB("domain", true, true);
 | 
					const db = new JsonDB('domain', true, true);
 | 
				
			||||||
const data = db.getData("/");
 | 
					const data = db.getData('/');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// adds debug features like hotkeys for triggering dev tools and reload
 | 
					// adds debug features like hotkeys for triggering dev tools and reload
 | 
				
			||||||
require('electron-debug')();
 | 
					require('electron-debug')();
 | 
				
			||||||
require('electron-context-menu')();
 | 
					require('electron-context-menu')();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const conf = new Configstore("Zulip-Desktop");
 | 
					const conf = new Configstore('Zulip-Desktop');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// spellchecker enabled
 | 
					// spellchecker enabled
 | 
				
			||||||
const SpellChecker = require('simple-spellchecker');
 | 
					 | 
				
			||||||
let myDictionary = null;
 | 
					let myDictionary = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// prevent window being garbage collected
 | 
					// prevent window being garbage collected
 | 
				
			||||||
@@ -32,18 +33,16 @@ let targetLink;
 | 
				
			|||||||
const targetUrl = 'file://' + path.join(__dirname, '../renderer', 'index.html');
 | 
					const targetUrl = 'file://' + path.join(__dirname, '../renderer', 'index.html');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function checkWindowURL() {
 | 
					function checkWindowURL() {
 | 
				
			||||||
	if (data["domain"] !== undefined) {
 | 
						if (data.domain !== undefined) {
 | 
				
			||||||
		return data["domain"]
 | 
							return data.domain;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return targetLink
 | 
						return targetLink;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const APP_ICON = path.join(__dirname, '../resources', 'Icon');
 | 
					const APP_ICON = path.join(__dirname, '../resources', 'Icon');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const iconPath = () => {
 | 
					const iconPath = () => {
 | 
				
			||||||
  return process.platform === 'win32'
 | 
						return APP_ICON + (process.platform === 'win32' ? '.ico' : '.png');
 | 
				
			||||||
    ? APP_ICON + '.ico'
 | 
					 | 
				
			||||||
    : APP_ICON + '.png'
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function onClosed() {
 | 
					function onClosed() {
 | 
				
			||||||
@@ -53,7 +52,6 @@ function onClosed() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function updateDockBadge(title) {
 | 
					function updateDockBadge(title) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (title.indexOf('Zulip') === -1) {
 | 
						if (title.indexOf('Zulip') === -1) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -62,7 +60,7 @@ function updateDockBadge(title) {
 | 
				
			|||||||
	messageCount = messageCount ? Number(messageCount[1]) : 0;
 | 
						messageCount = messageCount ? Number(messageCount[1]) : 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (process.platform === 'darwin') {
 | 
						if (process.platform === 'darwin') {
 | 
				
			||||||
		app.setBadgeCount(messageCount)
 | 
							app.setBadgeCount(messageCount);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -88,49 +86,49 @@ function createMainWindow() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Let's save browser window position
 | 
						// Let's save browser window position
 | 
				
			||||||
	if (conf.get('x') || conf.get('y')) {
 | 
						if (conf.get('x') || conf.get('y')) {
 | 
				
			||||||
	  win.setPosition(conf.get('x'), conf.get('y'));
 | 
							win.setPosition(conf.get('x'), conf.get('y'));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (conf.get('maximize')) {
 | 
						if (conf.get('maximize')) {
 | 
				
			||||||
	  win.maximize();
 | 
							win.maximize();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Handle sizing events so we can persist them.
 | 
						// Handle sizing events so we can persist them.
 | 
				
			||||||
	win.on('maximize', function (event) {
 | 
						win.on('maximize', () => {
 | 
				
			||||||
	  conf.set('maximize', true);
 | 
							conf.set('maximize', true);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	win.on('unmaximize', function (event) {
 | 
						win.on('unmaximize', () => {
 | 
				
			||||||
	  conf.set('maximize', false);
 | 
							conf.set('maximize', false);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	win.on('resize', function (event) {
 | 
						win.on('resize', () => {
 | 
				
			||||||
	  var size = this.getSize();
 | 
							const size = this.getSize();
 | 
				
			||||||
	  conf.set({
 | 
							conf.set({
 | 
				
			||||||
	    width: size[0],
 | 
								width: size[0],
 | 
				
			||||||
	    height: size[1]
 | 
								height: size[1]
 | 
				
			||||||
	  });
 | 
							});
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// on osx it's 'moved'
 | 
						// on osx it's 'moved'
 | 
				
			||||||
	win.on('move', function (event) {
 | 
						win.on('move', () => {
 | 
				
			||||||
	  var pos = this.getPosition();
 | 
							const pos = this.getPosition();
 | 
				
			||||||
	  conf.set({
 | 
							conf.set({
 | 
				
			||||||
	    x: pos[0],
 | 
								x: pos[0],
 | 
				
			||||||
	    y: pos[1]
 | 
								y: pos[1]
 | 
				
			||||||
	  });
 | 
							});
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// stop page to update it's title
 | 
						// stop page to update it's title
 | 
				
			||||||
	win.on('page-title-updated', (e,title) => {
 | 
						win.on('page-title-updated', (e, title) => {
 | 
				
			||||||
	e.preventDefault();
 | 
							e.preventDefault();
 | 
				
			||||||
	updateDockBadge(title);
 | 
							updateDockBadge(title);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return win;
 | 
						return win;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO
 | 
					// TODO: fix certificate errors
 | 
				
			||||||
app.commandLine.appendSwitch('ignore-certificate-errors', 'true');
 | 
					app.commandLine.appendSwitch('ignore-certificate-errors', 'true');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.on('window-all-closed', () => {
 | 
					app.on('window-all-closed', () => {
 | 
				
			||||||
@@ -153,59 +151,57 @@ app.on('ready', () => {
 | 
				
			|||||||
	const page = mainWindow.webContents;
 | 
						const page = mainWindow.webContents;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Add spellcheck dictionary
 | 
						// Add spellcheck dictionary
 | 
				
			||||||
	SpellChecker.getDictionary("en-US", "./node_modules/simple-spellchecker/dict", function(err, result) {
 | 
						SpellChecker.getDictionary('en-US', './node_modules/simple-spellchecker/dict', (err, result) => {
 | 
				
			||||||
	    if(!err) {
 | 
							if (!err) {
 | 
				
			||||||
	        myDictionary = result;
 | 
								myDictionary = result;
 | 
				
			||||||
	    }
 | 
							}
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Define function for consult the dictionary.
 | 
						// Define function for consult the dictionary.
 | 
				
			||||||
	ipc.on('checkspell', function(event, word) {
 | 
						ipc.on('checkspell', (event, word) => {
 | 
				
			||||||
	    var res = null;
 | 
							if (myDictionary !== null && word !== null) {
 | 
				
			||||||
	    if(myDictionary != null && word != null) {
 | 
								event.returnValue = myDictionary.spellCheck(word);
 | 
				
			||||||
	        res = myDictionary.spellCheck(word);
 | 
							}
 | 
				
			||||||
	    }
 | 
					 | 
				
			||||||
	    event.returnValue = res;
 | 
					 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO - use global shortcut instead
 | 
						// TODO - use global shortcut instead
 | 
				
			||||||
	electronLocalshortcut.register(mainWindow, 'CommandOrControl+R', () => {
 | 
						electronLocalshortcut.register(mainWindow, 'CommandOrControl+R', () => {
 | 
				
			||||||
	   mainWindow.reload();
 | 
							mainWindow.reload();
 | 
				
			||||||
	 });
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	electronLocalshortcut.register(mainWindow, 'Alt+Left', () => {
 | 
						electronLocalshortcut.register(mainWindow, 'Alt+Left', () => {
 | 
				
			||||||
		if (page.canGoBack()) {
 | 
							if (page.canGoBack()) {
 | 
				
			||||||
			page.goBack();
 | 
								page.goBack();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	 });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    electronLocalshortcut.register(mainWindow, 'CommandOrControl+=', () => {
 | 
					 | 
				
			||||||
    	page.send('zoomIn');
 | 
					 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    electronLocalshortcut.register(mainWindow, 'CommandOrControl+-', () => {
 | 
						electronLocalshortcut.register(mainWindow, 'CommandOrControl+=', () => {
 | 
				
			||||||
		page.send('zoomOut');
 | 
							page.send('zoomIn');
 | 
				
			||||||
    });
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   	electronLocalshortcut.register(mainWindow, 'CommandOrControl+0', () => {
 | 
						electronLocalshortcut.register(mainWindow, 'CommandOrControl+-', () => {
 | 
				
			||||||
 | 
							page.send('zoomOut');
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						electronLocalshortcut.register(mainWindow, 'CommandOrControl+0', () => {
 | 
				
			||||||
		page.send('zoomActualSize');
 | 
							page.send('zoomActualSize');
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    page.on('new-window', (event, url) => {
 | 
						page.on('new-window', (event, url) => {
 | 
				
			||||||
        if (mainWindow.useDefaultWindowBehaviour) {
 | 
							if (mainWindow.useDefaultWindowBehaviour) {
 | 
				
			||||||
            mainWindow.useDefaultWindowBehaviour = false;
 | 
								mainWindow.useDefaultWindowBehaviour = false;
 | 
				
			||||||
            return;
 | 
								return;
 | 
				
			||||||
        }
 | 
							}
 | 
				
			||||||
        if (linkIsInternal(checkWindowURL(), url)) {
 | 
							if (linkIsInternal(checkWindowURL(), url)) {
 | 
				
			||||||
        	event.preventDefault();
 | 
								event.preventDefault();
 | 
				
			||||||
			return mainWindow.loadURL(url);
 | 
								return mainWindow.loadURL(url);
 | 
				
			||||||
        }
 | 
							}
 | 
				
			||||||
        event.preventDefault();
 | 
							event.preventDefault();
 | 
				
			||||||
        electron.shell.openExternal(url);
 | 
							electron.shell.openExternal(url);
 | 
				
			||||||
    });
 | 
						});
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ipc.on('new-domain', function (e, domain) {
 | 
					ipc.on('new-domain', (e, domain) => {
 | 
				
			||||||
	mainWindow.loadURL(domain);
 | 
						mainWindow.loadURL(domain);
 | 
				
			||||||
	targetLink = domain;
 | 
						targetLink = domain;
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,9 +2,9 @@ const wurl = require('wurl');
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Check link if it's internal/external
 | 
					// Check link if it's internal/external
 | 
				
			||||||
function linkIsInternal(currentUrl, newUrl) {
 | 
					function linkIsInternal(currentUrl, newUrl) {
 | 
				
			||||||
    var currentDomain = wurl('domain', currentUrl);
 | 
						const currentDomain = wurl('domain', currentUrl);
 | 
				
			||||||
    var newDomain = wurl('domain', newUrl);
 | 
						const newDomain = wurl('domain', newUrl);
 | 
				
			||||||
    return currentDomain === newDomain;
 | 
						return currentDomain === newDomain;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports = module.exports = {
 | 
					exports = module.exports = {
 | 
				
			||||||
							
								
								
									
										520
									
								
								app/main/menu.js
									
									
									
									
									
								
							
							
						
						
									
										520
									
								
								app/main/menu.js
									
									
									
									
									
								
							@@ -1,288 +1,304 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
const os = require('os');
 | 
					const os = require('os');
 | 
				
			||||||
const path = require('path');
 | 
					 | 
				
			||||||
const electron = require('electron');
 | 
					const electron = require('electron');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const app = electron.app;
 | 
					const app = electron.app;
 | 
				
			||||||
const BrowserWindow = electron.BrowserWindow;
 | 
					const BrowserWindow = electron.BrowserWindow;
 | 
				
			||||||
const shell = electron.shell;
 | 
					const shell = electron.shell;
 | 
				
			||||||
const appName = app.getName();
 | 
					const appName = app.getName();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const { addDomain, About } = require('./windowmanager');
 | 
					const {addDomain, about} = require('./windowmanager');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function sendAction(action) {
 | 
					function sendAction(action) {
 | 
				
			||||||
  const win = BrowserWindow.getAllWindows()[0];
 | 
						const win = BrowserWindow.getAllWindows()[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (process.platform === 'darwin') {
 | 
						if (process.platform === 'darwin') {
 | 
				
			||||||
    win.restore();
 | 
							win.restore();
 | 
				
			||||||
  }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  win.webContents.send(action);
 | 
						win.webContents.send(action);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const viewSubmenu = [
 | 
					const viewSubmenu = [
 | 
				
			||||||
{
 | 
						{
 | 
				
			||||||
  label: 'Reload',
 | 
							label: 'Reload',
 | 
				
			||||||
  accelerator: 'CmdOrCtrl+R',
 | 
							accelerator: 'CmdOrCtrl+R',
 | 
				
			||||||
  click (item, focusedWindow) {
 | 
							click(item, focusedWindow) {
 | 
				
			||||||
    if (focusedWindow) focusedWindow.reload()
 | 
								if (focusedWindow) {
 | 
				
			||||||
  }
 | 
									focusedWindow.reload();
 | 
				
			||||||
},
 | 
								}
 | 
				
			||||||
{
 | 
							}
 | 
				
			||||||
  label: 'Toggle Developer Tools',
 | 
						},
 | 
				
			||||||
  accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
 | 
						{
 | 
				
			||||||
  click (item, focusedWindow) {
 | 
							label: 'Toggle Developer Tools',
 | 
				
			||||||
    if (focusedWindow) focusedWindow.webContents.toggleDevTools()
 | 
							accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
 | 
				
			||||||
  }
 | 
							click(item, focusedWindow) {
 | 
				
			||||||
},
 | 
								if (focusedWindow) {
 | 
				
			||||||
{
 | 
									focusedWindow.webContents.toggleDevTools();
 | 
				
			||||||
  type: 'separator'
 | 
								}
 | 
				
			||||||
},
 | 
							}
 | 
				
			||||||
{
 | 
						},
 | 
				
			||||||
  role: 'togglefullscreen'
 | 
						{
 | 
				
			||||||
}
 | 
							type: 'separator'
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							role: 'togglefullscreen'
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const helpSubmenu = [
 | 
					const helpSubmenu = [
 | 
				
			||||||
  {
 | 
						{
 | 
				
			||||||
    label: `${appName} Website`,
 | 
							label: `${appName} Website`,
 | 
				
			||||||
    click() {
 | 
							click() {
 | 
				
			||||||
      shell.openExternal('https://zulip.org');
 | 
								shell.openExternal('https://zulip.org');
 | 
				
			||||||
    }
 | 
							}
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  {
 | 
						{
 | 
				
			||||||
    label: `${app.getName()} - ${app.getVersion()}`,
 | 
							label: `${app.getName()} - ${app.getVersion()}`
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  {
 | 
						{
 | 
				
			||||||
    label: 'Report an Issue...',
 | 
							label: 'Report an Issue...',
 | 
				
			||||||
    click() {
 | 
							click() {
 | 
				
			||||||
      const body = `
 | 
								const body = `
 | 
				
			||||||
<!-- Please succinctly describe your issue and steps to reproduce it. -->
 | 
					<!-- Please succinctly describe your issue and steps to reproduce it. -->
 | 
				
			||||||
-
 | 
					-
 | 
				
			||||||
${app.getName()} ${app.getVersion()}
 | 
					${app.getName()} ${app.getVersion()}
 | 
				
			||||||
Electron ${process.versions.electron}
 | 
					Electron ${process.versions.electron}
 | 
				
			||||||
${process.platform} ${process.arch} ${os.release()}`;
 | 
					${process.platform} ${process.arch} ${os.release()}`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      shell.openExternal(`https://github.com/zulip/zulip-electron/issues/new?body=${encodeURIComponent(body)}`);
 | 
								shell.openExternal(`https://github.com/zulip/zulip-electron/issues/new?body=${encodeURIComponent(body)}`);
 | 
				
			||||||
    }
 | 
							}
 | 
				
			||||||
  }
 | 
						}
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const darwinTpl = [
 | 
					const darwinTpl = [
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  {
 | 
						{
 | 
				
			||||||
    label: `${app.getName()}`,
 | 
							label: `${app.getName()}`,
 | 
				
			||||||
    submenu: [
 | 
							submenu: [
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        label: 'Zulip desktop',
 | 
									label: 'Zulip desktop',
 | 
				
			||||||
        click() {
 | 
									click() {
 | 
				
			||||||
          About();
 | 
										about();
 | 
				
			||||||
        }
 | 
									}
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        type: 'separator'
 | 
									type: 'separator'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        label: 'Change Zulip Server',
 | 
									label: 'Change Zulip Server',
 | 
				
			||||||
        accelerator: 'Cmd+,',
 | 
									accelerator: 'Cmd+,',
 | 
				
			||||||
        click(item, focusedWindow) {
 | 
									click(item, focusedWindow) {
 | 
				
			||||||
          if(focusedWindow) addDomain();
 | 
										if (focusedWindow) {
 | 
				
			||||||
        }
 | 
											addDomain();
 | 
				
			||||||
      },
 | 
										}
 | 
				
			||||||
      {
 | 
									}
 | 
				
			||||||
        label: 'Keyboard shortcuts',
 | 
								},
 | 
				
			||||||
        accelerator: 'Cmd+K',
 | 
								{
 | 
				
			||||||
        click(item, focusedWindow) {
 | 
									label: 'Keyboard shortcuts',
 | 
				
			||||||
          if(focusedWindow) sendAction('shortcut');
 | 
									accelerator: 'Cmd+K',
 | 
				
			||||||
        }
 | 
									click(item, focusedWindow) {
 | 
				
			||||||
      },
 | 
										if (focusedWindow) {
 | 
				
			||||||
      {
 | 
											sendAction('shortcut');
 | 
				
			||||||
        type: 'separator'
 | 
										}
 | 
				
			||||||
      },
 | 
									}
 | 
				
			||||||
      {
 | 
								},
 | 
				
			||||||
        label: 'Log Out',
 | 
								{
 | 
				
			||||||
        click(item, focusedWindow) {
 | 
									type: 'separator'
 | 
				
			||||||
          if(focusedWindow) sendAction('log-out');
 | 
								},
 | 
				
			||||||
        }
 | 
								{
 | 
				
			||||||
      },
 | 
									label: 'Log Out',
 | 
				
			||||||
      {
 | 
									click(item, focusedWindow) {
 | 
				
			||||||
        type: 'separator'
 | 
										if (focusedWindow) {
 | 
				
			||||||
      },
 | 
											sendAction('log-out');
 | 
				
			||||||
      {
 | 
										}
 | 
				
			||||||
        role: 'services',
 | 
									}
 | 
				
			||||||
        submenu: []
 | 
								},
 | 
				
			||||||
      },
 | 
								{
 | 
				
			||||||
      {
 | 
									type: 'separator'
 | 
				
			||||||
        type: 'separator'
 | 
								},
 | 
				
			||||||
      },
 | 
								{
 | 
				
			||||||
      {
 | 
									role: 'services',
 | 
				
			||||||
        role: 'hide'
 | 
									submenu: []
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'hideothers'
 | 
									type: 'separator'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'unhide'
 | 
									role: 'hide'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        type: 'separator'
 | 
									role: 'hideothers'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'quit'
 | 
									role: 'unhide'
 | 
				
			||||||
      }
 | 
								},
 | 
				
			||||||
    ]
 | 
								{
 | 
				
			||||||
  },
 | 
									type: 'separator'
 | 
				
			||||||
  {
 | 
								},
 | 
				
			||||||
    label: 'Edit',
 | 
								{
 | 
				
			||||||
    submenu: [
 | 
									role: 'quit'
 | 
				
			||||||
      {
 | 
								}
 | 
				
			||||||
        role: 'undo'
 | 
							]
 | 
				
			||||||
      },
 | 
						},
 | 
				
			||||||
      {
 | 
						{
 | 
				
			||||||
        role: 'redo'
 | 
							label: 'Edit',
 | 
				
			||||||
      },
 | 
							submenu: [
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        type: 'separator'
 | 
									role: 'undo'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'cut'
 | 
									role: 'redo'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'copy'
 | 
									type: 'separator'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'paste'
 | 
									role: 'cut'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'pasteandmatchstyle'
 | 
									role: 'copy'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'delete'
 | 
									role: 'paste'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'selectall'
 | 
									role: 'pasteandmatchstyle'
 | 
				
			||||||
      }
 | 
								},
 | 
				
			||||||
    ]
 | 
								{
 | 
				
			||||||
  },
 | 
									role: 'delete'
 | 
				
			||||||
  {
 | 
								},
 | 
				
			||||||
    label: 'View',
 | 
								{
 | 
				
			||||||
    submenu: viewSubmenu
 | 
									role: 'selectall'
 | 
				
			||||||
  },
 | 
								}
 | 
				
			||||||
  {
 | 
							]
 | 
				
			||||||
    role: 'window',
 | 
						},
 | 
				
			||||||
    submenu: [
 | 
						{
 | 
				
			||||||
      {
 | 
							label: 'View',
 | 
				
			||||||
        role: 'minimize'
 | 
							submenu: viewSubmenu
 | 
				
			||||||
      },
 | 
						},
 | 
				
			||||||
      {
 | 
						{
 | 
				
			||||||
        role: 'close'
 | 
							role: 'window',
 | 
				
			||||||
      },
 | 
							submenu: [
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        type: 'separator'
 | 
									role: 'minimize'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'front'
 | 
									role: 'close'
 | 
				
			||||||
      }
 | 
								},
 | 
				
			||||||
    ]
 | 
								{
 | 
				
			||||||
  },
 | 
									type: 'separator'
 | 
				
			||||||
  {
 | 
								},
 | 
				
			||||||
    role: 'help',
 | 
								{
 | 
				
			||||||
    submenu: helpSubmenu
 | 
									role: 'front'
 | 
				
			||||||
  }
 | 
								}
 | 
				
			||||||
 | 
							]
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							role: 'help',
 | 
				
			||||||
 | 
							submenu: helpSubmenu
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const otherTpl = [
 | 
					const otherTpl = [
 | 
				
			||||||
  {
 | 
						{
 | 
				
			||||||
    label: 'File',
 | 
							label: 'File',
 | 
				
			||||||
    submenu: [
 | 
							submenu: [
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        label: 'Zulip desktop',
 | 
									label: 'Zulip desktop',
 | 
				
			||||||
        click() {
 | 
									click() {
 | 
				
			||||||
          About();
 | 
										about();
 | 
				
			||||||
        }
 | 
									}
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        type: 'separator'
 | 
									type: 'separator'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        label: 'Change Zulip Server',
 | 
									label: 'Change Zulip Server',
 | 
				
			||||||
        accelerator: 'Ctrl+,',
 | 
									accelerator: 'Ctrl+,',
 | 
				
			||||||
        click(item, focusedWindow) {
 | 
									click(item, focusedWindow) {
 | 
				
			||||||
          if(focusedWindow) addDomain();
 | 
										if (focusedWindow) {
 | 
				
			||||||
        }
 | 
											addDomain();
 | 
				
			||||||
      },
 | 
										}
 | 
				
			||||||
      {
 | 
									}
 | 
				
			||||||
        type: 'separator'
 | 
								},
 | 
				
			||||||
      },
 | 
								{
 | 
				
			||||||
      {
 | 
									type: 'separator'
 | 
				
			||||||
        label: 'Keyboard shortcuts',
 | 
								},
 | 
				
			||||||
        accelerator: 'Ctrl+K',
 | 
								{
 | 
				
			||||||
        click(item, focusedWindow) {
 | 
									label: 'Keyboard shortcuts',
 | 
				
			||||||
          if(focusedWindow) sendAction('shortcut');
 | 
									accelerator: 'Ctrl+K',
 | 
				
			||||||
        }
 | 
									click(item, focusedWindow) {
 | 
				
			||||||
      },
 | 
										if (focusedWindow) {
 | 
				
			||||||
      {
 | 
											sendAction('shortcut');
 | 
				
			||||||
        type: 'separator'
 | 
										}
 | 
				
			||||||
      },
 | 
									}
 | 
				
			||||||
      {
 | 
								},
 | 
				
			||||||
        label: 'Log Out',
 | 
								{
 | 
				
			||||||
        click(item, focusedWindow) {
 | 
									type: 'separator'
 | 
				
			||||||
          if(focusedWindow) sendAction('log-out');
 | 
								},
 | 
				
			||||||
        }
 | 
								{
 | 
				
			||||||
      },
 | 
									label: 'Log Out',
 | 
				
			||||||
      {
 | 
									click(item, focusedWindow) {
 | 
				
			||||||
        type: 'separator'
 | 
										if (focusedWindow) {
 | 
				
			||||||
      },
 | 
											sendAction('log-out');
 | 
				
			||||||
      {
 | 
										}
 | 
				
			||||||
        role: 'quit'
 | 
									}
 | 
				
			||||||
      }
 | 
								},
 | 
				
			||||||
    ]
 | 
								{
 | 
				
			||||||
  },
 | 
									type: 'separator'
 | 
				
			||||||
  {
 | 
								},
 | 
				
			||||||
    label: 'Edit',
 | 
								{
 | 
				
			||||||
    submenu: [
 | 
									role: 'quit'
 | 
				
			||||||
      {
 | 
								}
 | 
				
			||||||
        role: 'undo'
 | 
							]
 | 
				
			||||||
      },
 | 
						},
 | 
				
			||||||
      {
 | 
						{
 | 
				
			||||||
        role: 'redo'
 | 
							label: 'Edit',
 | 
				
			||||||
      },
 | 
							submenu: [
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        type: 'separator'
 | 
									role: 'undo'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'cut'
 | 
									role: 'redo'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'copy'
 | 
									type: 'separator'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'paste'
 | 
									role: 'cut'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'pasteandmatchstyle'
 | 
									role: 'copy'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'delete'
 | 
									role: 'paste'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        type: 'separator'
 | 
									role: 'pasteandmatchstyle'
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
      {
 | 
								{
 | 
				
			||||||
        role: 'selectall'
 | 
									role: 'delete'
 | 
				
			||||||
      }
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									type: 'separator'
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									role: 'selectall'
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ]
 | 
							]
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  {
 | 
						{
 | 
				
			||||||
    label: 'View',
 | 
							label: 'View',
 | 
				
			||||||
    submenu: viewSubmenu
 | 
							submenu: viewSubmenu
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  {
 | 
						{
 | 
				
			||||||
    role: 'help',
 | 
							role: 'help',
 | 
				
			||||||
    submenu: helpSubmenu
 | 
							submenu: helpSubmenu
 | 
				
			||||||
  }
 | 
						}
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const tpl = process.platform === 'darwin' ? darwinTpl : otherTpl;
 | 
					const tpl = process.platform === 'darwin' ? darwinTpl : otherTpl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = electron.Menu.buildFromTemplate(tpl);
 | 
					module.exports = electron.Menu.buildFromTemplate(tpl);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,29 +1,28 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
const electron = require('electron');
 | 
					 | 
				
			||||||
const ipcRenderer = require('electron').ipcRenderer;
 | 
					const ipcRenderer = require('electron').ipcRenderer;
 | 
				
			||||||
const webFrame = require('electron').webFrame;
 | 
					const webFrame = require('electron').webFrame;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Implement spellcheck using electron api
 | 
					// Implement spellcheck using electron api
 | 
				
			||||||
 | 
					
 | 
				
			||||||
webFrame.setSpellCheckProvider("en-US", false, {
 | 
					webFrame.setSpellCheckProvider('en-US', false, {
 | 
				
			||||||
    spellCheck: function(text) {
 | 
						spellCheck: text => {
 | 
				
			||||||
        var res = ipcRenderer.sendSync('checkspell', text);
 | 
							const res = ipcRenderer.sendSync('checkspell', text);
 | 
				
			||||||
        return res != null? res : true;
 | 
							return res === null ? true : res;
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Handle zooming functionality
 | 
					// Handle zooming functionality
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const zoomIn = () => {
 | 
					const zoomIn = () => {
 | 
				
			||||||
  webFrame.setZoomFactor(webFrame.getZoomFactor() + 0.1);
 | 
						webFrame.setZoomFactor(webFrame.getZoomFactor() + 0.1);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const zoomOut = () => {
 | 
					const zoomOut = () => {
 | 
				
			||||||
  webFrame.setZoomFactor(webFrame.getZoomFactor() - 0.1);
 | 
						webFrame.setZoomFactor(webFrame.getZoomFactor() - 0.1);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const zoomActualSize = () => {
 | 
					const zoomActualSize = () => {
 | 
				
			||||||
  webFrame.setZoomFactor(1);
 | 
						webFrame.setZoomFactor(1);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Get zooming actions from main process
 | 
					// Get zooming actions from main process
 | 
				
			||||||
@@ -53,4 +52,4 @@ ipcRenderer.on('shortcut', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	const nodes = document.querySelectorAll('.dropdown-menu li:nth-child(4) a');
 | 
						const nodes = document.querySelectorAll('.dropdown-menu li:nth-child(4) a');
 | 
				
			||||||
	nodes[nodes.length - 1].click();
 | 
						nodes[nodes.length - 1].click();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,22 +2,17 @@
 | 
				
			|||||||
const path = require('path');
 | 
					const path = require('path');
 | 
				
			||||||
const electron = require('electron');
 | 
					const electron = require('electron');
 | 
				
			||||||
const app = require('electron').app;
 | 
					const app = require('electron').app;
 | 
				
			||||||
const {shell} = require('electron');
 | 
					const {addDomain, about} = require('./windowmanager');
 | 
				
			||||||
const { addDomain, About } = require('./windowmanager');
 | 
					 | 
				
			||||||
const BrowserWindow = electron.BrowserWindow;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
let tray = null;
 | 
					let tray = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const APP_ICON = path.join(__dirname, '../resources', 'Icon');
 | 
					const APP_ICON = path.join(__dirname, '../resources', 'Icon');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const iconPath = () => {
 | 
					const iconPath = () => {
 | 
				
			||||||
  return process.platform === 'win32'
 | 
						return APP_ICON + (process.platform === 'win32' ? '.ico' : '.png');
 | 
				
			||||||
    ? APP_ICON + '.ico'
 | 
					 | 
				
			||||||
    : APP_ICON + '.png'
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.create = win => {
 | 
					exports.create = () => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Noone is using this feature. so let's hide it for now.
 | 
						// Noone is using this feature. so let's hide it for now.
 | 
				
			||||||
	// const toggleWin = () => {
 | 
						// const toggleWin = () => {
 | 
				
			||||||
	// 	if (win.isVisible()) {
 | 
						// 	if (win.isVisible()) {
 | 
				
			||||||
@@ -26,12 +21,11 @@ exports.create = win => {
 | 
				
			|||||||
	// 		win.show();
 | 
						// 		win.show();
 | 
				
			||||||
	// 	}
 | 
						// 	}
 | 
				
			||||||
	// };
 | 
						// };
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	const contextMenu = electron.Menu.buildFromTemplate([
 | 
						const contextMenu = electron.Menu.buildFromTemplate([
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			label: 'About',
 | 
								label: 'About',
 | 
				
			||||||
			click() {
 | 
								click() {
 | 
				
			||||||
				About();
 | 
									about();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -40,7 +34,9 @@ exports.create = win => {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			label: 'Change Zulip server',
 | 
								label: 'Change Zulip server',
 | 
				
			||||||
			click(item, focusedWindow) {
 | 
								click(item, focusedWindow) {
 | 
				
			||||||
				if(focusedWindow) addDomain();
 | 
									if (focusedWindow) {
 | 
				
			||||||
 | 
										addDomain();
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -48,8 +44,10 @@ exports.create = win => {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			label: 'Reload',
 | 
								label: 'Reload',
 | 
				
			||||||
			click (item, focusedWindow) {
 | 
								click(item, focusedWindow) {
 | 
				
			||||||
			  if (focusedWindow) focusedWindow.reload()
 | 
									if (focusedWindow) {
 | 
				
			||||||
 | 
										focusedWindow.reload();
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,69 +1,69 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
const electron = require('electron');
 | 
					 | 
				
			||||||
const path = require('path');
 | 
					const path = require('path');
 | 
				
			||||||
 | 
					const electron = require('electron');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let domainWindow;
 | 
					let domainWindow;
 | 
				
			||||||
let aboutWindow;
 | 
					let aboutWindow;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function onClosed() {
 | 
					function onClosed() {
 | 
				
			||||||
    // dereference the window
 | 
						// dereference the window
 | 
				
			||||||
    domainWindow = null;
 | 
						domainWindow = null;
 | 
				
			||||||
    aboutWindow = null;
 | 
						aboutWindow = null;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Change Zulip server Window
 | 
					// Change Zulip server Window
 | 
				
			||||||
function createdomainWindow() {
 | 
					function createdomainWindow() {
 | 
				
			||||||
    const domainwin = new electron.BrowserWindow({
 | 
						const domainwin = new electron.BrowserWindow({
 | 
				
			||||||
        frame: false,
 | 
							frame: false,
 | 
				
			||||||
        height: 300,
 | 
							height: 300,
 | 
				
			||||||
        resizable: false,
 | 
							resizable: false,
 | 
				
			||||||
        width: 400
 | 
							width: 400
 | 
				
			||||||
    })
 | 
						});
 | 
				
			||||||
    const domainURL = 'file://' + path.join(__dirname, '../renderer', 'pref.html');
 | 
						const domainURL = 'file://' + path.join(__dirname, '../renderer', 'pref.html');
 | 
				
			||||||
    domainwin.loadURL(domainURL);
 | 
						domainwin.loadURL(domainURL);
 | 
				
			||||||
    domainwin.on('closed', onClosed);
 | 
						domainwin.on('closed', onClosed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return domainwin;
 | 
						return domainwin;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Call this window onClick addDomain in tray
 | 
					// Call this window onClick addDomain in tray
 | 
				
			||||||
function addDomain(){
 | 
					function addDomain() {
 | 
				
			||||||
    domainWindow = createdomainWindow();
 | 
						domainWindow = createdomainWindow();
 | 
				
			||||||
    domainWindow.show();
 | 
						domainWindow.show();
 | 
				
			||||||
};
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// About window
 | 
					// About window
 | 
				
			||||||
function createAboutWindow() {
 | 
					function createAboutWindow() {
 | 
				
			||||||
    const aboutwin = new electron.BrowserWindow({
 | 
						const aboutwin = new electron.BrowserWindow({
 | 
				
			||||||
        width: 500,
 | 
							width: 500,
 | 
				
			||||||
        height: 500,
 | 
							height: 500,
 | 
				
			||||||
        title: 'About Zulip Desktop',
 | 
							title: 'About Zulip Desktop',
 | 
				
			||||||
        show: false,
 | 
							show: false,
 | 
				
			||||||
        center: true,
 | 
							center: true,
 | 
				
			||||||
        fullscreen: false,
 | 
							fullscreen: false,
 | 
				
			||||||
        fullscreenable: false,
 | 
							fullscreenable: false,
 | 
				
			||||||
        resizable: false
 | 
							resizable: false
 | 
				
			||||||
    })
 | 
						});
 | 
				
			||||||
    const aboutURL = 'file://' + path.join(__dirname, '../renderer', 'about.html');
 | 
						const aboutURL = 'file://' + path.join(__dirname, '../renderer', 'about.html');
 | 
				
			||||||
    aboutwin.loadURL(aboutURL);
 | 
						aboutwin.loadURL(aboutURL);
 | 
				
			||||||
    aboutwin.on('closed', onClosed);
 | 
						aboutwin.on('closed', onClosed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // stop page to update it's title
 | 
						// stop page to update it's title
 | 
				
			||||||
    aboutwin.on('page-title-updated', (e) => {
 | 
						aboutwin.on('page-title-updated', e => {
 | 
				
			||||||
       e.preventDefault();
 | 
							e.preventDefault();
 | 
				
			||||||
    });
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    aboutwin.on('closed', onClosed);
 | 
						aboutwin.on('closed', onClosed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return aboutwin;
 | 
						return aboutwin;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Call this onClick About in tray
 | 
					// Call this onClick About in tray
 | 
				
			||||||
function About() {
 | 
					function about() {
 | 
				
			||||||
    aboutWindow = createAboutWindow();
 | 
						aboutWindow = createAboutWindow();
 | 
				
			||||||
    aboutWindow.show();
 | 
						aboutWindow.show();
 | 
				
			||||||
};
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports = module.exports = {
 | 
					exports = module.exports = {
 | 
				
			||||||
   addDomain,About
 | 
						addDomain, about
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,36 +2,33 @@ window.onload = function getURL() {
 | 
				
			|||||||
	const request = require('request');
 | 
						const request = require('request');
 | 
				
			||||||
	const JsonDB = require('node-json-db');
 | 
						const JsonDB = require('node-json-db');
 | 
				
			||||||
	const ipcRenderer = require('electron').ipcRenderer;
 | 
						const ipcRenderer = require('electron').ipcRenderer;
 | 
				
			||||||
	const dialogs = require('dialogs')()
 | 
						const dialogs = require('dialogs')();
 | 
				
			||||||
    const db = new JsonDB("domain", true, true);
 | 
					 | 
				
			||||||
    const data = db.getData("/");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (data["domain"] !== undefined) {
 | 
						const db = new JsonDB('domain', true, true);
 | 
				
			||||||
        window.location.href = data["domain"];
 | 
						const data = db.getData('/');
 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        dialogs.prompt('Enter the URL for your Zulip server', function(url) {
 | 
						if (data.domain) {
 | 
				
			||||||
 | 
							window.location.href = data.domain;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							dialogs.prompt('Enter the URL for your Zulip server', url => {
 | 
				
			||||||
 | 
								const newurl = 'https://' + url.replace(/^https?:\/\//, '');
 | 
				
			||||||
 | 
								const checkURL = newurl + '/static/audio/zulip.ogg';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        	let newurl = 'https://' + url.replace(/^https?:\/\//,'')
 | 
								request(checkURL, (error, response) => {
 | 
				
			||||||
        	let checkURL = newurl + '/static/audio/zulip.ogg';
 | 
									if (!error && response.statusCode !== 404) {
 | 
				
			||||||
 | 
										db.push('/domain', newurl);
 | 
				
			||||||
 | 
										ipcRenderer.send('new-domain', newurl);
 | 
				
			||||||
 | 
										window.location.href = newurl;
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										dialogs.alert('Not valid url');
 | 
				
			||||||
 | 
										console.log('Not valid url');
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        	request(checkURL, function (error, response, body) {
 | 
						const getInput = document.getElementsByTagName('input')[0];
 | 
				
			||||||
        		if (!error && response.statusCode !== 404) {
 | 
					 | 
				
			||||||
        			    db.push("/domain", newurl);
 | 
					 | 
				
			||||||
        			    ipcRenderer.send('new-domain', newurl);
 | 
					 | 
				
			||||||
        			    window.location.href = newurl ;
 | 
					 | 
				
			||||||
        		}
 | 
					 | 
				
			||||||
        		else {
 | 
					 | 
				
			||||||
        			dialogs.alert('Not valid url');
 | 
					 | 
				
			||||||
        			console.log("Not valid url");
 | 
					 | 
				
			||||||
        		}
 | 
					 | 
				
			||||||
        	})
 | 
					 | 
				
			||||||
        })
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const getInput = document.getElementsByTagName('input')[0];
 | 
						getInput.setAttribute('placeholder', 'zulip.example.com'); // add placeholder
 | 
				
			||||||
 | 
						getInput.setAttribute('spellcheck', 'false'); // no spellcheck for form
 | 
				
			||||||
getInput.setAttribute('placeholder', 'zulip.example.com'); // add placeholder
 | 
					};
 | 
				
			||||||
getInput.setAttribute('spellcheck', 'false');	// no spellcheck for form	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,40 +1,40 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
const {remote} = require('electron');
 | 
					const {remote} = require('electron');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
document.getElementById('close-button').addEventListener('click', function (e) {
 | 
					document.getElementById('close-bu	on').addEventListener('click', () => {
 | 
				
			||||||
     let window = remote.getCurrentWindow();
 | 
						const window = remote.getCurrentWindow();
 | 
				
			||||||
     window.close();
 | 
						window.close();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// document.getElementById('pic').style.display ='block';
 | 
					// document.getElementById('pic').style.display ='block';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// eslint-disable-next-line no-unused-vars
 | 
				
			||||||
function addDomain() {
 | 
					function addDomain() {
 | 
				
			||||||
 | 
						const request = require('request');
 | 
				
			||||||
 | 
						const ipcRenderer = require('electron').ipcRenderer;
 | 
				
			||||||
 | 
						const JsonDB = require('node-json-db');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const request = require('request');
 | 
						const db = new JsonDB('domain', true, true);
 | 
				
			||||||
        const ipcRenderer = require('electron').ipcRenderer;
 | 
						document.getElementById('main').innerHTML = 'checking...';
 | 
				
			||||||
        const JsonDB = require('node-json-db');
 | 
						document.getElementById('pic').style.display = 'block';
 | 
				
			||||||
        const db = new JsonDB('domain', true, true);
 | 
					 | 
				
			||||||
        document.getElementById('main').innerHTML = 'checking...'
 | 
					 | 
				
			||||||
        document.getElementById('pic').style.display ='block';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let newDomain = document.getElementById('url').value;
 | 
						let newDomain = document.getElementById('url').value;
 | 
				
			||||||
        newDomain = newDomain.replace(/^https?:\/\//,'')
 | 
						newDomain = newDomain.replace(/^https?:\/\//, '');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const domain = 'https://' + newDomain;
 | 
						const domain = 'https://' + newDomain;
 | 
				
			||||||
        const checkDomain = domain + '/static/audio/zulip.ogg';
 | 
						const checkDomain = domain + '/static/audio/zulip.ogg';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        request(checkDomain, function (error, response, body) {
 | 
						request(checkDomain, (error, response) => {
 | 
				
			||||||
            if (!error && response.statusCode !== 404) {
 | 
							if (!error && response.statusCode !== 404) {
 | 
				
			||||||
                document.getElementById('pic').style.display ='none';
 | 
								document.getElementById('pic').style.display = 'none';
 | 
				
			||||||
                document.getElementById('main').innerHTML = 'Add'
 | 
								document.getElementById('main').innerHTML = 'Add';
 | 
				
			||||||
                document.getElementById('urladded').innerHTML = newDomain + '  Added';
 | 
								document.getElementById('urladded').innerHTML = newDomain + '  Added';
 | 
				
			||||||
                db.push('/domain', domain);
 | 
								db.push('/domain', domain);
 | 
				
			||||||
                ipcRenderer.send('new-domain', domain);
 | 
								ipcRenderer.send('new-domain', domain);
 | 
				
			||||||
            }
 | 
							} else {
 | 
				
			||||||
            else {
 | 
								document.getElementById('pic').style.display = 'none';
 | 
				
			||||||
                document.getElementById('pic').style.display ='none';
 | 
								document.getElementById('main').innerHTML = 'Add';
 | 
				
			||||||
                document.getElementById('main').innerHTML = 'Add'
 | 
								document.getElementById('urladded').innerHTML = 'Not a vaild Zulip server';
 | 
				
			||||||
                document.getElementById('urladded').innerHTML = "Not a vaild Zulip server";
 | 
							}
 | 
				
			||||||
            }
 | 
						});
 | 
				
			||||||
        })
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,6 +26,7 @@
 | 
				
			|||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "configstore": "^2.0.0",
 | 
					    "configstore": "^2.0.0",
 | 
				
			||||||
    "dialogs": "1.1.14",
 | 
					    "dialogs": "1.1.14",
 | 
				
			||||||
 | 
					    "electron": "^1.3.3",
 | 
				
			||||||
    "electron-context-menu": "0.4.0",
 | 
					    "electron-context-menu": "0.4.0",
 | 
				
			||||||
    "electron-debug": "^1.0.0",
 | 
					    "electron-debug": "^1.0.0",
 | 
				
			||||||
    "electron-dl": "^0.2.0",
 | 
					    "electron-dl": "^0.2.0",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user