electron/docs/fiddles/windows/manage-windows/manage-window-state/renderer.js
Milan Burda b14b876d50
docs: fix fiddles (#39060)
* refactor: replace Array.prototype.forEach.call with plain for-of

* fix: add missing contextIsolation: false

* fix: open links in default browser
2023-07-13 10:10:37 +02:00

25 lines
730 B
JavaScript

const { shell, ipcRenderer } = require('electron')
const manageWindowBtn = document.getElementById('manage-window')
const links = document.querySelectorAll('a[href]')
ipcRenderer.on('bounds-changed', (event, bounds) => {
const manageWindowReply = document.getElementById('manage-window-reply')
const message = `Size: ${bounds.size} Position: ${bounds.position}`
manageWindowReply.textContent = message
})
manageWindowBtn.addEventListener('click', (event) => {
ipcRenderer.send('create-demo-window')
})
for (const link of links) {
const url = link.getAttribute('href')
if (url.indexOf('http') === 0) {
link.addEventListener('click', (e) => {
e.preventDefault()
shell.openExternal(url)
})
}
}