don't override paste command in dev tools
This commit is contained in:
60
index.js
60
index.js
@@ -80,8 +80,38 @@ function createMainWindow () {
|
|||||||
return win
|
return win
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addTorrentFromPaste () {
|
||||||
|
var torrentIds = electron.clipboard.readText().split('\n')
|
||||||
|
console.log(torrentIds)
|
||||||
|
torrentIds.forEach(function (torrentId) {
|
||||||
|
torrentId = torrentId.trim()
|
||||||
|
if (torrentId.length === 0) return
|
||||||
|
mainWindow.send('action', 'addTorrent', torrentId)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleDevTools (win) {
|
||||||
|
win = win || electron.BrowserWindow.getFocusedWindow()
|
||||||
|
|
||||||
|
if (win) {
|
||||||
|
win.toggleDevTools()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function reloadWindow (win) {
|
||||||
|
win = win || electron.BrowserWindow.getFocusedWindow()
|
||||||
|
|
||||||
|
if (win) {
|
||||||
|
startTime = Date.now()
|
||||||
|
win.webContents.reloadIgnoringCache()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
electron.ipcMain.on('action', function (event, action, ...args) {
|
electron.ipcMain.on('action', function (event, action, ...args) {
|
||||||
debug('action %s', action)
|
debug('action %s', action)
|
||||||
|
if (action === 'addTorrentFromPaste') {
|
||||||
|
addTorrentFromPaste()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var template = [
|
var template = [
|
||||||
@@ -147,14 +177,7 @@ var template = [
|
|||||||
{
|
{
|
||||||
label: 'Paste',
|
label: 'Paste',
|
||||||
accelerator: 'CmdOrCtrl+V',
|
accelerator: 'CmdOrCtrl+V',
|
||||||
click: function () {
|
role: 'paste'
|
||||||
var torrentIds = electron.clipboard.readText().split('\n')
|
|
||||||
torrentIds.forEach(function (torrentId) {
|
|
||||||
torrentId = torrentId.trim()
|
|
||||||
if (torrentId.length === 0) return
|
|
||||||
mainWindow.send('action', 'addTorrent', torrentId)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Select All',
|
label: 'Select All',
|
||||||
@@ -183,7 +206,7 @@ var template = [
|
|||||||
label: 'Reload',
|
label: 'Reload',
|
||||||
accelerator: 'CmdOrCtrl+R',
|
accelerator: 'CmdOrCtrl+R',
|
||||||
click: function (item, focusedWindow) {
|
click: function (item, focusedWindow) {
|
||||||
reload(focusedWindow)
|
reloadWindow(focusedWindow)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -193,7 +216,7 @@ var template = [
|
|||||||
else return 'Ctrl+Shift+I'
|
else return 'Ctrl+Shift+I'
|
||||||
})(),
|
})(),
|
||||||
click: function (item, focusedWindow) {
|
click: function (item, focusedWindow) {
|
||||||
devTools(focusedWindow)
|
toggleDevTools(focusedWindow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -296,23 +319,6 @@ if (process.platform === 'darwin') {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function devTools (win) {
|
|
||||||
win = win || electron.BrowserWindow.getFocusedWindow()
|
|
||||||
|
|
||||||
if (win) {
|
|
||||||
win.toggleDevTools()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function reload (win) {
|
|
||||||
win = win || electron.BrowserWindow.getFocusedWindow()
|
|
||||||
|
|
||||||
if (win) {
|
|
||||||
startTime = Date.now()
|
|
||||||
win.webContents.reloadIgnoringCache()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// var progress = 0
|
// var progress = 0
|
||||||
// setInterval(function () {
|
// setInterval(function () {
|
||||||
// progress += 0.1
|
// progress += 0.1
|
||||||
|
|||||||
@@ -69,6 +69,12 @@ function init () {
|
|||||||
airplay.createBrowser().on('deviceOn', function (player) {
|
airplay.createBrowser().on('deviceOn', function (player) {
|
||||||
state.airplay = player
|
state.airplay = player
|
||||||
}).start()
|
}).start()
|
||||||
|
|
||||||
|
document.addEventListener('paste', function () {
|
||||||
|
electron.ipcRenderer.send('action', 'addTorrentFromPaste')
|
||||||
|
})
|
||||||
|
|
||||||
|
handler('addTorrent', 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4')
|
||||||
}
|
}
|
||||||
init()
|
init()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user