1
var current_torrent = 0;
3
function show_torrent_details(tor)
5
update_torrent_details(tor);
6
show_div("torrent_details");
9
function update_torrent_details(tor)
11
current_torrent = tor;
12
fetch_xml("/data/torrent/files.xml?torrent=" + tor,update_torrent_details_table,show_error);
15
function update_torrent_details_table(xmldoc)
17
// Make sure errors are cleared
20
var newtable = document.createElement('table');
21
newtable.setAttribute('id', 'torrent_details_table');
22
newtable.className='list_table';
24
var files = xmldoc.getElementsByTagName('file');
28
file_row(files[i], newtable, i);
32
file_header(newtable.insertRow(0));
34
var oldtable = document.getElementById('torrent_details_table');
35
oldtable.parentNode.replaceChild(newtable, oldtable);
38
function file_row(element,table,i)
40
var row = table.insertRow(i);
41
var actions = row.insertCell(0);
42
var file = row.insertCell(1);
43
var priority = row.insertCell(2);
44
var size = row.insertCell(3);
45
var perc = row.insertCell(4);
47
row.setAttribute('class',(i % 2 == 0) ? 'even' : 'odd');
49
var file_status = element.getElementsByTagName('priority')[0].firstChild.data;
51
command = (file_status==20 || file_status==10) ? '' : "file_stop=" + current_torrent + "-" +i;
52
actions.appendChild(create_priority_button("Only Seed","/only_seed.png",command));
54
command = (file_status==30) ? '' : "file_lp=" + current_torrent + "-" +i;
55
actions.appendChild(create_priority_button("Low Priority","/low_priority.png",command));
57
command = (file_status==40) ? '' : "file_np=" + current_torrent + "-" +i;
58
actions.appendChild(create_priority_button("Normal Priority","/normal_priority.png",command));
60
command = (file_status==50) ? '' : "file_hp=" + current_torrent + "-" +i;
61
actions.appendChild(create_priority_button("High Priority","/high_priority.png",command));
63
actions.setAttribute("align","center");
64
file.appendChild(get_text(element,"path"));
65
size.appendChild(get_text(element,"size"));
66
priority.appendChild(priority_node(element));
67
var el = get_text(element,"percentage");
72
function file_header(row)
74
headers = new Array("Actions","File","Priority","Size","Complete");
75
for (var i in headers)
77
var header = document.createElement("th");
78
header.appendChild(document.createTextNode(headers[i]));
79
row.appendChild(header);
85
function priority_node(element)
87
var prio = element.getElementsByTagName('priority')[0].firstChild.data;
90
case '50': return document.createTextNode('Download First');
91
case '40': return document.createTextNode('Download Normally');
92
case '30': return document.createTextNode('Download Last');
93
case '20': return document.createTextNode('Only Seed');
94
case '10': return document.createTextNode('Do Not Download');
95
default: return document.createTextNode('Unknown');
99
function create_priority_button(button_name, image_src, command)
101
var image = document.createElement("img");
102
image.setAttribute("src", image_src);
103
image.setAttribute("alt", button_name);
104
image.setAttribute("title", button_name);
108
var a = document.createElement("a");
109
a.setAttribute("href", "javascript:do_action(\"" + command + "\"); update_torrent_details(current_torrent);");
110
a.appendChild(image);