Browse Source

WebUI: Define some functions on load

These function shouldn't be called when the page is not loaded yet,
so it makes sense to define them later.
adaptive-webui-19844
Gabriele 10 years ago
parent
commit
95bf2ffc51
  1. 158
      src/webui/www/public/scripts/client.js

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

@ -25,6 +25,8 @@ @@ -25,6 +25,8 @@
myTable = new dynamicTable();
var updatePropertiesPanel = function(){};
var updateTransferInfo = function(){};
var updateTransferList = function(){};
var stateToImg = function (state) {
if (state == "pausedUP" || state == "pausedDL") {
@ -43,6 +45,82 @@ var stateToImg = function (state) { @@ -43,6 +45,82 @@ var stateToImg = function (state) {
filter = getLocalStorageItem('selected_filter', 'all');
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();
setFilter = function (f) {
// Visually Select the right filter
$("all_filter").removeClass("selectedFilter");
$("downloading_filter").removeClass("selectedFilter");
$("completed_filter").removeClass("selectedFilter");
$("paused_filter").removeClass("selectedFilter");
$("active_filter").removeClass("selectedFilter");
$("inactive_filter").removeClass("selectedFilter");
$(f + "_filter").addClass("selectedFilter");
filter = f;
localStorage.setItem('selected_filter', f);
// Reload torrents
if (typeof myTable.table != 'undefined')
updateTransferList();
}
new MochaUI.Panel({
id : 'Filters',
title : 'Panel',
header : false,
padding : {
top : 0,
right : 0,
bottom : 0,
left : 0
},
loadMethod : 'xhr',
contentURL : 'filters.html',
onContentLoaded : function () {
setFilter(filter);
},
column : 'filtersColumn',
height : 300
});
initializeWindows();
var speedInTitle = localStorage.getItem('speed_in_browser_title_bar') == "true";
if (!speedInTitle)
$('speedInBrowserTitleBarLink').firstChild.style.opacity = '0';
var loadTorrentsInfoTimer;
var loadTorrentsInfo = function () {
var queueing_enabled = false;
@ -145,87 +223,11 @@ var loadTorrentsInfo = function () { @@ -145,87 +223,11 @@ var loadTorrentsInfo = function () {
}).send();
};
var updateTransferList = function() {
updateTransferList = function() {
clearTimeout(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();
setFilter = function (f) {
// Visually Select the right filter
$("all_filter").removeClass("selectedFilter");
$("downloading_filter").removeClass("selectedFilter");
$("completed_filter").removeClass("selectedFilter");
$("paused_filter").removeClass("selectedFilter");
$("active_filter").removeClass("selectedFilter");
$("inactive_filter").removeClass("selectedFilter");
$(f + "_filter").addClass("selectedFilter");
filter = f;
localStorage.setItem('selected_filter', f);
// Reload torrents
if (typeof myTable.table != 'undefined')
updateTransferList();
}
new MochaUI.Panel({
id : 'Filters',
title : 'Panel',
header : false,
padding : {
top : 0,
right : 0,
bottom : 0,
left : 0
},
loadMethod : 'xhr',
contentURL : 'filters.html',
onContentLoaded : function () {
setFilter(filter);
},
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';
@ -263,7 +265,7 @@ window.addEvent('load', function () { @@ -263,7 +265,7 @@ window.addEvent('load', function () {
}).send();
};
var updateTransferInfo = function() {
updateTransferInfo = function() {
clearTimeout(loadTransferInfoTimer);
loadTransferInfo();
}

Loading…
Cancel
Save