chore: always lint JS in docs/fiddles (#38025)
This commit is contained in:
parent
141f65b291
commit
9b41ab1e53
16 changed files with 86 additions and 98 deletions
|
@ -2,5 +2,5 @@ const NOTIFICATION_TITLE = 'Title'
|
|||
const NOTIFICATION_BODY = 'Notification from the Renderer process. Click to log to console.'
|
||||
const CLICK_MESSAGE = 'Notification clicked!'
|
||||
|
||||
new Notification(NOTIFICATION_TITLE, { body: NOTIFICATION_BODY })
|
||||
.onclick = () => document.getElementById('output').innerText = CLICK_MESSAGE
|
||||
new window.Notification(NOTIFICATION_TITLE, { body: NOTIFICATION_BODY })
|
||||
.onclick = () => { document.getElementById('output').innerText = CLICK_MESSAGE }
|
||||
|
|
|
@ -4,16 +4,31 @@ const path = require('path')
|
|||
|
||||
app.disableHardwareAcceleration()
|
||||
|
||||
let win
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
offscreen: true
|
||||
}
|
||||
})
|
||||
|
||||
app.whenReady().then(() => {
|
||||
win = new BrowserWindow({ webPreferences: { offscreen: true } })
|
||||
win.loadURL('https://github.com')
|
||||
win.webContents.on('paint', (event, dirty, image) => {
|
||||
fs.writeFileSync('ex.png', image.toPNG())
|
||||
})
|
||||
win.webContents.setFrameRate(60)
|
||||
console.log(`The screenshot has been successfully saved to ${path.join(process.cwd(), 'ex.png')}`)
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
|
@ -21,9 +36,3 @@ app.on('window-all-closed', () => {
|
|||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
let bluetoothPinCallback
|
||||
let bluetoothPinCallback
|
||||
let selectBluetoothCallback
|
||||
|
||||
function createWindow () {
|
||||
|
@ -24,13 +24,12 @@ function createWindow () {
|
|||
} else {
|
||||
// The device wasn't found so we need to either wait longer (eg until the
|
||||
// device is turned on) or until the user cancels the request
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('cancel-bluetooth-request', (event) => {
|
||||
selectBluetoothCallback('')
|
||||
})
|
||||
|
||||
|
||||
// Listen for a message from the renderer to get the response for the Bluetooth pairing.
|
||||
ipcMain.on('bluetooth-pairing-response', (event, response) => {
|
||||
|
|
|
@ -7,7 +7,7 @@ async function testIt () {
|
|||
|
||||
document.getElementById('clickme').addEventListener('click', testIt)
|
||||
|
||||
function cancelRequest() {
|
||||
function cancelRequest () {
|
||||
window.electronAPI.cancelBluetoothRequest()
|
||||
}
|
||||
|
||||
|
@ -18,15 +18,15 @@ window.electronAPI.bluetoothPairingRequest((event, details) => {
|
|||
|
||||
switch (details.pairingKind) {
|
||||
case 'confirm': {
|
||||
response.confirmed = confirm(`Do you want to connect to device ${details.deviceId}?`)
|
||||
response.confirmed = window.confirm(`Do you want to connect to device ${details.deviceId}?`)
|
||||
break
|
||||
}
|
||||
case 'confirmPin': {
|
||||
response.confirmed = confirm(`Does the pin ${details.pin} match the pin displayed on device ${details.deviceId}?`)
|
||||
response.confirmed = window.confirm(`Does the pin ${details.pin} match the pin displayed on device ${details.deviceId}?`)
|
||||
break
|
||||
}
|
||||
case 'providePin': {
|
||||
const pin = prompt(`Please provide a pin for ${details.deviceId}.`)
|
||||
const pin = window.prompt(`Please provide a pin for ${details.deviceId}.`)
|
||||
if (pin) {
|
||||
response.pin = pin
|
||||
response.confirmed = true
|
||||
|
|
|
@ -23,6 +23,7 @@ function createWindow () {
|
|||
if (portList && portList.length > 0) {
|
||||
callback(portList[0].portId)
|
||||
} else {
|
||||
// eslint-disable-next-line standard/no-callback-literal
|
||||
callback('') // Could not find any matching devices
|
||||
}
|
||||
})
|
||||
|
|
|
@ -20,7 +20,7 @@ async function testIt () {
|
|||
const grantedDevice = await navigator.usb.requestDevice({
|
||||
filters: []
|
||||
})
|
||||
grantedDeviceList += `<hr>${getDeviceDetails(device)}</hr>`
|
||||
grantedDeviceList += `<hr>${getDeviceDetails(grantedDevice)}</hr>`
|
||||
} catch (ex) {
|
||||
if (ex.name === 'NotFoundError') {
|
||||
grantedDeviceList = noDevicesFoundMsg
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue