Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.catch((err) => {
if (err.message.toString().toLowerCase().indexOf('user') === -1) {
dialog.showErrorBox(T('Printing error'), T('Failed to print'))
}
return Promise.resolve()
})
.then(() => { // Always
_handleWillPreventUnload = (evt) => {
const bw = BrowserWindow.fromWebContents(ElectronWebContents.rootWebContents(evt.sender))
if (!bw || bw.isDestroyed()) { return }
const choice = dialog.showMessageBox(bw, {
type: 'question',
buttons: [T('Leave'), T('Stay')],
title: '',
message: T('Do you want to leave this site?'),
detail: T('Changes you made may not be saved.'),
defaultId: 0,
cancelId: 1
})
if (choice === 0) {
evt.preventDefault()
}
}
if (title === 'wbaction:print') {
window.webContents.print({ silent: false, printBackground: false, deviceName: '' }, (success) => {
this._pdfPrintCleanup(tmpDownloadPath, window)
if (success) {
resolve()
} else {
reject(new Error(T('Printing Error')))
}
})
} else if (title === 'wbaction:error') {
this._pdfPrintCleanup(tmpDownloadPath, window)
reject(new Error(T('Printing Error')))
} else if (title === 'wbaction:cancel') {
this._pdfPrintCleanup(tmpDownloadPath, window)
reject(new Error(T('User cancelled')))
}
}
})
window.loadURL(`file://${Resolver.printScene('index.html')}`)
const { showRestart, userIsLoggedIn, userEmail } = this.state
const { classes, match } = this.props
const tab = match.params.tab || 'general'
const tabArg = match.params.tabArg
return (
_handleWillPreventUnload = (evt) => {
const bw = BrowserWindow.fromWebContents(ElectronWebContents.rootWebContents(evt.sender))
if (!bw || bw.isDestroyed()) { return }
const choice = dialog.showMessageBox(bw, {
type: 'question',
buttons: [T('Leave'), T('Stay')],
title: '',
message: T('Do you want to leave this site?'),
detail: T('Changes you made may not be saved.'),
defaultId: 0,
cancelId: 1
})
if (choice === 0) {
evt.preventDefault()
}
}
_injectPrintButton (wc) {
wc.executeJavaScript(`
;(function () {
const printButton = document.createElement('paper-icon-button')
printButton.id = 'print'
printButton.setAttribute('icon', 'cr:print')
printButton.setAttribute('aria-label', '${T('Print')}')
printButton.setAttribute('title', '${T('Print')}')
printButton.addEventListener('click', () => {
document.title = 'wbaction:print'
})
const toolbar = document.querySelector('#toolbar').shadowRoot
const downloadButton = toolbar.querySelector('#download')
downloadButton.parentElement.insertBefore(printButton, downloadButton.nextSibling)
})()
`)
}
<div>{T('Wavebox Subscription')}</div>
<div>{userEmail}</div>
) : T('Wavebox Subscription')}
className={classes.tabButton}
value='pro' />
{this.renderTab(classes, tab, tabArg)}
<button color="{showRestart"></button>
_injectPrintButton (wc) {
wc.executeJavaScript(`
;(function () {
const printButton = document.createElement('paper-icon-button')
printButton.id = 'print'
printButton.setAttribute('icon', 'cr:print')
printButton.setAttribute('aria-label', '${T('Print')}')
printButton.setAttribute('title', '${T('Print')}')
printButton.addEventListener('click', () => {
document.title = 'wbaction:print'
})
const toolbar = document.querySelector('#toolbar').shadowRoot
const downloadButton = toolbar.querySelector('#download')
downloadButton.parentElement.insertBefore(printButton, downloadButton.nextSibling)
})()
`)
}