1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-25 22:14:32 +00:00

Merge pull request #2224 from pmzqla/webui-updates

WebUI changes
This commit is contained in:
sledgehammer999 2014-12-07 17:23:54 +02:00
commit dcfe95f04b
10 changed files with 930 additions and 871 deletions

View File

@ -29,6 +29,8 @@
} }
#myTable tr:nth-child(even),
#filesTable tr:nth-child(even),
#properties #torrentFiles tr.alt, #properties #torrentFiles tr.alt,
#properties #trackers tr.alt, #properties #trackers tr.alt,
#transferList tr.alt { #transferList tr.alt {
@ -49,6 +51,8 @@
color: #fff; color: #fff;
} }
#myTable tr:hover,
#filesTable tr:hover,
#properties #torrentFiles tr.over, #properties #torrentFiles tr.over,
#properties #trackers tr.over, #properties #trackers tr.over,
#transferList tr.over { #transferList tr.over {

View File

@ -350,15 +350,6 @@ ul.filterList li:hover a {
line-height: 20px; line-height: 20px;
} }
#filesTable tr:nth-child(even) {
background-color: #eee;
}
#filesTable tr:hover {
background-color: #e60;
color: white;
}
#addTrackersPlus { #addTrackersPlus {
width: 16px; width: 16px;
cursor: pointer; cursor: pointer;

View File

