Browse Source

Update torrent list after operations with torrents.

Immediately update torrent list after some operations with torrents.
Such as changing priority, adding torrent, pause/resume, etc.
adaptive-webui-19844
buinsky 10 years ago
parent
commit
b4f39add08
  1. 204
      src/webui/www/public/scripts/client.js
  2. 7
      src/webui/www/public/scripts/mocha-init.js

204
src/webui/www/public/scripts/client.js

@ -24,62 +24,6 @@
myTable = new dynamicTable(); myTable = new dynamicTable();
window.addEvent('load', function () {
var saveColumnSizes = function () {
var filters_width = $('Filters').getSize().x;
var properties_height = $('propertiesPanel').getSize().y;
localStorage.setItem('filters_width', filters_width);
localStorage.setItem('properties_height', properties_height);
}
/*MochaUI.Desktop = new MochaUI.Desktop();
MochaUI.Desktop.desktop.setStyles({
'background': '#fff',
'visibility': 'visible'
});*/
MochaUI.Desktop.initialize();
var filt_w = localStorage.getItem('filters_width');
if ($defined(filt_w))
filt_w = filt_w.toInt();
else
filt_w = 120;
new MochaUI.Column({
id : 'filtersColumn',
placement : 'left',
onResize : saveColumnSizes,
width : filt_w,
resizeLimit : [100, 300]
});
new MochaUI.Column({
id : 'mainColumn',
placement : 'main',
width : null,
resizeLimit : [100, 300]
});
MochaUI.Desktop.setDesktopSize();
new MochaUI.Panel({
id : 'Filters',
title : 'Panel',
header : false,
padding : {
top : 0,
right : 0,
bottom : 0,
left : 0
},
loadMethod : 'xhr',
contentURL : 'filters.html',
column : 'filtersColumn',
height : 300
});
initializeWindows();
var speedInTitle = localStorage.getItem('speed_in_browser_title_bar') == "true";
if (!speedInTitle)
$('speedInBrowserTitleBarLink').firstChild.style.opacity = '0';
var stateToImg = function (state) { var stateToImg = function (state) {
if (state == "pausedUP" || state == "pausedDL") { if (state == "pausedUP" || state == "pausedDL") {
state = "paused"; state = "paused";
@ -95,48 +39,8 @@ window.addEvent('load', function () {
return 'images/skin/' + state + '.png'; return 'images/skin/' + state + '.png';
}; };
var loadTransferInfoTimer; var loadTorrentsInfoTimer;
var loadTransferInfo = function () { var loadTorrentsInfo = function () {
var url = 'json/transferInfo';
var request = new Request.JSON({
url : url,
noCache : true,
method : 'get',
onFailure : function () {
$('error_div').set('html', '_(qBittorrent client is not reachable)');
loadTransferInfoTimer = loadTransferInfo.delay(4000);
},
onSuccess : function (info) {
if (info) {
$("DlInfos").set('html', "_(D: %1 - T: %2)"
.replace("%1", friendlyUnit(info.dl_info_speed, true))
.replace("%2", friendlyUnit(info.dl_info_data, false)));
$("UpInfos").set('html', "_(U: %1 - T: %2)"
.replace("%1", friendlyUnit(info.up_info_speed, true))
.replace("%2", friendlyUnit(info.up_info_data, false)));
if (speedInTitle)
document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true));
else
document.title = "_(qBittorrent web User Interface)";
loadTransferInfoTimer = loadTransferInfo.delay(3000);
}
}
}).send();
};
var updateTransferInfo = function() {
clearTimeout(loadTransferInfoTimer);
loadTransferInfoTimer = loadTransferInfo();
}
// Start fetching data now
loadTransferInfo();
$('DlInfos').addEvent('click', globalDownloadLimitFN);
$('UpInfos').addEvent('click', globalUploadLimitFN);
var ajaxfnTimer;
var ajaxfn = function () {
var queueing_enabled = false; var queueing_enabled = false;
var url = new URI('json/torrents'); var url = new URI('json/torrents');
url.setData('filter', filter); url.setData('filter', filter);
@ -148,7 +52,7 @@ window.addEvent('load', function () {
method : 'get', method : 'get',
onFailure : function () { onFailure : function () {
$('error_div').set('html', '_(qBittorrent client is not reachable)'); $('error_div').set('html', '_(qBittorrent client is not reachable)');
ajaxfnTimer = ajaxfn.delay(2000); loadTorrentsInfoTimer = loadTorrentsInfo.delay(2000);
}, },
onSuccess : function (events) { onSuccess : function (events) {
$('error_div').set('html', ''); $('error_div').set('html', '');
@ -223,16 +127,112 @@ window.addEvent('load', function () {
myTable.altRow(); myTable.altRow();
} }
ajaxfnTimer = ajaxfn.delay(1500); loadTorrentsInfoTimer = loadTorrentsInfo.delay(1500);
} }
}).send(); }).send();
}; };
var updateTransferList = function() { var updateTransferList = function() {
clearTimeout(ajaxfnTimer); clearTimeout(loadTorrentsInfoTimer);
ajaxfnTimer = ajaxfn(); loadTorrentsInfoTimer = loadTorrentsInfo();
} }
window.addEvent('load', function () {
var saveColumnSizes = function () {
var filters_width = $('Filters').getSize().x;
var properties_height = $('propertiesPanel').getSize().y;
localStorage.setItem('filters_width', filters_width);
localStorage.setItem('properties_height', properties_height);
}
/*MochaUI.Desktop = new MochaUI.Desktop();
MochaUI.Desktop.desktop.setStyles({
'background': '#fff',
'visibility': 'visible'
});*/
MochaUI.Desktop.initialize();
var filt_w = localStorage.getItem('filters_width');
if ($defined(filt_w))
filt_w = filt_w.toInt();
else
filt_w = 120;
new MochaUI.Column({
id : 'filtersColumn',
placement : 'left',
onResize : saveColumnSizes,
width : filt_w,
resizeLimit : [100, 300]
});
new MochaUI.Column({
id : 'mainColumn',
placement : 'main',
width : null,
resizeLimit : [100, 300]
});
MochaUI.Desktop.setDesktopSize();
new MochaUI.Panel({
id : 'Filters',
title : 'Panel',
header : false,
padding : {
top : 0,
right : 0,
bottom : 0,
left : 0
},
loadMethod : 'xhr',
contentURL : 'filters.html',
column : 'filtersColumn',
height : 300
});
initializeWindows();
var speedInTitle = localStorage.getItem('speed_in_browser_title_bar') == "true";
if (!speedInTitle)
$('speedInBrowserTitleBarLink').firstChild.style.opacity = '0';
var loadTransferInfoTimer;
var loadTransferInfo = function () {
var url = 'json/transferInfo';
var request = new Request.JSON({
url : url,
noCache : true,
method : 'get',
onFailure : function () {
$('error_div').set('html', '_(qBittorrent client is not reachable)');
loadTransferInfoTimer = loadTransferInfo.delay(4000);
},
onSuccess : function (info) {
if (info) {
$("DlInfos").set('html', "_(D: %1 - T: %2)"
.replace("%1", friendlyUnit(info.dl_info_speed, true))
.replace("%2", friendlyUnit(info.dl_info_data, false)));
$("UpInfos").set('html', "_(U: %1 - T: %2)"
.replace("%1", friendlyUnit(info.up_info_speed, true))
.replace("%2", friendlyUnit(info.up_info_data, false)));
if (speedInTitle)
document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true));
else
document.title = "_(qBittorrent web User Interface)";
loadTransferInfoTimer = loadTransferInfo.delay(3000);
}
}
}).send();
};
var updateTransferInfo = function() {
clearTimeout(loadTransferInfoTimer);
loadTransferInfoTimer = loadTransferInfo();
}
// Start fetching data now
loadTransferInfo();
$('DlInfos').addEvent('click', globalDownloadLimitFN);
$('UpInfos').addEvent('click', globalUploadLimitFN);
setSortedColumn = function (column) { setSortedColumn = function (column) {
myTable.setSortedColumn(column); myTable.setSortedColumn(column);
updateTransferList(); updateTransferList();

7
src/webui/www/public/scripts/mocha-init.js

@ -48,6 +48,7 @@ initializeWindows = function() {
width: 500, width: 500,
height: 300 height: 300
}); });
updateTransferList();
}); });
addClickEvent('preferences', function(e) { addClickEvent('preferences', function(e) {
@ -87,6 +88,7 @@ initializeWindows = function() {
width: 600, width: 600,
height: 130 height: 130
}); });
updateTransferList();
}); });
globalUploadLimitFN = function() { globalUploadLimitFN = function() {
@ -181,6 +183,7 @@ initializeWindows = function() {
width: 424, width: 424,
height: 140 height: 140
}); });
updateTransferList();
} }
}; };
@ -201,6 +204,7 @@ initializeWindows = function() {
} }
}).send(); }).send();
}); });
updateTransferList();
} }
}; };
@ -216,6 +220,7 @@ initializeWindows = function() {
} }
}).send(); }).send();
}); });
updateTransferList();
} }
}; };
@ -248,6 +253,7 @@ initializeWindows = function() {
} }
}).send(); }).send();
}); });
updateTransferList();
} }
}); });
@ -276,6 +282,7 @@ initializeWindows = function() {
hashes: h.join("|") hashes: h.join("|")
} }
}).send(); }).send();
updateTransferList();
} }
} }

Loading…
Cancel
Save