var app = require('app'); // Module to control application life. var ipc = require('ipc'); // Module to facilitate interprocess communication var BrowserWindow = require('browser-window'); // Module to create native browser window. const dialog = require('electron').dialog; // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. var mainWindow = null; var backWindow = null; mainWindow = new BrowserWindow({width: 1000, height: 600, x: 900, y:600}); backWindow = new BrowserWindow({width: 900, height: 600, x: 0, y: 0}); backWindow.webContents.session.clearCache(function(){ console.log('cacheCleared'); }); mainWindow.webContents.session.clearCache(function(){ console.log('cacheCleared'); }); // and load the index.html of the app. backWindow.loadUrl('http://example.com'); mainWindow.loadUrl('file://' + __dirname + '/ui/website.html'); // Open the DevTools. backWindow.webContents.openDevTools(); mainWindow.webContents.openDevTools(); // Emitted when the window is closed. backWindow.on('closed', function() { // Dereference the window object, usually you would store windows // in an array if your app supports multi windows, this is the time // when you should delete the corresponding element. backWindow = null; }); // Emitted when the window is closed. mainWindow.on('closed', function() { // Dereference the window object, usually you would store windows // in an array if your app supports multi windows, this is the time // when you should delete the corresponding element. mainWindow = null; }); ipc.on('website', function(event, website){ console.log(website); backWindow.loadUrl('http://' + website + '/admin'); backWindow.webContents.once('did-finish-load', function(){ if(backWindow.webContents.getUrl().indexOf('loc=') != -1){ mainWindow.loadUrl('file://' + __dirname + '/ui/ror/login.html'); } else if(backWindow.webContents.getUrl().indexOf('#home') != -1){ mainWindow.loadUrl('file://' + __dirname + '/ui/rac/login.html'); } else { // mostly for testing on dev // this will throw an error in production console.log('hit else in site selection, please check your site carefully.'); backWindow.loadUrl('http://' + website + '/admin/' ); // validation mainWindow.loadUrl('file://' + __dirname + '/ui/rac/login.html'); } }); }); ipc.on('rorLogin', function(event, login) { //JSON.parse(login); //console.log(login.user[0]); console.log(login); var user = login.user; var password = login.password; console.log(backWindow.getUrl()); var loginURL = backWindow.getUrl() + "&user=" + user + "&password=" + password; console.log(loginURL); backWindow.loadUrl(loginURL); backWindow.webContents.once('did-finish-load', function(){ if(backWindow.webContents.getTitle().includes('Settings')){ var splitIndex = backWindow.webContents.getUrl().lastIndexOf('location'); var liveURL = backWindow.webContents.getUrl().substr(0, splitIndex) + "3rdparty/live_sites"; backWindow.loadUrl(liveURL); console.log(liveURL); backWindow.webContents.once('did-finish-load', function(){ var codeString = "var ipc = require('ipc');" + "var sites = [];" + "var ids = [];" + "var list = document.getElementsByTagName('site');" + "var i;" + "for(i = 0; i