Skip to content

Commit

Permalink
eventLIsterner 1x only (document is kept during reload)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Link committed Mar 25, 2019
1 parent 85f831f commit 3deff38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ upstream repo is `git clone https://github.com/ericlink/electron-forge-webapp-te
- [ ] zoom by window?

### tech
- [ ] auto updater using git releases
- [ ] get electron-forge start working (not passing arg; detect mode and default arg to readme?)
- [ ] installer - install command line script
- [ ] load modules more efficiently?
Expand All @@ -45,6 +46,7 @@ upstream repo is `git clone https://github.com/ericlink/electron-forge-webapp-te
- [ ] mac code signing

## done
- [x] open url only add listener once, not every reload
- [x] export menu (html, open in browser)
- [x] open links in os browser
- [x] expand cmd args to absolute path
Expand Down
16 changes: 8 additions & 8 deletions src/renderer/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const remote = require('electron').remote
const shell = require('electron').shell;

const readFile = (file) => {
log.info('readFile', file);
//log.info('readFile', file);
fs.readFile(file, (err, data) => {
if (err) log.error('readFile', err);
if (!data || data.length == 0) log.error('readFile', 'no data');
Expand All @@ -22,13 +22,6 @@ const readFile = (file) => {
Array.from(document.querySelectorAll('.lang-mermaid')).forEach(
block => mermaid.init(undefined, block)
);
// open all links in external browser
document.addEventListener('click', function (event) {
if (event.target.tagName === 'A' && event.target.href.startsWith('http')) {
event.preventDefault();
shell.openExternal(event.target.href);
}
})
})
}

Expand Down Expand Up @@ -66,6 +59,13 @@ const watchFile = (file) => {
})
}

// open all links in external browser
document.addEventListener('click', function (event) {
if (event.target.tagName === 'A' && event.target.href.startsWith('http')) {
event.preventDefault();
shell.openExternal(event.target.href);
}
})
const file = getFileName();
initMermaid();
readFile(file);
Expand Down

0 comments on commit 3deff38

Please sign in to comment.