mirror of
https://github.com/ronggang/transmission-web-control.git
synced 2024-09-21 07:15:33 +00:00
b879adb4b1
* 修改原来设置RPC路径的方式; * 删除种子提示对话框从每次从服务器读到改为只读取一次模板数据; * 添加 Brazilian Portuguese 葡萄牙语(巴西) 语言包,感谢 Dudu Maroja * 添加荷兰语语言包,感谢Alwin Hummels; * Fix some bug
160 lines
5.2 KiB
HTML
160 lines
5.2 KiB
HTML
<div class="easyui-layout" data-options="fit:true" style="width:100%;height:100%;">
|
|
<div data-options="region:'center'" style="padding:5px 6px 0px 6px;border:0px;">
|
|
<div id="" class="dialog" style="width:100%;padding:0px;">
|
|
<table style="width:100%;">
|
|
<tr>
|
|
<td width="20%" class="title"><span id="dialog-torrent-add-download-dir"></span></td>
|
|
<td width="80%">
|
|
<select id="download-dir" style="width:450px;"></select>
|
|
<input type="checkbox" id="set-default-download-dir" style="width:20px;"/><label for="set-default-download-dir" id="dialog-torrent-add-set-default-download-dir"></label>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="title"><label id="dialog-torrent-add-upload-file" for="torrent_upload_file"></label></td>
|
|
<td>
|
|
<select id="torrent_upload_file" style="height:120px;" multiple="multiple"></select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2">
|
|
<hr/>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="title"><span id="dialog-torrent-add-autostart"></span></td>
|
|
<td>
|
|
<input type="checkbox" id="chkautostart" style="width:20px;"/><label for="chkautostart" id="dialog-torrent-add-tip-autostart"></label>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div data-options="region:'south',border:false" style="text-align:right;padding:6px;">
|
|
<span id="dialog-torrent-add-queue" style="display:none;"></span>
|
|
<a id="torrent-button-ok" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" href="javascript:void(0);">Ok</a>
|
|
<a id="torrent-button-cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" href="javascript:void(0);">Cancel</a>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
(function(thisDialog){
|
|
var title = "download-dir,autostart,tip-autostart,set-default-download-dir,upload-file".split(",");
|
|
$.each(title, function(i, item){
|
|
thisDialog.find("#dialog-torrent-add-"+item).html(system.lang.dialog["torrent-add"][item]);
|
|
});
|
|
|
|
title = "button-ok,button-cancel".split(",");
|
|
$.each(title, function(i, item){
|
|
thisDialog.find("#torrent-"+item).html(system.lang.dialog.public[item]);
|
|
});
|
|
|
|
thisDialog.find("#download-dir").val(system.downloadDir);
|
|
$.each(transmission.downloadDirs, function(i, item){
|
|
$("<option/>").text(item).val(item).attr("selected",(item==system.downloadDir?true:false)).appendTo(thisDialog.find("#download-dir"));
|
|
});
|
|
if (transmission.downloadDirs.length==0)
|
|
{
|
|
$("<option/>").text(system.downloadDir).val(system.downloadDir).attr("selected",true).appendTo(thisDialog.find("#download-dir"));
|
|
}
|
|
thisDialog.find("#download-dir").combobox();
|
|
$.each(thisDialog.data("files"),function(i,item){
|
|
$("<option/>").text((i+1)+"."+item.name).appendTo(thisDialog.find("#torrent_upload_file"));
|
|
});
|
|
|
|
// 确认
|
|
thisDialog.find("#torrent-button-ok").click(function()
|
|
{
|
|
var dir = thisDialog.find("#download-dir").combobox("getValue");
|
|
var olddir = system.downloadDir;
|
|
var isnewdir = system.serverConfig["download-dir"]!=dir;
|
|
var autostart = thisDialog.find("#chkautostart").prop("checked");
|
|
var button = $(this);
|
|
|
|
if (dir=="")
|
|
{
|
|
return;
|
|
}
|
|
|
|
button.linkbutton({disabled:true});
|
|
|
|
if (thisDialog.find("#set-default-download-dir").prop("checked")&&isnewdir)
|
|
{
|
|
updateDownloadDir(dir);
|
|
}
|
|
|
|
var files = thisDialog.data("files");
|
|
var uploaded = 0;
|
|
$.each(files,function(i,item){
|
|
transmission.addTorrentFromFile(item,dir,!autostart,function(){
|
|
uploaded++;
|
|
thisDialog.find("#dialog-torrent-add-queue").html(uploaded+"/"+files.length).show();
|
|
if (uploaded==files.length)
|
|
{
|
|
thisDialog.find("#dialog-torrent-add-queue").html("").hide();
|
|
button.linkbutton({disabled:false});
|
|
thisDialog.dialog("close");
|
|
}
|
|
system.reloadData();
|
|
});
|
|
});
|
|
|
|
//thisDialog.dialog("close");
|
|
});
|
|
|
|
thisDialog.find("#torrent-button-cancel").click(function()
|
|
{
|
|
thisDialog.dialog("close");
|
|
});
|
|
|
|
// 保存上传目录
|
|
function updateDownloadDir(dir,callback)
|
|
{
|
|
transmission.exec(
|
|
{
|
|
method:"session-set"
|
|
,arguments:{"download-dir":dir}
|
|
}
|
|
,function(data){
|
|
if (data.result=="success")
|
|
{
|
|
system.downloadDir = dir;
|
|
system.serverConfig["download-dir"] = dir;
|
|
if (callback)
|
|
{
|
|
callback();
|
|
}
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
// 上传文件
|
|
// 2013/3/11 起失效
|
|
function uploadFile(paused,callback){
|
|
var xhr = new XMLHttpRequest();
|
|
var files = thisDialog.data("files");
|
|
xhr.open("POST", "../upload?paused=" + paused);
|
|
|
|
xhr.onload = function() {
|
|
if (callback)
|
|
callback();
|
|
|
|
thisDialog.find("#torrent-button-ok").linkbutton({disabled:false});
|
|
thisDialog.dialog("close");
|
|
system.reloadData();
|
|
};
|
|
|
|
xhr.onerror = function() {
|
|
system.debug("this.responseText:",this.responseText);
|
|
};
|
|
|
|
// prepare FormData
|
|
var formData = new FormData();
|
|
$.each(files,function(i,item){
|
|
formData.append("torrent_files[]", item);
|
|
});
|
|
|
|
formData.append("X-Transmission-Session-Id",transmission.SessionId);
|
|
xhr.send(formData);
|
|
}
|
|
})($("#dialog-torrent-addfile"));
|
|
</script> |