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
|
||||
}
|
||||
|
||||
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) {
|
||||
debug('action %s', action)
|
||||
if (action === 'addTorrentFromPaste') {
|
||||
addTorrentFromPaste()
|
||||
}
|
||||
})
|
||||
|
||||
var template = [
|
||||
@@ -147,14 +177,7 @@ var template = [
|
||||
{
|
||||
label: 'Paste',
|
||||
accelerator: 'CmdOrCtrl+V',
|
||||
click: function () {
|
||||
var torrentIds = electron.clipboard.readText().split('\n')
|
||||
torrentIds.forEach(function (torrentId) {
|
||||
torrentId = torrentId.trim()
|
||||
if (torrentId.length === 0) return
|
||||
mainWindow.send('action', 'addTorrent', torrentId)
|
||||
})
|
||||
}
|
||||
role: 'paste'
|
||||
},
|
||||
{
|
||||
label: 'Select All',
|
||||
@@ -183,7 +206,7 @@ var template = [
|
||||
label: 'Reload',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
click: function (item, focusedWindow) {
|
||||
reload(focusedWindow)
|
||||
reloadWindow(focusedWindow)
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -193,7 +216,7 @@ var template = [
|
||||
else return 'Ctrl+Shift+I'
|
||||
})(),
|
||||
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
|
||||
// setInterval(function () {
|
||||
// progress += 0.1
|
||||
|
||||
@@ -69,6 +69,12 @@ function init () {
|
||||
airplay.createBrowser().on('deviceOn', function (player) {
|
||||
state.airplay = player
|
||||
}).start()
|
||||
|
||||
document.addEventListener('paste', function () {
|
||||
electron.ipcRenderer.send('action', 'addTorrentFromPaste')
|
||||
})
|
||||
|
||||
handler('addTorrent', 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4')
|
||||
}
|
||||
init()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user