mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -07:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
3672363207
commit
aab2c34257
6 changed files with 798 additions and 734 deletions
|
@ -1,7 +1,7 @@
|
||||||
var ContextMenu = new Class({
|
var ContextMenu = new Class({
|
||||||
|
|
||||||
//implements
|
//implements
|
||||||
Implements: [Options,Events],
|
Implements: [Options, Events],
|
||||||
|
|
||||||
//options
|
//options
|
||||||
options: {
|
options: {
|
||||||
|
@ -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,
|
||||||
|
@ -29,12 +32,13 @@ var ContextMenu = new Class({
|
||||||
//fx
|
//fx
|
||||||
this.fx = new Fx.Tween(this.menu, {
|
this.fx = new Fx.Tween(this.menu, {
|
||||||
property: 'opacity',
|
property: 'opacity',
|
||||||
duration:this.options.fadeSpeed,
|
duration: this.options.fadeSpeed,
|
||||||
onComplete: function() {
|
onComplete: function() {
|
||||||
if(this.getStyle('opacity')){
|
if (this.getStyle('opacity')) {
|
||||||
this.setStyle('visibility','visible');
|
this.setStyle('visibility', 'visible');
|
||||||
}else{
|
}
|
||||||
this.setStyle('visibility','hidden');
|
else {
|
||||||
|
this.setStyle('visibility', 'hidden');
|
||||||
}
|
}
|
||||||
}.bind(this.menu)
|
}.bind(this.menu)
|
||||||
});
|
});
|
||||||
|
@ -43,16 +47,22 @@ 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) {
|
||||||
this.targets[this.targets.length] = t;
|
this.targets[this.targets.length] = t;
|
||||||
t.addEvent(this.options.trigger,function(e) {
|
t.addEvent(this.options.trigger, function(e) {
|
||||||
//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
|
||||||
|
@ -66,7 +76,7 @@ var ContextMenu = new Class({
|
||||||
this.show();
|
this.show();
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
t.addEvent('click',function(e) {
|
t.addEvent('click', function(e) {
|
||||||
this.hide();
|
this.hide();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
@ -76,11 +86,13 @@ var ContextMenu = new Class({
|
||||||
/* all elements */
|
/* all elements */
|
||||||
this.targets.each(function(el) {
|
this.targets.each(function(el) {
|
||||||
/* show the menu */
|
/* show the menu */
|
||||||
el.addEvent(this.options.trigger,function(e) {
|
el.addEvent(this.options.trigger, function(e) {
|
||||||
//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
|
||||||
|
@ -94,20 +106,20 @@ var ContextMenu = new Class({
|
||||||
this.show();
|
this.show();
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
el.addEvent('click',function(e) {
|
el.addEvent('click', function(e) {
|
||||||
this.hide();
|
this.hide();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},this);
|
}, this);
|
||||||
|
|
||||||
/* menu items */
|
/* menu items */
|
||||||
this.menu.getElements('a').each(function(item) {
|
this.menu.getElements('a').each(function(item) {
|
||||||
item.addEvent('click',function(e) {
|
item.addEvent('click', function(e) {
|
||||||
if(!item.hasClass('disabled')) {
|
if (!item.hasClass('disabled')) {
|
||||||
this.execute(item.get('href').split('#')[1],$(this.options.element));
|
this.execute(item.get('href').split('#')[1], $(this.options.element));
|
||||||
this.fireEvent('click',[item,e]);
|
this.fireEvent('click', [item, e]);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},this);
|
}, this);
|
||||||
|
|
||||||
//hide on body click
|
//hide on body click
|
||||||
$(document.body).addEvent('click', function() {
|
$(document.body).addEvent('click', function() {
|
||||||
|
@ -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');
|
||||||
|
@ -161,9 +172,9 @@ var ContextMenu = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
//execute an action
|
//execute an action
|
||||||
execute: function(action,element) {
|
execute: function(action, element) {
|
||||||
if(this.options.actions[action]) {
|
if (this.options.actions[action]) {
|
||||||
this.options.actions[action](element,this);
|
this.options.actions[action](element, this);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ function friendlyDuration(seconds) {
|
||||||
if (minutes < 60)
|
if (minutes < 60)
|
||||||
return "_(%1m)".replace("%1", parseInt(minutes));
|
return "_(%1m)".replace("%1", parseInt(minutes));
|
||||||
var hours = minutes / 60;
|
var hours = minutes / 60;
|
||||||
minutes = minutes - hours*60;
|
minutes = minutes - hours * 60;
|
||||||
if (hours < 24)
|
if (hours < 24)
|
||||||
return "_(%1h %2m)".replace("%1", parseInt(hours)).replace("%2", parseInt(minutes))
|
return "_(%1h %2m)".replace("%1", parseInt(hours)).replace("%2", parseInt(minutes))
|
||||||
var days = hours / 24;
|
var days = hours / 24;
|
||||||
|
|
|
@ -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,28 +15,30 @@ 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
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeWindows = function(){
|
initializeWindows = function() {
|
||||||
|
|
||||||
function addClickEvent(el, fn){
|
function addClickEvent(el, fn) {
|
||||||
['Link','Button'].each(function(item) {
|
['Link', 'Button'].each(function(item) {
|
||||||
if ($(el+item)){
|
if ($(el + item)) {
|
||||||
$(el+item).addEvent('click', fn);
|
$(el + item).addEvent('click', fn);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addClickEvent('download', function(e){
|
addClickEvent('download', function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: 'downloadPage',
|
id: 'downloadPage',
|
||||||
title: "_(Download from urls)",
|
title: "_(Download from urls)",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL:'download.html',
|
contentURL: 'download.html',
|
||||||
scrollbars: true,
|
scrollbars: true,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -71,13 +72,13 @@ initializeWindows = function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addClickEvent('upload', function(e){
|
addClickEvent('upload', function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: 'uploadPage',
|
id: 'uploadPage',
|
||||||
title: "_(Download local torrent)",
|
title: "_(Download local torrent)",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL:'upload.html',
|
contentURL: 'upload.html',
|
||||||
scrollbars: true,
|
scrollbars: true,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -93,7 +94,7 @@ initializeWindows = function(){
|
||||||
id: 'uploadLimitPage',
|
id: 'uploadLimitPage',
|
||||||
title: "_(Global Upload Speed Limiting)",
|
title: "_(Global Upload Speed Limiting)",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL:'uploadlimit.html?hash=global',
|
contentURL: 'uploadlimit.html?hash=global',
|
||||||
scrollbars: false,
|
scrollbars: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -106,13 +107,13 @@ initializeWindows = function(){
|
||||||
|
|
||||||
uploadLimitFN = function() {
|
uploadLimitFN = function() {
|
||||||
var h = myTable.selectedIds();
|
var h = myTable.selectedIds();
|
||||||
if(h.length){
|
if (h.length) {
|
||||||
var hash = h[0];
|
var hash = h[0];
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: 'uploadLimitPage',
|
id: 'uploadLimitPage',
|
||||||
title: "_(Torrent Upload Speed Limiting)",
|
title: "_(Torrent Upload Speed Limiting)",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL:'uploadlimit.html?hash='+hash,
|
contentURL: 'uploadlimit.html?hash=' + hash,
|
||||||
scrollbars: false,
|
scrollbars: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -129,7 +130,7 @@ initializeWindows = function(){
|
||||||
id: 'downloadLimitPage',
|
id: 'downloadLimitPage',
|
||||||
title: "_(Global Download Speed Limiting)",
|
title: "_(Global Download Speed Limiting)",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL:'downloadlimit.html?hash=global',
|
contentURL: 'downloadlimit.html?hash=global',
|
||||||
scrollbars: false,
|
scrollbars: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -142,13 +143,13 @@ initializeWindows = function(){
|
||||||
|
|
||||||
downloadLimitFN = function() {
|
downloadLimitFN = function() {
|
||||||
var h = myTable.selectedIds();
|
var h = myTable.selectedIds();
|
||||||
if(h.length){
|
if (h.length) {
|
||||||
var hash = h[0];
|
var hash = h[0];
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: 'downloadLimitPage',
|
id: 'downloadLimitPage',
|
||||||
title: "_(Torrent Download Speed Limiting)",
|
title: "_(Torrent Download Speed Limiting)",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL:'downloadlimit.html?hash='+hash,
|
contentURL: 'downloadlimit.html?hash=' + hash,
|
||||||
scrollbars: false,
|
scrollbars: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -167,12 +168,12 @@ initializeWindows = function(){
|
||||||
new Request({url: 'command/delete', method: 'post', data: {hash: item}}).send();
|
new Request({url: 'command/delete', method: 'post', data: {hash: item}}).send();
|
||||||
});
|
});
|
||||||
}*/
|
}*/
|
||||||
if(h.length) {
|
if (h.length) {
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: 'confirmDeletionPage',
|
id: 'confirmDeletionPage',
|
||||||
title: "_(Deletion confirmation - qBittorrent)",
|
title: "_(Deletion confirmation - qBittorrent)",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL:'confirmdeletion.html?hashes='+h.join(','),
|
contentURL: 'confirmdeletion.html?hashes=' + h.join(','),
|
||||||
scrollbars: false,
|
scrollbars: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -183,57 +184,83 @@ initializeWindows = function(){
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
addClickEvent('delete', function(e){
|
addClickEvent('delete', function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
deleteFN();
|
deleteFN();
|
||||||
});
|
});
|
||||||
|
|
||||||
pauseFN = function() {
|
pauseFN = 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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
startFN = function() {
|
startFN = 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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
recheckFN = function() {
|
recheckFN = 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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
['pause','resume', 'recheck'].each(function(item) {
|
['pause', 'resume', 'recheck'].each(function(item) {
|
||||||
addClickEvent(item, function(e){
|
addClickEvent(item, function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
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();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
['decreasePrio','increasePrio', 'topPrio', 'bottomPrio'].each(function(item) {
|
['decreasePrio', 'increasePrio', 'topPrio', 'bottomPrio'].each(function(item) {
|
||||||
addClickEvent(item, function(e){
|
addClickEvent(item, function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
setPriorityFN(item);
|
setPriorityFN(item);
|
||||||
});
|
});
|
||||||
|
@ -241,12 +268,18 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addClickEvent('about', function(e){
|
addClickEvent('about', function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: 'aboutpage',
|
id: 'aboutpage',
|
||||||
|
@ -259,7 +292,7 @@ initializeWindows = function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addClickEvent('logout', function(e){
|
addClickEvent('logout', function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
new Request({
|
new Request({
|
||||||
url: '/logout',
|
url: '/logout',
|
||||||
|
@ -270,7 +303,7 @@ initializeWindows = function(){
|
||||||
}).send();
|
}).send();
|
||||||
});
|
});
|
||||||
|
|
||||||
addClickEvent('shutdown', function(e){
|
addClickEvent('shutdown', function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
new Request({
|
new Request({
|
||||||
url: 'command/shutdown',
|
url: 'command/shutdown',
|
||||||
|
@ -281,8 +314,7 @@ initializeWindows = function(){
|
||||||
}).send();
|
}).send();
|
||||||
});
|
});
|
||||||
|
|
||||||
updateSpeedInBrowserTitleBarLinkCheckState = function()
|
updateSpeedInBrowserTitleBarLinkCheckState = function() {
|
||||||
{
|
|
||||||
if (localStorage.getItem('speed_in_browser_title_bar') == 'true')
|
if (localStorage.getItem('speed_in_browser_title_bar') == 'true')
|
||||||
$(speedInBrowserTitleBarLink).firstChild.style.opacity = '1';
|
$(speedInBrowserTitleBarLink).firstChild.style.opacity = '1';
|
||||||
else
|
else
|
||||||
|
@ -291,7 +323,7 @@ initializeWindows = function(){
|
||||||
|
|
||||||
updateSpeedInBrowserTitleBarLinkCheckState();
|
updateSpeedInBrowserTitleBarLinkCheckState();
|
||||||
|
|
||||||
addClickEvent('speedInBrowserTitleBar', function(e){
|
addClickEvent('speedInBrowserTitleBar', function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
var speed_in_browser_title_bar = localStorage.getItem('speed_in_browser_title_bar');
|
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';
|
speed_in_browser_title_bar = speed_in_browser_title_bar == 'true' ? 'false' : 'true';
|
||||||
|
@ -300,8 +332,8 @@ initializeWindows = function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,9 +13,8 @@ Requires:
|
||||||
Core.js, Window.js
|
Core.js, Window.js
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MochaUI.extend({
|
MochaUI.extend({
|
||||||
addUpLimitSlider: function(hash){
|
addUpLimitSlider: function(hash) {
|
||||||
if ($('uplimitSliderarea')) {
|
if ($('uplimitSliderarea')) {
|
||||||
var windowOptions = MochaUI.Windows.windowOptions;
|
var windowOptions = MochaUI.Windows.windowOptions;
|
||||||
var sliderFirst = true;
|
var sliderFirst = true;
|
||||||
|
@ -26,71 +25,79 @@ MochaUI.extend({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {},
|
data: {},
|
||||||
onSuccess: function(data) {
|
onSuccess: function(data) {
|
||||||
if(data){
|
if (data) {
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get torrent upload limit
|
// Get torrent upload limit
|
||||||
// And create slider
|
// And create slider
|
||||||
if(hash == 'global') {
|
if (hash == 'global') {
|
||||||
var up_limit = maximum;
|
var up_limit = maximum;
|
||||||
if(up_limit < 0) up_limit = 0;
|
if (up_limit < 0) up_limit = 0;
|
||||||
maximum = 1000;
|
maximum = 1000;
|
||||||
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
|
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
|
||||||
steps: maximum,
|
steps: maximum,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
initialStep: up_limit.round(),
|
initialStep: up_limit.round(),
|
||||||
onChange: function(pos){
|
onChange: function(pos) {
|
||||||
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', "");
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
});
|
});
|
||||||
// Set default value
|
// Set default value
|
||||||
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();
|
||||||
if(up_limit < 0) up_limit = 0;
|
if (up_limit < 0) up_limit = 0;
|
||||||
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
|
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
|
||||||
steps: maximum,
|
steps: maximum,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
initialStep: (up_limit/1024.).round(),
|
initialStep: (up_limit / 1024.).round(),
|
||||||
onChange: function(pos){
|
onChange: function(pos) {
|
||||||
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', "");
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
});
|
});
|
||||||
// Set default value
|
// Set default value
|
||||||
if(up_limit == 0) {
|
if (up_limit == 0) {
|
||||||
$('uplimitUpdatevalue').set('html', '∞');
|
$('uplimitUpdatevalue').set('html', '∞');
|
||||||
$('upLimitUnit').set('html', "");
|
$('upLimitUnit').set('html', "");
|
||||||
} else {
|
}
|
||||||
$('uplimitUpdatevalue').set('html', (up_limit/1024.).round());
|
else {
|
||||||
|
$('uplimitUpdatevalue').set('html', (up_limit / 1024.).round());
|
||||||
$('upLimitUnit').set('html', "_(KiB/s)");
|
$('upLimitUnit').set('html', "_(KiB/s)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +109,7 @@ MochaUI.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addDlLimitSlider: function(hash){
|
addDlLimitSlider: function(hash) {
|
||||||
if ($('dllimitSliderarea')) {
|
if ($('dllimitSliderarea')) {
|
||||||
var windowOptions = MochaUI.Windows.windowOptions;
|
var windowOptions = MochaUI.Windows.windowOptions;
|
||||||
var sliderFirst = true;
|
var sliderFirst = true;
|
||||||
|
@ -113,71 +120,79 @@ MochaUI.extend({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {},
|
data: {},
|
||||||
onSuccess: function(data) {
|
onSuccess: function(data) {
|
||||||
if(data){
|
if (data) {
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get torrent download limit
|
// Get torrent download limit
|
||||||
// And create slider
|
// And create slider
|
||||||
if(hash == "global") {
|
if (hash == "global") {
|
||||||
var dl_limit = maximum;
|
var dl_limit = maximum;
|
||||||
if(dl_limit < 0) dl_limit = 0;
|
if (dl_limit < 0) dl_limit = 0;
|
||||||
maximum = 10000;
|
maximum = 10000;
|
||||||
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
|
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
|
||||||
steps: maximum,
|
steps: maximum,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
initialStep: dl_limit.round(),
|
initialStep: dl_limit.round(),
|
||||||
onChange: function(pos){
|
onChange: function(pos) {
|
||||||
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', "");
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
});
|
});
|
||||||
// Set default value
|
// Set default value
|
||||||
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();
|
||||||
if(dl_limit < 0) dl_limit = 0;
|
if (dl_limit < 0) dl_limit = 0;
|
||||||
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
|
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
|
||||||
steps: maximum,
|
steps: maximum,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
initialStep: (dl_limit/1024.).round(),
|
initialStep: (dl_limit / 1024.).round(),
|
||||||
onChange: function(pos){
|
onChange: function(pos) {
|
||||||
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', "");
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
});
|
});
|
||||||
// Set default value
|
// Set default value
|
||||||
if(dl_limit == 0) {
|
if (dl_limit == 0) {
|
||||||
$('dllimitUpdatevalue').set('html', '∞');
|
$('dllimitUpdatevalue').set('html', '∞');
|
||||||
$('dlLimitUnit').set('html', "");
|
$('dlLimitUnit').set('html', "");
|
||||||
} else {
|
}
|
||||||
$('dllimitUpdatevalue').set('html', (dl_limit/1024.).round());
|
else {
|
||||||
|
$('dllimitUpdatevalue').set('html', (dl_limit / 1024.).round());
|
||||||
$('dlLimitUnit').set('html', "_(KiB/s)");
|
$('dlLimitUnit').set('html', "_(KiB/s)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,96 +1,98 @@
|
||||||
var ProgressBar=new Class({
|
var ProgressBar = new Class({
|
||||||
initialize:function(value,parameters){
|
initialize: function(value, parameters) {
|
||||||
var vals={
|
var vals = {
|
||||||
'id':'progressbar_'+(ProgressBars++),
|
'id': 'progressbar_' + (ProgressBars++),
|
||||||
'value':$pick(value,0),
|
'value': $pick(value, 0),
|
||||||
'width':0,
|
'width': 0,
|
||||||
'height':0,
|
'height': 0,
|
||||||
'darkbg':'#006',
|
'darkbg': '#006',
|
||||||
'darkfg':'#fff',
|
'darkfg': '#fff',
|
||||||
'lightbg':'#fff',
|
'lightbg': '#fff',
|
||||||
'lightfg':'#000'
|
'lightfg': '#000'
|
||||||
};
|
};
|
||||||
if(parameters && $type(parameters)=='object')$extend(vals,parameters);
|
if (parameters && $type(parameters) == 'object') $extend(vals, parameters);
|
||||||
if(vals.height<12)vals.height=12;
|
if (vals.height < 12) vals.height = 12;
|
||||||
var obj=new Element('div',{
|
var obj = new Element('div', {
|
||||||
'id':vals.id,
|
'id': vals.id,
|
||||||
'class':'progressbar_wrapper',
|
'class': 'progressbar_wrapper',
|
||||||
'styles':{
|
'styles': {
|
||||||
'border':'1px solid #000',
|
'border': '1px solid #000',
|
||||||
'width':vals.width,
|
'width': vals.width,
|
||||||
'height':vals.height,
|
'height': vals.height,
|
||||||
'position':'relative'
|
'position': 'relative'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
obj.vals=vals;
|
obj.vals = vals;
|
||||||
obj.vals.value = $pick(value, 0); // Fix by Chris
|
obj.vals.value = $pick(value, 0); // Fix by Chris
|
||||||
obj.vals.dark=new Element('div',{
|
obj.vals.dark = new Element('div', {
|
||||||
'id':vals.id+'_dark',
|
'id': vals.id + '_dark',
|
||||||
'class':'progressbar_dark',
|
'class': 'progressbar_dark',
|
||||||
'styles':{
|
'styles': {
|
||||||
'width':vals.width,
|
'width': vals.width,
|
||||||
'height':vals.height,
|
'height': vals.height,
|
||||||
'background':vals.darkbg,
|
'background': vals.darkbg,
|
||||||
'color':vals.darkfg,
|
'color': vals.darkfg,
|
||||||
'position':'absolute',
|
'position': 'absolute',
|
||||||
'text-align':'center',
|
'text-align': 'center',
|
||||||
'left':0,
|
'left': 0,
|
||||||
'top':0,
|
'top': 0,
|
||||||
'line-height':vals.height-2
|
'line-height': vals.height - 2
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
obj.vals.light=new Element('div',{
|
obj.vals.light = new Element('div', {
|
||||||
'id':vals.id+'_light',
|
'id': vals.id + '_light',
|
||||||
'class':'progressbar_light',
|
'class': 'progressbar_light',
|
||||||
'styles':{
|
'styles': {
|
||||||
'width':vals.width,
|
'width': vals.width,
|
||||||
'height':vals.height,
|
'height': vals.height,
|
||||||
'background':vals.lightbg,
|
'background': vals.lightbg,
|
||||||
'color':vals.lightfg,
|
'color': vals.lightfg,
|
||||||
'position':'absolute',
|
'position': 'absolute',
|
||||||
'text-align':'center',
|
'text-align': 'center',
|
||||||
'left':0,
|
'left': 0,
|
||||||
'top':0,
|
'top': 0,
|
||||||
'line-height':vals.height-2
|
'line-height': vals.height - 2
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
obj.appendChild(obj.vals.dark);
|
obj.appendChild(obj.vals.dark);
|
||||||
obj.appendChild(obj.vals.light);
|
obj.appendChild(obj.vals.light);
|
||||||
obj.getValue=ProgressBar_getValue;
|
obj.getValue = ProgressBar_getValue;
|
||||||
obj.setValue=ProgressBar_setValue;
|
obj.setValue = ProgressBar_setValue;
|
||||||
if(vals.width)obj.setValue(vals.value);
|
if (vals.width) obj.setValue(vals.value);
|
||||||
else setTimeout('ProgressBar_checkForParent("'+obj.id+'")',1);
|
else setTimeout('ProgressBar_checkForParent("' + obj.id + '")', 1);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function ProgressBar_getValue(){
|
function ProgressBar_getValue() {
|
||||||
return this.vals.value;
|
return this.vals.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProgressBar_setValue(value){
|
function ProgressBar_setValue(value) {
|
||||||
value=parseFloat(value);
|
value = parseFloat(value);
|
||||||
if(isNaN(value))value=0;
|
if (isNaN(value)) value = 0;
|
||||||
if(value>100)value=100;
|
if (value > 100) value = 100;
|
||||||
if(value<0)value=0;
|
if (value < 0) value = 0;
|
||||||
this.vals.value=value;
|
this.vals.value = value;
|
||||||
this.vals.dark.empty();
|
this.vals.dark.empty();
|
||||||
this.vals.light.empty();
|
this.vals.light.empty();
|
||||||
this.vals.dark.appendText(value+'%');
|
this.vals.dark.appendText(value + '%');
|
||||||
this.vals.light.appendText(value+'%');
|
this.vals.light.appendText(value + '%');
|
||||||
var r=parseInt(this.vals.width*(value/100));
|
var r = parseInt(this.vals.width * (value / 100));
|
||||||
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){
|
|
||||||
var obj=$(id);
|
function ProgressBar_checkForParent(id) {
|
||||||
if(!obj)return;
|
var obj = $(id);
|
||||||
if(!obj.parentNode)return setTimeout('ProgressBar_checkForParent("'+id+'")',1);
|
if (!obj) return;
|
||||||
obj.setStyle('width','100%');
|
if (!obj.parentNode) return setTimeout('ProgressBar_checkForParent("' + id + '")', 1);
|
||||||
var w=obj.offsetWidth;
|
obj.setStyle('width', '100%');
|
||||||
obj.vals.dark.setStyle('width',w);
|
var w = obj.offsetWidth;
|
||||||
obj.vals.light.setStyle('width',w);
|
obj.vals.dark.setStyle('width', w);
|
||||||
obj.vals.width=w;
|
obj.vals.light.setStyle('width', w);
|
||||||
|
obj.vals.width = w;
|
||||||
obj.setValue(obj.vals.value);
|
obj.setValue(obj.vals.value);
|
||||||
}
|
}
|
||||||
var ProgressBars=0;
|
|
||||||
|
var ProgressBars = 0;
|
Loading…
Add table
Add a link
Reference in a new issue