@ -23,7 +23,6 @@
*/ */
myTable = new dynamicTable(); myTable = new dynamicTable();
ajaxfn = function () {};
window.addEvent('load', function () { window.addEvent('load', function () {
@ -76,9 +75,10 @@ window.addEvent('load', function () {
height : 300 height : 300
}); });
initializeWindows(); initializeWindows();
var r = 0;
var waiting = false; var speedInTitle = localStorage.getItem('speed_in_browser_title_bar') == "true";
var waitingTrInfo = false; 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") {
@ -94,18 +94,17 @@ window.addEvent('load', function () {
} }
return 'images/skin/' + state + '.png'; return 'images/skin/' + state + '.png';
}; };
var loadTransferInfoTimer;
var loadTransferInfo = function () { var loadTransferInfo = function () {
var url = 'json/transferInfo'; var url = 'json/transferInfo';
if (!waitingTrInfo) {
waitingTrInfo = true;
var request = new Request.JSON({ var request = new Request.JSON({
url : url, url : url,
noCache : true, noCache : true,
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)');
waitingTrInfo = false; loadTransferInfoTimer = loadTransferInfo.delay(4000);
loadTransferInfo.delay(4000);
}, },
onSuccess : function (info) { onSuccess : function (info) {
if (info) { if (info) {
@ -115,36 +114,41 @@ window.addEvent('load', function () {
$("UpInfos").set('html', "_(U: %1 - T: %2)" $("UpInfos").set('html', "_(U: %1 - T: %2)"
.replace("%1", friendlyUnit(info.up_info_speed, true)) .replace("%1", friendlyUnit(info.up_info_speed, true))
.replace("%2", friendlyUnit(info.up_info_data, false))); .replace("%2", friendlyUnit(info.up_info_data, false)));
if(localStorage.getItem('speed_in_browser_title_bar') == 'true') if (speedInTitle)
document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true)); document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true));
else else
document.title = "_(qBittorrent web User Interface)"; document.title = "_(qBittorrent web User Interface)";
waitingTrInfo = false; loadTransferInfoTimer = loadTransferInfo.delay(3000);
loadTransferInfo.delay(3000);
} }
} }
}).send(); }).send();
}
}; };
var updateTransferInfo = function() {
clearTimeout(loadTransferInfoTimer);
loadTransferInfoTimer = loadTransferInfo();
}
// Start fetching data now
loadTransferInfo();
$('DlInfos').addEvent('click', globalDownloadLimitFN); $('DlInfos').addEvent('click', globalDownloadLimitFN);
$('UpInfos').addEvent('click', globalUploadLimitFN); $('UpInfos').addEvent('click', globalUploadLimitFN);
var ajaxfnTimer;
var ajaxfn = function () { 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);
url.setData('sort', myTable.table.sortedColumn); url.setData('sort', myTable.table.sortedColumn);
url.setData('reverse', myTable.table.reverseSort); url.setData('reverse', myTable.table.reverseSort);
if (!waiting) {
waiting = true;
var request = new Request.JSON({ var request = new Request.JSON({
url : url, url : url,
noCache : true, noCache : true,
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)');
waiting = false; ajaxfnTimer = ajaxfn.delay(2000);
ajaxfn.delay(2000);
}, },
onSuccess : function (events) { onSuccess : function (events) {
$('error_div').set('html', ''); $('error_div').set('html', '');
@ -217,19 +221,31 @@ window.addEvent('load', function () {
myTable.altRow(); myTable.altRow();
} }
waiting = false; ajaxfnTimer = ajaxfn.delay(1500);
ajaxfn.delay(1500);
} }
}).send(); }).send();
}
}; };
var updateTransferList = function() {
clearTimeout(ajaxfnTimer);
ajaxfnTimer = ajaxfn();
}
setSortedColumn = function (column) { setSortedColumn = function (column) {
myTable.setSortedColumn(column); myTable.setSortedColumn(column);
// reload torrents updateTransferList();
ajaxfn();
}; };
$('speedInBrowserTitleBarLink').addEvent('click', function(e) {
speedInTitle = !speedInTitle;
localStorage.setItem('speed_in_browser_title_bar', speedInTitle.toString());
if (speedInTitle)
$('speedInBrowserTitleBarLink').firstChild.style.opacity = '1';
else
$('speedInBrowserTitleBarLink').firstChild.style.opacity = '0';
updateTransferInfo();
});
new MochaUI.Panel({ new MochaUI.Panel({
id : 'transferList', id : 'transferList',
title : 'Panel', title : 'Panel',
@ -243,7 +259,7 @@ window.addEvent('load', function () {
loadMethod : 'xhr', loadMethod : 'xhr',
contentURL : 'transferlist.html', contentURL : 'transferlist.html',
onContentLoaded : function () { onContentLoaded : function () {
ajaxfn(); updateTransferList();
}, },
column : 'mainColumn', column : 'mainColumn',
onResize : saveColumnSizes, onResize : saveColumnSizes,
@ -272,8 +288,6 @@ window.addEvent('load', function () {
column : 'mainColumn', column : 'mainColumn',
height : prop_h height : prop_h
}); });
//ajaxfn();
loadTransferInfo();
setFilter = function (f) { setFilter = function (f) {
// Visually Select the right filter // Visually Select the right filter
@ -287,7 +301,7 @@ window.addEvent('load', function () {
filter = f; filter = f;
localStorage.setItem('selected_filter', f); localStorage.setItem('selected_filter', f);
// Reload torrents // Reload torrents
ajaxfn(); updateTransferList();
} }
}); });

View File

@ -10,7 +10,10 @@ var ContextMenu = new Class({
stopEvent: true, stopEvent: true,
targets: 'body', targets: 'body',
trigger: 'contextmenu', trigger: 'contextmenu',
offsets: { x:0, y:0 }, offsets: {
x: 0,
y: 0
},
onShow: $empty, onShow: $empty,
onHide: $empty, onHide: $empty,
onClick: $empty, onClick: $empty,
@ -33,7 +36,8 @@ var ContextMenu = new Class({
onComplete: function() { onComplete: function() {
if (this.getStyle('opacity')) { if (this.getStyle('opacity')) {
this.setStyle('visibility', 'visible'); this.setStyle('visibility', 'visible');
}else{ }
else {
this.setStyle('visibility', 'hidden'); this.setStyle('visibility', 'hidden');
} }
}.bind(this.menu) }.bind(this.menu)
@ -43,7 +47,11 @@ var ContextMenu = new Class({
this.hide().startListener(); this.hide().startListener();
//hide the menu //hide the menu
this.menu.setStyles({ 'position':'absolute','top':'-900000px', 'display':'block' }); this.menu.setStyles({
'position': 'absolute',
'top': '-900000px',
'display': 'block'
});
}, },
addTarget: function(t) { addTarget: function(t) {
@ -52,7 +60,9 @@ var ContextMenu = new Class({
//enabled? //enabled?
if (!this.options.disabled) { if (!this.options.disabled) {
//prevent default, if told to //prevent default, if told to
if(this.options.stopEvent) { e.stop(); } if (this.options.stopEvent) {
e.stop();
}
//record this as the trigger //record this as the trigger
this.options.element = $(t); this.options.element = $(t);
//position the menu //position the menu
@ -80,7 +90,9 @@ var ContextMenu = new Class({
//enabled? //enabled?
if (!this.options.disabled) { if (!this.options.disabled) {
//prevent default, if told to //prevent default, if told to
if(this.options.stopEvent) { e.stop(); } if (this.options.stopEvent) {
e.stop();
}
//record this as the trigger //record this as the trigger
this.options.element = $(el); this.options.element = $(el);
//position the menu //position the menu
@ -126,8 +138,7 @@ var ContextMenu = new Class({
//hide the menu //hide the menu
hide: function(trigger) { hide: function(trigger) {
if(this.shown) if (this.shown) {
{
this.fx.start(0); this.fx.start(0);
//this.menu.fade('out'); //this.menu.fade('out');
this.fireEvent('hide'); this.fireEvent('hide');

View File

@ -20,12 +20,16 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
window.addEvent('domready', function() { window.addEvent('domready', function() {
$('urls').focus(); $('urls').focus();
$('downButton').addEvent('click', function(e) { $('downButton').addEvent('click', function(e) {
new Event(e).stop(); new Event(e).stop();
new Request({url: 'command/download', method: 'post', data: {urls: $('urls').value}, new Request({
url: 'command/download',
method: 'post',
data: {
urls: $('urls').value
},
onComplete: function() { onComplete: function() {
window.parent.document.getElementById('downloadPage').parentNode.removeChild(window.parent.document.getElementById('downloadPage')); window.parent.document.getElementById('downloadPage').parentNode.removeChild(window.parent.document.getElementById('downloadPage'));
} }

View File

@ -63,6 +63,9 @@ var dynamicTable = new Class({
}, },
altRow : function () { altRow : function () {
if (!MUI.ieLegacySupport)
return;
var trs = this.table.getElements('tr'); var trs = this.table.getElements('tr');
trs.each(function (el, i) { trs.each(function (el, i) {
if (i % 2) { if (i % 2) {

View File

@ -8,7 +8,6 @@
it in the onContentLoaded function of the new window. it in the onContentLoaded function of the new window.
----------------------------------------------------------------- */ ----------------------------------------------------------------- */
/* Define localStorage object for older browsers */ /* Define localStorage object for older browsers */
if (typeof localStorage == 'undefined') { if (typeof localStorage == 'undefined') {
window['localStorage'] = { window['localStorage'] = {
@ -16,7 +15,9 @@ if (typeof localStorage == 'undefined') {
return Cookie.read(name); return Cookie.read(name);
}, },
setItem: function(name, value) { setItem: function(name, value) {
Cookie.write(name, value, {duration: 365 * 10}); Cookie.write(name, value, {
duration: 365 * 10
});
} }
} }
} }
@ -192,7 +193,13 @@ initializeWindows = function(){
var h = myTable.selectedIds(); var h = myTable.selectedIds();
if (h.length) { if (h.length) {
h.each(function(hash, index) { h.each(function(hash, index) {
new Request({url: 'command/pause', method: 'post', data: {hash: hash}}).send(); new Request({
url: 'command/pause',
method: 'post',
data: {
hash: hash
}
}).send();
}); });
} }
}; };
@ -201,7 +208,13 @@ initializeWindows = function(){
var h = myTable.selectedIds(); var h = myTable.selectedIds();
if (h.length) { if (h.length) {
h.each(function(hash, index) { h.each(function(hash, index) {
new Request({url: 'command/resume', method: 'post', data: {hash: hash}}).send(); new Request({
url: 'command/resume',
method: 'post',
data: {
hash: hash
}
}).send();
}); });
} }
}; };
@ -210,7 +223,13 @@ initializeWindows = function(){
var h = myTable.selectedIds(); var h = myTable.selectedIds();
if (h.length) { if (h.length) {
h.each(function(hash, index) { h.each(function(hash, index) {
new Request({url: 'command/recheck', method: 'post', data: {hash: hash}}).send(); new Request({
url: 'command/recheck',
method: 'post',
data: {
hash: hash
}
}).send();
}); });
} }
}; };
@ -221,14 +240,22 @@ initializeWindows = function(){
var h = myTable.selectedIds(); var h = myTable.selectedIds();
if (h.length) { if (h.length) {
h.each(function(hash, index) { h.each(function(hash, index) {
new Request({url: 'command/'+item, method: 'post', data: {hash: hash}}).send(); new Request({
url: 'command/' + item,
method: 'post',
data: {
hash: hash
}
}).send();
}); });
} }
}); });
addClickEvent(item + 'All', function(e) { addClickEvent(item + 'All', function(e) {
new Event(e).stop(); new Event(e).stop();
new Request({url: 'command/'+item+'all'}).send(); new Request({
url: 'command/' + item + 'all'
}).send();
}); });
}); });
@ -242,7 +269,13 @@ initializeWindows = function(){
setPriorityFN = function(cmd) { setPriorityFN = function(cmd) {
var h = myTable.selectedIds(); var h = myTable.selectedIds();
if (h.length) { if (h.length) {
new Request({url: 'command/'+cmd, method: 'post', data: {hashes: h.join("|")}}).send(); new Request({
url: 'command/' + cmd,
method: 'post',
data: {
hashes: h.join("|")
}
}).send();
} }
} }
@ -281,24 +314,6 @@ initializeWindows = function(){
}).send(); }).send();
}); });
updateSpeedInBrowserTitleBarLinkCheckState = function()
{
if (localStorage.getItem('speed_in_browser_title_bar') == 'true')
$(speedInBrowserTitleBarLink).firstChild.style.opacity = '1';
else
$(speedInBrowserTitleBarLink).firstChild.style.opacity = '0';
}
updateSpeedInBrowserTitleBarLinkCheckState();
addClickEvent('speedInBrowserTitleBar', function(e){
new Event(e).stop();
var speed_in_browser_title_bar = localStorage.getItem('speed_in_browser_title_bar');
speed_in_browser_title_bar = speed_in_browser_title_bar == 'true' ? 'false' : 'true';
localStorage.setItem('speed_in_browser_title_bar', speed_in_browser_title_bar);
updateSpeedInBrowserTitleBarLinkCheckState();
});
// Deactivate menu header links // Deactivate menu header links
$$('a.returnFalse').each(function(el) { $$('a.returnFalse').each(function(el) {
el.addEvent('click', function(e) { el.addEvent('click', function(e) {

View File

@ -13,7 +13,6 @@ Requires:
Core.js, Window.js Core.js, Window.js
*/ */
MochaUI.extend({ MochaUI.extend({
addUpLimitSlider: function(hash) { addUpLimitSlider: function(hash) {
if ($('uplimitSliderarea')) { if ($('uplimitSliderarea')) {
@ -30,7 +29,8 @@ MochaUI.extend({
var tmp = data.toInt(); var tmp = data.toInt();
if (tmp > 0) { if (tmp > 0) {
maximum = tmp / 1024. maximum = tmp / 1024.
} else { }
else {
maximum = 1000 maximum = 1000
} }
} }
@ -48,7 +48,8 @@ MochaUI.extend({
if (pos > 0) { if (pos > 0) {
$('uplimitUpdatevalue').set('html', pos); $('uplimitUpdatevalue').set('html', pos);
$('upLimitUnit').set('html', "_(KiB/s)"); $('upLimitUnit').set('html', "_(KiB/s)");
} else { }
else {
$('uplimitUpdatevalue').set('html', '∞'); $('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', ""); $('upLimitUnit').set('html', "");
} }
@ -58,15 +59,19 @@ MochaUI.extend({
if (up_limit == 0) { if (up_limit == 0) {
$('uplimitUpdatevalue').set('html', '∞'); $('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', ""); $('upLimitUnit').set('html', "");
} else { }
else {
$('uplimitUpdatevalue').set('html', up_limit.round()); $('uplimitUpdatevalue').set('html', up_limit.round());
$('upLimitUnit').set('html', "_(KiB/s)"); $('upLimitUnit').set('html', "_(KiB/s)");
} }
} else { }
else {
var req = new Request({ var req = new Request({
url: 'command/getTorrentUpLimit', url: 'command/getTorrentUpLimit',
method: 'post', method: 'post',
data: {hash: hash}, data: {
hash: hash
},
onSuccess: function(data) { onSuccess: function(data) {
if (data) { if (data) {
var up_limit = data.toInt(); var up_limit = data.toInt();
@ -79,7 +84,8 @@ MochaUI.extend({
if (pos > 0) { if (pos > 0) {
$('uplimitUpdatevalue').set('html', pos); $('uplimitUpdatevalue').set('html', pos);
$('upLimitUnit').set('html', "_(KiB/s)"); $('upLimitUnit').set('html', "_(KiB/s)");
} else { }
else {
$('uplimitUpdatevalue').set('html', '∞'); $('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', ""); $('upLimitUnit').set('html', "");
} }
@ -89,7 +95,8 @@ MochaUI.extend({
if (up_limit == 0) { if (up_limit == 0) {
$('uplimitUpdatevalue').set('html', '∞'); $('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', ""); $('upLimitUnit').set('html', "");
} else { }
else {
$('uplimitUpdatevalue').set('html', (up_limit / 1024.).round()); $('uplimitUpdatevalue').set('html', (up_limit / 1024.).round());
$('upLimitUnit').set('html', "_(KiB/s)"); $('upLimitUnit').set('html', "_(KiB/s)");
} }
@ -117,7 +124,8 @@ MochaUI.extend({
var tmp = data.toInt(); var tmp = data.toInt();
if (tmp > 0) { if (tmp > 0) {
maximum = tmp / 1024. maximum = tmp / 1024.
} else { }
else {
maximum = 1000 maximum = 1000
} }
} }
@ -135,7 +143,8 @@ MochaUI.extend({
if (pos > 0) { if (pos > 0) {
$('dllimitUpdatevalue').set('html', pos); $('dllimitUpdatevalue').set('html', pos);
$('dlLimitUnit').set('html', "_(KiB/s)"); $('dlLimitUnit').set('html', "_(KiB/s)");
} else { }
else {
$('dllimitUpdatevalue').set('html', '∞'); $('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', ""); $('dlLimitUnit').set('html', "");
} }
@ -145,15 +154,19 @@ MochaUI.extend({
if (dl_limit == 0) { if (dl_limit == 0) {
$('dllimitUpdatevalue').set('html', '∞'); $('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', ""); $('dlLimitUnit').set('html', "");
} else { }
else {
$('dllimitUpdatevalue').set('html', dl_limit.round()); $('dllimitUpdatevalue').set('html', dl_limit.round());
$('dlLimitUnit').set('html', "_(KiB/s)"); $('dlLimitUnit').set('html', "_(KiB/s)");
} }
} else { }
else {
var req = new Request({ var req = new Request({
url: 'command/getTorrentDlLimit', url: 'command/getTorrentDlLimit',
method: 'post', method: 'post',
data: {hash: hash}, data: {
hash: hash
},
onSuccess: function(data) { onSuccess: function(data) {
if (data) { if (data) {
var dl_limit = data.toInt(); var dl_limit = data.toInt();
@ -166,7 +179,8 @@ MochaUI.extend({
if (pos > 0) { if (pos > 0) {
$('dllimitUpdatevalue').set('html', pos); $('dllimitUpdatevalue').set('html', pos);
$('dlLimitUnit').set('html', "_(KiB/s)"); $('dlLimitUnit').set('html', "_(KiB/s)");
} else { }
else {
$('dllimitUpdatevalue').set('html', '∞'); $('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', ""); $('dlLimitUnit').set('html', "");
} }
@ -176,7 +190,8 @@ MochaUI.extend({
if (dl_limit == 0) { if (dl_limit == 0) {
$('dllimitUpdatevalue').set('html', '∞'); $('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', ""); $('dlLimitUnit').set('html', "");
} else { }
else {
$('dllimitUpdatevalue').set('html', (dl_limit / 1024.).round()); $('dllimitUpdatevalue').set('html', (dl_limit / 1024.).round());
$('dlLimitUnit').set('html', "_(KiB/s)"); $('dlLimitUnit').set('html', "_(KiB/s)");
} }

View File

@ -82,6 +82,7 @@ function ProgressBar_setValue(value){
this.vals.dark.setStyle('clip', 'rect(0,' + r + 'px,' + this.vals.height + 'px,0)'); this.vals.dark.setStyle('clip', 'rect(0,' + r + 'px,' + this.vals.height + 'px,0)');
this.vals.light.setStyle('clip', 'rect(0,' + this.vals.width + 'px,' + this.vals.height + 'px,' + r + 'px)'); this.vals.light.setStyle('clip', 'rect(0,' + this.vals.width + 'px,' + this.vals.height + 'px,' + r + 'px)');
} }
function ProgressBar_checkForParent(id) { function ProgressBar_checkForParent(id) {
var obj = $(id); var obj = $(id);
if (!obj) return; if (!obj) return;
@ -93,4 +94,5 @@ function ProgressBar_checkForParent(id){
obj.vals.width = w; obj.vals.width = w;
obj.setValue(obj.vals.value); obj.setValue(obj.vals.value);
} }
var ProgressBars = 0; var ProgressBars = 0;