1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 23:37:59 +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 #trackers tr.alt,
#transferList tr.alt {
@ -49,6 +51,8 @@
color: #fff;
}
#myTable tr:hover,
#filesTable tr:hover,
#properties #torrentFiles tr.over,
#properties #trackers tr.over,
#transferList tr.over {

View File

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

View File

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

View File

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

View File

@ -20,12 +20,16 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
window.addEvent('domready', function() {
$('urls').focus();
$('downButton').addEvent('click', function(e) {
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() {
window.parent.document.getElementById('downloadPage').parentNode.removeChild(window.parent.document.getElementById('downloadPage'));
}

View File

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

View File

@ -8,7 +8,6 @@
it in the onContentLoaded function of the new window.
----------------------------------------------------------------- */
/* Define localStorage object for older browsers */
if (typeof localStorage == 'undefined') {
window['localStorage'] = {
@ -16,7 +15,9 @@ if (typeof localStorage == 'undefined') {
return Cookie.read(name);
},
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();
if (h.length) {
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();
if (h.length) {
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();
if (h.length) {
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();
if (h.length) {
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) {
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) {
var h = myTable.selectedIds();
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();
});
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
$$('a.returnFalse').each(function(el) {
el.addEvent('click', function(e) {

View File

@ -13,7 +13,6 @@ Requires:
Core.js, Window.js
*/
MochaUI.extend({
addUpLimitSlider: function(hash) {
if ($('uplimitSliderarea')) {
@ -30,7 +29,8 @@ MochaUI.extend({
var tmp = data.toInt();
if (tmp > 0) {
maximum = tmp / 1024.
} else {
}
else {
maximum = 1000
}
}
@ -48,7 +48,8 @@ MochaUI.extend({
if (pos > 0) {
$('uplimitUpdatevalue').set('html', pos);
$('upLimitUnit').set('html', "_(KiB/s)");
} else {
}
else {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
}
@ -58,15 +59,19 @@ MochaUI.extend({
if (up_limit == 0) {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
} else {
}
else {
$('uplimitUpdatevalue').set('html', up_limit.round());
$('upLimitUnit').set('html', "_(KiB/s)");
}
} else {
}
else {
var req = new Request({
url: 'command/getTorrentUpLimit',
method: 'post',
data: {hash: hash},
data: {
hash: hash
},
onSuccess: function(data) {
if (data) {
var up_limit = data.toInt();
@ -79,7 +84,8 @@ MochaUI.extend({
if (pos > 0) {
$('uplimitUpdatevalue').set('html', pos);
$('upLimitUnit').set('html', "_(KiB/s)");
} else {
}
else {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
}
@ -89,7 +95,8 @@ MochaUI.extend({
if (up_limit == 0) {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
} else {
}
else {
$('uplimitUpdatevalue').set('html', (up_limit / 1024.).round());
$('upLimitUnit').set('html', "_(KiB/s)");
}
@ -117,7 +124,8 @@ MochaUI.extend({
var tmp = data.toInt();
if (tmp > 0) {
maximum = tmp / 1024.
} else {
}
else {
maximum = 1000
}
}
@ -135,7 +143,8 @@ MochaUI.extend({
if (pos > 0) {
$('dllimitUpdatevalue').set('html', pos);
$('dlLimitUnit').set('html', "_(KiB/s)");
} else {
}
else {
$('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', "");
}
@ -145,15 +154,19 @@ MochaUI.extend({
if (dl_limit == 0) {
$('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', "");
} else {
}
else {
$('dllimitUpdatevalue').set('html', dl_limit.round());
$('dlLimitUnit').set('html', "_(KiB/s)");
}
} else {
}
else {
var req = new Request({
url: 'command/getTorrentDlLimit',
method: 'post',
data: {hash: hash},
data: {
hash: hash
},
onSuccess: function(data) {
if (data) {
var dl_limit = data.toInt();
@ -166,7 +179,8 @@ MochaUI.extend({
if (pos > 0) {
$('dllimitUpdatevalue').set('html', pos);
$('dlLimitUnit').set('html', "_(KiB/s)");
} else {
}
else {
$('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', "");
}
@ -176,7 +190,8 @@ MochaUI.extend({
if (dl_limit == 0) {
$('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', "");
} else {
}
else {
$('dllimitUpdatevalue').set('html', (dl_limit / 1024.).round());
$('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.light.setStyle('clip', 'rect(0,' + this.vals.width + 'px,' + this.vals.height + 'px,' + r + 'px)');
}
function ProgressBar_checkForParent(id) {
var obj = $(id);
if (!obj) return;
@ -93,4 +94,5 @@ function ProgressBar_checkForParent(id){
obj.vals.width = w;
obj.setValue(obj.vals.value);
}
var ProgressBars = 0;