From 4b7a124c4fc167f567b05d9adcf0d42cf3d8cbb7 Mon Sep 17 00:00:00 2001 From: Koushik Naskar Date: Sat, 5 Feb 2022 20:26:27 +0530 Subject: [PATCH] few fixes --- index.js | 23 ++++++++++++++--------- src/html/doc.html | 4 ++++ src/js/init.js | 9 ++++----- src/js/keyIpcTrigger.js | 8 +------- src/js/version.js | 2 +- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/index.js b/index.js index 6f70c33..c9ec0f2 100644 --- a/index.js +++ b/index.js @@ -58,10 +58,10 @@ var info = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file,"utf8")) :{} // for capturing proxy authentication request let reservedLoginCallback = null -let proxy = null +let proxyPopUp = null let loginCount = 0 ipcMain.on('authSubmitted', (_, {id, password}) => { - proxy.close() + proxyPopUp.close() reservedLoginCallback(id, password) reservedLoginCallback = null info.proxy = {"id":id, "password":password} @@ -82,8 +82,9 @@ app.on('ready', function () { callback(aInfo.id,aInfo.password); }else { reservedLoginCallback = callback - proxy = new BrowserWindow({ - width: 450, + if(proxyPopUp) proxyPopUp.close() // discard multiple popups + proxyPopUp = new BrowserWindow({ + width: 400, height: 200, show:false, modal:true, @@ -96,11 +97,13 @@ app.on('ready', function () { enableRemoteModule: true, contextIsolation:false },}) - proxy.loadFile("src/html/auth.html") - proxy.once('ready-to-show',()=>{ - proxy.webContents.send('details', authInfo) - proxy.show(); + proxyPopUp.loadFile("src/html/auth.html") + proxyPopUp.once('ready-to-show',()=>{ + proxyPopUp.webContents.send('details', authInfo) + proxyPopUp.show(); }) + proxyPopUp.once('closed',()=>{proxyPopUp=null}) + } loginCount++ } @@ -149,7 +152,7 @@ const helpMenu = { childWindow.loadFile('src/html/doc.html') childWindow.maximize(); childWindow.setMenuBarVisibility(false); - childWindow.show(); + childWindow.once('ready-to-show',childWindow.show) } }, { label: "Sample Data", @@ -185,6 +188,7 @@ const helpMenu = { minWidth: 500, maxWidth : 700, width:600, + show:false, title: "Interactive Data Editor - About", webPreferences: { nodeIntegration: true, @@ -195,6 +199,7 @@ const helpMenu = { }); childWindow.loadFile('./src/html/about.html') childWindow.setMenuBarVisibility(false); + childWindow.once('ready-to-show',childWindow.show) } }, { diff --git a/src/html/doc.html b/src/html/doc.html index 8f62541..d7a241c 100644 --- a/src/html/doc.html +++ b/src/html/doc.html @@ -199,6 +199,9 @@ width: 1.3pc; height: 1.3pc; } + .page:focus{ + outline: none; + } @@ -536,6 +539,7 @@ var current=0; secList[current].classList.add('shown') linkList[current].classList.add('visited') + secList[current].focus() function showThis(index){ if(current==index) return diff --git a/src/js/init.js b/src/js/init.js index 363b057..ff50244 100644 --- a/src/js/init.js +++ b/src/js/init.js @@ -15,7 +15,7 @@ class dataStore{ this.info = fs.existsSync(this.file) ? JSON.parse(fs.readFileSync(this.file,"utf8")) :{} } get(key,optionalValue) { - return this.info[key]===undefined ? optionalValue : this.info[key] + return this.info.hasOwnProperty(key) ? this.info[key]: optionalValue } set(key, value){ this.info[key] = value @@ -44,11 +44,10 @@ function recentMenu() {// builds the recent file submenu })) } store.set('files', recentFiles) - // localStorage.setItem("files", JSON.stringify(recentFiles)); }; -var recentFiles =store.get('files',[]) // JSON.parse(localStorage.getItem("files")); +var recentFiles =store.get('files',[]) if (recentFiles.length!=0) recentMenu(); var recentLocation = store.get('recent',os.userInfo().homedir) @@ -86,8 +85,8 @@ if (app.isPackaged) { -// var fl = store.get('autosave',0)// JSON.parse(localStorage.getItem("autosave")); -var autoSave = parseInt(store.get('autosave',0)) // fl!==null? parseInt(fl) : 0; // autosave file every, 0 means no autosave + +var autoSave = parseInt(store.get('autosave',0)) // autosave file every, 0 means no autosave var autoSaveMenuItems = menu.getMenuItemById('autosave').submenu.items; autoSaveMenuItems.forEach(e=>{e.checked=false}) autoSaveMenuItems[{0:0,1:1,5:2,10:3}[autoSave]].checked = true diff --git a/src/js/keyIpcTrigger.js b/src/js/keyIpcTrigger.js index fc485e7..6005cce 100644 --- a/src/js/keyIpcTrigger.js +++ b/src/js/keyIpcTrigger.js @@ -200,7 +200,7 @@ function ipcTrigger(_,d){ autoSaveMenuItems[{0:0,1:1,5:2,10:3}[autoSave]].checked = true saveRemminder() // localStorage.setItem( "autosave", JSON.stringify(autoSave)) - StorageEvent.set('autosave',autoSave) + store.set('autosave',autoSave) } } @@ -417,9 +417,3 @@ document.getElementById("valinput").onchange = document.getElementById('valBtn') setValue($('#valinput').val()) $('.popup').hide() } - - -// document.getElementById("autoSaveVal").onchange = document.getElementById('autoSaveBtn').onclick = ()=>{ -// autoSave = parseInt($('#autoSaveVal').val()*1000) -// $('.popup').hide() -// } diff --git a/src/js/version.js b/src/js/version.js index 27ccd32..b1bd48e 100644 --- a/src/js/version.js +++ b/src/js/version.js @@ -14,7 +14,7 @@ function _versionCheck() { buttons: ['OK', "Cancel"] }) if (!res) { - shell.openExternal("https://github.com/Koushikphy/Interactive_Data_Editor/releases/latest") + shell.openExternal("https://koushikphy.github.io/Interactive_Data_Editor/") } } })