|
|
@ -2,7 +2,7 @@ |
|
|
|
<table class="torrentTable" cellpadding="0" cellspacing="0"> |
|
|
|
<table class="torrentTable" cellpadding="0" cellspacing="0"> |
|
|
|
<thead> |
|
|
|
<thead> |
|
|
|
<tr> |
|
|
|
<tr> |
|
|
|
<th>_(Downloaded)</th> |
|
|
|
<th><a id="all_files_cb" style="margin-right: 2px;" class="tristate" onclick="javascript:switchCBState()"></a> _(Downloaded)</th> |
|
|
|
<th>_(Name)</th> |
|
|
|
<th>_(Name)</th> |
|
|
|
<th>_(Size)</th> |
|
|
|
<th>_(Size)</th> |
|
|
|
<th style="width: 90px;">_(Progress)</th> |
|
|
|
<th style="width: 90px;">_(Progress)</th> |
|
|
@ -16,10 +16,85 @@ |
|
|
|
<script type="text/javascript"> |
|
|
|
<script type="text/javascript"> |
|
|
|
var waitingTorrentFiles=false; |
|
|
|
var waitingTorrentFiles=false; |
|
|
|
var current_hash = ""; |
|
|
|
var current_hash = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var setCBState = function(state) { |
|
|
|
|
|
|
|
if(state == "partial") { |
|
|
|
|
|
|
|
if(!$("all_files_cb").hasClass("partial")) { |
|
|
|
|
|
|
|
$("all_files_cb").removeClass("checked"); |
|
|
|
|
|
|
|
$("all_files_cb").addClass("partial"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(state == "checked") { |
|
|
|
|
|
|
|
if(!$("all_files_cb").hasClass("checked")) { |
|
|
|
|
|
|
|
$("all_files_cb").removeClass("partial"); |
|
|
|
|
|
|
|
$("all_files_cb").addClass("checked"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$("all_files_cb").removeClass("partial"); |
|
|
|
|
|
|
|
$("all_files_cb").removeClass("checked"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var switchCBState = function() { |
|
|
|
|
|
|
|
// Uncheck |
|
|
|
|
|
|
|
if($("all_files_cb").hasClass("partial")) { |
|
|
|
|
|
|
|
$("all_files_cb").removeClass("partial"); |
|
|
|
|
|
|
|
// Uncheck all checkboxes |
|
|
|
|
|
|
|
$$('input.DownloadedCB').each(function(item, index) { |
|
|
|
|
|
|
|
item.erase("checked"); |
|
|
|
|
|
|
|
setFilePriority(index, 0); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if($("all_files_cb").hasClass("checked")) { |
|
|
|
|
|
|
|
$("all_files_cb").removeClass("checked"); |
|
|
|
|
|
|
|
// Uncheck all checkboxes |
|
|
|
|
|
|
|
$$('input.DownloadedCB').each(function(item, index) { |
|
|
|
|
|
|
|
item.erase("checked"); |
|
|
|
|
|
|
|
setFilePriority(index, 0); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Check |
|
|
|
|
|
|
|
$("all_files_cb").addClass("checked"); |
|
|
|
|
|
|
|
// Check all checkboxes |
|
|
|
|
|
|
|
$$('input.DownloadedCB').each(function(item, index) { |
|
|
|
|
|
|
|
item.set("checked", "checked"); |
|
|
|
|
|
|
|
setFilePriority(index, 1); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var allCBChecked = function() { |
|
|
|
|
|
|
|
var CBs = $$('input.DownloadedCB'); |
|
|
|
|
|
|
|
for(var i=0; i<CBs.length; i+=1) { |
|
|
|
|
|
|
|
var item = CBs[i]; |
|
|
|
|
|
|
|
if(!$defined(item.get('checked')) || !item.get('checked')) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var allCBUnchecked = function() { |
|
|
|
|
|
|
|
var CBs = $$('input.DownloadedCB'); |
|
|
|
|
|
|
|
for(var i=0; i<CBs.length; i+=1) { |
|
|
|
|
|
|
|
var item = CBs[i]; |
|
|
|
|
|
|
|
if($defined(item.get('checked')) && item.get('checked')) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var setFilePriority = function(id, priority) { |
|
|
|
var setFilePriority = function(id, priority) { |
|
|
|
if(current_hash == "") return; |
|
|
|
if(current_hash == "") return; |
|
|
|
new Request({url: '/command/setFilePrio', method: 'post', data: {'hash': current_hash, 'id': id, 'priority': priority}}).send(); |
|
|
|
new Request({url: '/command/setFilePrio', method: 'post', data: {'hash': current_hash, 'id': id, 'priority': priority}}).send(); |
|
|
|
|
|
|
|
// Display or add combobox |
|
|
|
|
|
|
|
if(priority > 0) { |
|
|
|
|
|
|
|
$('comboPrio'+id).set("value", 1); |
|
|
|
|
|
|
|
$('comboPrio'+id).removeClass("invisible"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$('comboPrio'+id).addClass("invisible"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var createDownloadedCB = function(id, downloaded) { |
|
|
|
var createDownloadedCB = function(id, downloaded) { |
|
|
@ -28,17 +103,20 @@ var createDownloadedCB = function(id, downloaded) { |
|
|
|
if(downloaded) |
|
|
|
if(downloaded) |
|
|
|
CB.set('checked', 'checked'); |
|
|
|
CB.set('checked', 'checked'); |
|
|
|
CB.set('id', 'cbPrio'+id); |
|
|
|
CB.set('id', 'cbPrio'+id); |
|
|
|
|
|
|
|
CB.set('class', 'DownloadedCB'); |
|
|
|
CB.addEvent('change', function(e){ |
|
|
|
CB.addEvent('change', function(e){ |
|
|
|
var checked = 0; |
|
|
|
var checked = 0; |
|
|
|
if($defined($('cbPrio'+id).get('checked')) && $('cbPrio'+id).get('checked')) |
|
|
|
if($defined($('cbPrio'+id).get('checked')) && $('cbPrio'+id).get('checked')) |
|
|
|
checked = 1; |
|
|
|
checked = 1; |
|
|
|
setFilePriority(id, checked); |
|
|
|
setFilePriority(id, checked); |
|
|
|
// Display or add combobox |
|
|
|
if(allCBChecked()) { |
|
|
|
if(checked) { |
|
|
|
setCBState("checked"); |
|
|
|
$('comboPrio'+id).set("value", 1); |
|
|
|
|
|
|
|
$('comboPrio'+id).removeClass("invisible"); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$('comboPrio'+id).addClass("invisible"); |
|
|
|
if(allCBUnchecked()) { |
|
|
|
|
|
|
|
setCBState("unchecked"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setCBState("partial"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
return CB; |
|
|
|
return CB; |
|
|
@ -113,7 +191,7 @@ var createPriorityCombo = function(id, selected_prio) { |
|
|
|
if(row[i] > 0) |
|
|
|
if(row[i] > 0) |
|
|
|
tds[i].getChildren('input')[0].set('checked', 'checked'); |
|
|
|
tds[i].getChildren('input')[0].set('checked', 'checked'); |
|
|
|
else |
|
|
|
else |
|
|
|
tds[i].removeProperty('checked') |
|
|
|
tds[i].getChildren('input')[0].removeProperty('checked') |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if(i == 4) { |
|
|
|
if(i == 4) { |
|
|
|
if(row[i] > 0) { |
|
|
|
if(row[i] > 0) { |
|
|
@ -148,7 +226,8 @@ var createPriorityCombo = function(id, selected_prio) { |
|
|
|
td.adopt(new ProgressBar(row[i].toFloat(), {'id': 'pbf_'+id, 'width':80})); |
|
|
|
td.adopt(new ProgressBar(row[i].toFloat(), {'id': 'pbf_'+id, 'width':80})); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if(i == 0) { |
|
|
|
if(i == 0) { |
|
|
|
td.adopt(createDownloadedCB(id,row[i])); |
|
|
|
var tree_img = new Element('img', {src: 'images/L.gif', style: 'margin-bottom: -2px'}); |
|
|
|
|
|
|
|
td.adopt(tree_img, createDownloadedCB(id,row[i])); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if(i == 4) { |
|
|
|
if(i == 4) { |
|
|
|
td.adopt(createPriorityCombo(id,row[i])); |
|
|
|
td.adopt(createPriorityCombo(id,row[i])); |
|
|
@ -206,6 +285,16 @@ var createPriorityCombo = function(id, selected_prio) { |
|
|
|
fTable.insertRow(i, row); |
|
|
|
fTable.insertRow(i, row); |
|
|
|
i++; |
|
|
|
i++; |
|
|
|
}.bind(this)); |
|
|
|
}.bind(this)); |
|
|
|
|
|
|
|
// Set global CB state |
|
|
|
|
|
|
|
if(allCBChecked()) { |
|
|
|
|
|
|
|
setCBState("checked"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if(allCBUnchecked()) { |
|
|
|
|
|
|
|
setCBState("unchecked"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setCBState("partial"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
fTable.removeAllRows(); |
|
|
|
fTable.removeAllRows(); |
|
|
|
} |
|
|
|
} |
|
|
|