Merge pull request #295 from xue-blood/master

新增 复制磁力链接到剪切板
This commit is contained in:
栽培者 2019-01-16 10:04:31 +08:00 committed by GitHub
commit b7c4202e4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 114 additions and 140 deletions

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Automatically matches data directory"
},
"setLabels": "Set User Labels"
"setLabels": "Set User Labels",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Navigation",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Elegir automáticamente directorio de datos"
},
"setLabels": "Set User Labels"
"setLabels": "Set User Labels",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Navegación",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Correspondance auto des dossiers de données"
},
"setLabels": "Personnaliser les étiquettes"
"setLabels": "Personnaliser les étiquettes",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Navigation",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Könyvtárak automatikus felismerése"
},
"setLabels": "Set User Labels"
"setLabels": "Set User Labels",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Navigáció",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Associa automaticamente cartella dati"
},
"setLabels": "Imposta Etichette Utente"
"setLabels": "Imposta Etichette Utente",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Navigazione",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "자동으로 데이터 폴더 일치시키기"
},
"setLabels": "Set User Labels"
"setLabels": "Set User Labels",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "안내",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Automatically matches data directory"
},
"setLabels": "Set User Labels"
"setLabels": "Set User Labels",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Navigatie",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Automatyczne dopasowanie katalogu"
},
"setLabels": "Ustaw własne etykiety"
"setLabels": "Ustaw własne etykiety",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Nawigacja",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Combinar automaticamente diretório de dados"
},
"setLabels": "Definir Rótulos do Usuário"
"setLabels": "Definir Rótulos do Usuário",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Navegação",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Combinar automaticamente o diretório de dados"
},
"setLabels": "Set User Labels"
"setLabels": "Set User Labels",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Navegação",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Automatically matches data directory"
},
"setLabels": "Set User Labels"
"setLabels": "Set User Labels",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Navigare",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Автосопоставление путей"
},
"setLabels": "Присвоить метки"
"setLabels": "Присвоить метки",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Навигация",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "Авто-зіставлення шляхів"
},
"setLabels": "Set User Labels"
"setLabels": "Set User Labels",
"copyMagnetLink": "Copy magnetLink to clipboard"
},
"title": {
"left": "Навігація",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "自动匹配数据目录"
},
"setLabels": "设置用户标签"
"setLabels": "设置用户标签",
"copyMagnetLink": "复制磁力链接到剪切板"
},
"title": {
"left": "导航",

View File

@ -85,7 +85,8 @@
"plugin": {
"auto-match-data-folder": "自動配對資料夾"
},
"setLabels": "設置使用者標籤"
"setLabels": "設置使用者標籤",
"copyMagnetLink": "复制磁力链接到剪切板"
},
"title": {
"left": "分類資料夾",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -928,7 +928,8 @@ var system = {
menus = new Array("start", "pause", "-",
"rename", "remove", "recheck", "-",
"morepeers", "changeDownloadDir", "copyPath", "-",
"menu-queue-move-top", "menu-queue-move-up", "menu-queue-move-down", "menu-queue-move-bottom"
"menu-queue-move-top", "menu-queue-move-up", "menu-queue-move-down", "menu-queue-move-bottom",
"magnetLink"
);
// 是否显示标签菜单
@ -1026,6 +1027,18 @@ var system = {
});
}
};
case "magnetLink":
return{
id: "magnetLink",
text: system.lang.menus.copyMagnetLink,
iconCls: "iconfont tr-icon-labels",
disabled: this.checkedRows.length==0,
onclick: function() {
system.getTorrentMagnetLink(function(data){
system.copyToClipboard(data);
});
}
}
}
},
/**
@ -1198,6 +1211,21 @@ var system = {
$("#clipboard-source").val("");
}
},
// by https://stackoverflow.com/questions/22581345/click-button-copy-to-clipboard-using-jquery?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
copyToClipboard: function (text) {
// Create a "hidden" input
var aux = document.createElement("input");
// Assign it the value of the specified element
aux.setAttribute("value", text);
// Append it to the body
document.body.appendChild(aux);
// Highlight its content
aux.select();
// Copy the highlighted text
document.execCommand("copy");
// Remove it from the body
document.body.removeChild(aux);
},
// Initialize the System Toolbar
initToolbar: function () {
// refresh time
@ -2452,6 +2480,15 @@ var system = {
});
}
},
// get the magnetlink of torrent
getTorrentMagnetLink: function (callback) {
var rows = this.control.torrentlist.datagrid("getChecked");
var ids = new Array();
for (var i in rows) {
ids.push(rows[i].id);
}
transmission.torrents.getMagnetLink(ids, callback);
},
// Looks for the specified torrent from the torrent list
searchTorrents: function (key) {
if (key == "") {

View File

@ -483,5 +483,49 @@ transmission.torrents = {
}
}, result[index].ids);
}
},
// 获取磁力链接
getMagnetLink: function(ids, callback){
var result = "";
// is single number
if(ids.constructor.name != "Array")
ids = [ids];
if(ids.length == 0) {
if(callback) callback(result);
return;
}
// 跳过己获取的
var req_list = [];
for(var id in ids){
id = ids[id];
if (!this.all[id]) continue;
if (!this.all[id].magnetLink)
req_list.push(id)
else
result += this.all[id].magnetLink + "\n";
}
if(req_list.length == 0){
if(callback) callback(result.trim());
return;
}
transmission.exec({
method: "torrent-get",
arguments: {
fields: [ "id", "magnetLink" ],
ids: req_list
}
}, function(data) {
if (data.result == "success") {
for(var item in data.arguments.torrents){
item = data.arguments.torrents[item];
transmission.torrents.all[item.id].magnetLink = item.magnetLink;
result += item.magnetLink + "\n";
}
if(callback) callback(result.trim());
}
});
}
};