<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>FatRat - transfer details</title>
<link rel="icon" href="/favicon.png" type="image/png"/>
<link rel="stylesheet" type="text/css" href="/style.css"/>
<script type="text/javascript" src="/filedialog/api.js"></script>
</head>
<body>

<?qs
	var queue, transfer;
	for(var i=0;i<QUEUES.length;i++)
	{
		queue = QUEUES[i];
		for(var j=0;j<queue.size;j++)
		{
			if(queue.at(j).uuid == GET.transfer)
			{
				transfer = queue.at(j);
				break;
			}
		}
	}
	
	if(!transfer)
	{
		print('<h2>Transfer not found!</h2>');
		terminate();
	}
	
	if(POST.save != undefined)
	{
		if(transfer.object != POST.object)
			transfer.object = POST.object;
		transfer.setUserSpeedLimits(POST.downLimit*1024, POST.upLimit*1024);
		transfer.comment = POST.comment;
		print('<p style="color: green">Saved.</p>');
	}
	
	function escapeAmpersand(text)
	{
		text = new String(text);
		return text.split('&').join('&amp;');
	}
?>

<p style="text-align: center"><b>Transfer details</b></p>

<form method="post" action="?<?qs print(escapeAmpersand(QUERY_STRING));?>">

<table class="transfers">
<tr><td>Name</td><td><?qs print(transfer.name) ?></td></tr>
<tr>
	<td><?qs if(transfer.primaryMode == 1) print('Destination'); else print('Source'); ?></td>
	<td>
		<input type="text" name="object" id="object" style="width: 90%" value="<?qs print(transfer.object) ?>"/>
		<input type="button" value="..." onclick="javascript: dirDialog('object')" <?qsif(transfer.primaryMode != 1) print('style="visibility: hidden"'); ?>/>
	</td>
</tr>
<tr>
	<td>Max. download speed</td>
	<td>
		<?qs var speed = transfer.speedLimits(); ?>
		<input type="text" size="4" name="downLimit" value="<?qs print(speed.down/1024); ?>"/> kB/s
	</td>
</tr>
<tr>
	<td>Max. upload speed</td>
	<td>
		<input type="text" size="4" name="upLimit" value="<?qs print(speed.up/1024); ?>"/> kB/s
	</td>
</tr>
<tr>
	<td>Comment</td>
	<td>
		<textarea name="comment" rows="10" cols="10" style="width: 100%"><?qs print(transfer.comment); ?></textarea>
	</td>
</tr>
</table>

<p style="text-align: center">
	<input type="submit" name="save" value="Apply"/>
	<input type="button" value="Close" onclick="javascript:window.close()"/>
</p>
</form>

</body></html>
