|
|
@ -70,7 +70,7 @@ window.addEvent('load', function () { |
|
|
|
var properties_height_rel = $('propertiesPanel').getSize().y / Window.getSize().y; |
|
|
|
var properties_height_rel = $('propertiesPanel').getSize().y / Window.getSize().y; |
|
|
|
localStorage.setItem('filters_width', filters_width); |
|
|
|
localStorage.setItem('filters_width', filters_width); |
|
|
|
localStorage.setItem('properties_height_rel', properties_height_rel); |
|
|
|
localStorage.setItem('properties_height_rel', properties_height_rel); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
window.addEvent('resize', function() { |
|
|
|
window.addEvent('resize', function() { |
|
|
|
// Resizing might takes some time.
|
|
|
|
// Resizing might takes some time.
|
|
|
@ -128,7 +128,7 @@ window.addEvent('load', function () { |
|
|
|
// Reload torrents
|
|
|
|
// Reload torrents
|
|
|
|
if (typeof torrentsTable.tableBody != 'undefined') |
|
|
|
if (typeof torrentsTable.tableBody != 'undefined') |
|
|
|
updateMainData(); |
|
|
|
updateMainData(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
new MochaUI.Panel({ |
|
|
|
new MochaUI.Panel({ |
|
|
|
id : 'Filters', |
|
|
|
id : 'Filters', |
|
|
@ -151,10 +151,9 @@ window.addEvent('load', function () { |
|
|
|
initializeWindows(); |
|
|
|
initializeWindows(); |
|
|
|
|
|
|
|
|
|
|
|
// Show Top Toolbar is enabled by default
|
|
|
|
// Show Top Toolbar is enabled by default
|
|
|
|
if (localStorage.getItem('show_top_toolbar') == null) |
|
|
|
var showTopToolbar = true; |
|
|
|
var showTopToolbar = true; |
|
|
|
if (localStorage.getItem('show_top_toolbar') !== null) |
|
|
|
else |
|
|
|
showTopToolbar = localStorage.getItem('show_top_toolbar') == "true"; |
|
|
|
var showTopToolbar = localStorage.getItem('show_top_toolbar') == "true"; |
|
|
|
|
|
|
|
if (!showTopToolbar) { |
|
|
|
if (!showTopToolbar) { |
|
|
|
$('showTopToolbarLink').firstChild.style.opacity = '0'; |
|
|
|
$('showTopToolbarLink').firstChild.style.opacity = '0'; |
|
|
|
$('mochaToolbar').addClass('invisible'); |
|
|
|
$('mochaToolbar').addClass('invisible'); |
|
|
@ -171,7 +170,7 @@ window.addEvent('load', function () { |
|
|
|
var serverState = {}; |
|
|
|
var serverState = {}; |
|
|
|
|
|
|
|
|
|
|
|
var removeTorrentFromCategoryList = function(hash) { |
|
|
|
var removeTorrentFromCategoryList = function(hash) { |
|
|
|
if (hash == null || hash == "") |
|
|
|
if (hash === null || hash === "") |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
var removed = false; |
|
|
|
var removed = false; |
|
|
|
Object.each(category_list, function(category) { |
|
|
|
Object.each(category_list, function(category) { |
|
|
@ -185,14 +184,14 @@ window.addEvent('load', function () { |
|
|
|
|
|
|
|
|
|
|
|
var addTorrentToCategoryList = function(torrent) { |
|
|
|
var addTorrentToCategoryList = function(torrent) { |
|
|
|
var category = torrent['category']; |
|
|
|
var category = torrent['category']; |
|
|
|
if (category == null) |
|
|
|
if (category === null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (category.length === 0) { // Empty category
|
|
|
|
if (category.length === 0) { // Empty category
|
|
|
|
removeTorrentFromCategoryList(torrent['hash']); |
|
|
|
removeTorrentFromCategoryList(torrent['hash']); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
var categoryHash = genHash(category); |
|
|
|
var categoryHash = genHash(category); |
|
|
|
if (category_list[categoryHash] == null) // This should not happen
|
|
|
|
if (category_list[categoryHash] === null) // This should not happen
|
|
|
|
category_list[categoryHash] = {name: category, torrents: []}; |
|
|
|
category_list[categoryHash] = {name: category, torrents: []}; |
|
|
|
if (!Object.contains(category_list[categoryHash].torrents, torrent['hash'])) { |
|
|
|
if (!Object.contains(category_list[categoryHash].torrents, torrent['hash'])) { |
|
|
|
removeTorrentFromCategoryList(torrent['hash']); |
|
|
|
removeTorrentFromCategoryList(torrent['hash']); |
|
|
@ -242,7 +241,7 @@ window.addEvent('load', function () { |
|
|
|
categoryList.appendChild(create_link(CATEGORIES_ALL, 'QBT_TR(All)QBT_TR[CONTEXT=CategoryFilterModel]', all)); |
|
|
|
categoryList.appendChild(create_link(CATEGORIES_ALL, 'QBT_TR(All)QBT_TR[CONTEXT=CategoryFilterModel]', all)); |
|
|
|
categoryList.appendChild(create_link(CATEGORIES_UNCATEGORIZED, 'QBT_TR(Uncategorized)QBT_TR[CONTEXT=CategoryFilterModel]', uncategorized)); |
|
|
|
categoryList.appendChild(create_link(CATEGORIES_UNCATEGORIZED, 'QBT_TR(Uncategorized)QBT_TR[CONTEXT=CategoryFilterModel]', uncategorized)); |
|
|
|
|
|
|
|
|
|
|
|
var sortedCategories = [] |
|
|
|
var sortedCategories = []; |
|
|
|
Object.each(category_list, function(category) { |
|
|
|
Object.each(category_list, function(category) { |
|
|
|
sortedCategories.push(category.name); |
|
|
|
sortedCategories.push(category.name); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -268,7 +267,7 @@ window.addEvent('load', function () { |
|
|
|
else |
|
|
|
else |
|
|
|
childrens[i].className = ""; |
|
|
|
childrens[i].className = ""; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var syncMainDataTimer; |
|
|
|
var syncMainDataTimer; |
|
|
|
var syncMainData = function () { |
|
|
|
var syncMainData = function () { |
|
|
@ -287,7 +286,7 @@ window.addEvent('load', function () { |
|
|
|
$('error_div').set('html', ''); |
|
|
|
$('error_div').set('html', ''); |
|
|
|
if (response) { |
|
|
|
if (response) { |
|
|
|
var update_categories = false; |
|
|
|
var update_categories = false; |
|
|
|
var full_update = (response['full_update'] == true); |
|
|
|
var full_update = (response['full_update'] === true); |
|
|
|
if (full_update) { |
|
|
|
if (full_update) { |
|
|
|
torrentsTable.clear(); |
|
|
|
torrentsTable.clear(); |
|
|
|
category_list = {}; |
|
|
|
category_list = {}; |
|
|
@ -328,8 +327,8 @@ window.addEvent('load', function () { |
|
|
|
torrentsTable.altRow(); |
|
|
|
torrentsTable.altRow(); |
|
|
|
if (response['server_state']) { |
|
|
|
if (response['server_state']) { |
|
|
|
var tmp = response['server_state']; |
|
|
|
var tmp = response['server_state']; |
|
|
|
for(var key in tmp) |
|
|
|
for(var k in tmp) |
|
|
|
serverState[key] = tmp[key]; |
|
|
|
serverState[k] = tmp[k]; |
|
|
|
processServerState(); |
|
|
|
processServerState(); |
|
|
|
} |
|
|
|
} |
|
|
|
updateFiltersList(); |
|
|
|
updateFiltersList(); |
|
|
@ -348,7 +347,7 @@ window.addEvent('load', function () { |
|
|
|
torrentsTable.updateTable(); |
|
|
|
torrentsTable.updateTable(); |
|
|
|
clearTimeout(syncMainDataTimer); |
|
|
|
clearTimeout(syncMainDataTimer); |
|
|
|
syncMainDataTimer = syncMainData.delay(100); |
|
|
|
syncMainDataTimer = syncMainData.delay(100); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var processServerState = function () { |
|
|
|
var processServerState = function () { |
|
|
|
var transfer_info = friendlyUnit(serverState.dl_info_speed, true); |
|
|
|
var transfer_info = friendlyUnit(serverState.dl_info_speed, true); |
|
|
@ -368,7 +367,7 @@ window.addEvent('load', function () { |
|
|
|
document.title = "qBittorrent ${VERSION} QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]"; |
|
|
|
document.title = "qBittorrent ${VERSION} QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]"; |
|
|
|
$('DHTNodes').set('html', 'QBT_TR(DHT: %1 nodes)QBT_TR[CONTEXT=StatusBar]'.replace("%1", serverState.dht_nodes)); |
|
|
|
$('DHTNodes').set('html', 'QBT_TR(DHT: %1 nodes)QBT_TR[CONTEXT=StatusBar]'.replace("%1", serverState.dht_nodes)); |
|
|
|
|
|
|
|
|
|
|
|
<!-- Statistics dialog --> |
|
|
|
// Statistics dialog
|
|
|
|
if (document.getElementById("statisticspage")) { |
|
|
|
if (document.getElementById("statisticspage")) { |
|
|
|
$('AlltimeDL').set('html', 'QBT_TR(Alltime download:)QBT_TR[CONTEXT=StatsDialog]' + " " + friendlyUnit(serverState.alltime_dl, false)); |
|
|
|
$('AlltimeDL').set('html', 'QBT_TR(Alltime download:)QBT_TR[CONTEXT=StatsDialog]' + " " + friendlyUnit(serverState.alltime_dl, false)); |
|
|
|
$('AlltimeUL').set('html', 'QBT_TR(Alltime upload:)QBT_TR[CONTEXT=StatsDialog]' + " " + friendlyUnit(serverState.alltime_ul, false)); |
|
|
|
$('AlltimeUL').set('html', 'QBT_TR(Alltime upload:)QBT_TR[CONTEXT=StatsDialog]' + " " + friendlyUnit(serverState.alltime_ul, false)); |
|
|
@ -421,8 +420,8 @@ window.addEvent('load', function () { |
|
|
|
if (enabled) |
|
|
|
if (enabled) |
|
|
|
$('alternativeSpeedLimits').src = "images/slow.png"; |
|
|
|
$('alternativeSpeedLimits').src = "images/slow.png"; |
|
|
|
else |
|
|
|
else |
|
|
|
$('alternativeSpeedLimits').src = "images/slow_off.png" |
|
|
|
$('alternativeSpeedLimits').src = "images/slow_off.png"; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$('alternativeSpeedLimits').addEvent('click', function() { |
|
|
|
$('alternativeSpeedLimits').addEvent('click', function() { |
|
|
|
// Change icon immediately to give some feedback
|
|
|
|
// Change icon immediately to give some feedback
|
|
|
@ -436,7 +435,7 @@ window.addEvent('load', function () { |
|
|
|
}, |
|
|
|
}, |
|
|
|
onFailure: function() { |
|
|
|
onFailure: function() { |
|
|
|
// Restore icon in case of failure
|
|
|
|
// Restore icon in case of failure
|
|
|
|
updateAltSpeedIcon(alternativeSpeedLimits) |
|
|
|
updateAltSpeedIcon(alternativeSpeedLimits); |
|
|
|
} |
|
|
|
} |
|
|
|
}).send(); |
|
|
|
}).send(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -493,7 +492,7 @@ window.addEvent('load', function () { |
|
|
|
if ($defined(prop_h)) |
|
|
|
if ($defined(prop_h)) |
|
|
|
prop_h = prop_h.toFloat() * Window.getSize().y; |
|
|
|
prop_h = prop_h.toFloat() * Window.getSize().y; |
|
|
|
else |
|
|
|
else |
|
|
|
prop_h = Window.getSize().y / 2.; |
|
|
|
prop_h = Window.getSize().y / 2.0; |
|
|
|
new MochaUI.Panel({ |
|
|
|
new MochaUI.Panel({ |
|
|
|
id : 'propertiesPanel', |
|
|
|
id : 'propertiesPanel', |
|
|
|
title : 'Panel', |
|
|
|
title : 'Panel', |
|
|
@ -524,7 +523,7 @@ window.addEvent('load', function () { |
|
|
|
updateWebSeedsData(); |
|
|
|
updateWebSeedsData(); |
|
|
|
else if (!$('prop_files').hasClass('invisible')) |
|
|
|
else if (!$('prop_files').hasClass('invisible')) |
|
|
|
updateTorrentFilesData(); |
|
|
|
updateTorrentFilesData(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$('PropGeneralLink').addEvent('click', function(e){ |
|
|
|
$('PropGeneralLink').addEvent('click', function(e){ |
|
|
|
$('prop_general').removeClass("invisible"); |
|
|
|
$('prop_general').removeClass("invisible"); |
|
|
@ -587,7 +586,7 @@ window.addEvent('load', function () { |
|
|
|
|
|
|
|
|
|
|
|
function closeWindows() { |
|
|
|
function closeWindows() { |
|
|
|
MochaUI.closeAll(); |
|
|
|
MochaUI.closeAll(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var keyboardEvents = new Keyboard({ |
|
|
|
var keyboardEvents = new Keyboard({ |
|
|
|
defaultEventType: 'keydown', |
|
|
|
defaultEventType: 'keydown', |
|
|
@ -616,7 +615,7 @@ var loadTorrentPeersData = function(){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var current_hash = torrentsTable.getCurrentTorrentHash(); |
|
|
|
var current_hash = torrentsTable.getCurrentTorrentHash(); |
|
|
|
if (current_hash == "") { |
|
|
|
if (current_hash === "") { |
|
|
|
syncTorrentPeersLastResponseId = 0; |
|
|
|
syncTorrentPeersLastResponseId = 0; |
|
|
|
torrentPeersTable.clear(); |
|
|
|
torrentPeersTable.clear(); |
|
|
|
clearTimeout(loadTorrentPeersTimer); |
|
|
|
clearTimeout(loadTorrentPeersTimer); |
|
|
@ -638,7 +637,7 @@ var loadTorrentPeersData = function(){ |
|
|
|
onSuccess: function(response) { |
|
|
|
onSuccess: function(response) { |
|
|
|
$('error_div').set('html', ''); |
|
|
|
$('error_div').set('html', ''); |
|
|
|
if (response) { |
|
|
|
if (response) { |
|
|
|
var full_update = (response['full_update'] == true); |
|
|
|
var full_update = (response['full_update'] === true); |
|
|
|
if (full_update) { |
|
|
|
if (full_update) { |
|
|
|
torrentPeersTable.clear(); |
|
|
|
torrentPeersTable.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|