Browse Source

Restore selected filter on page load

adaptive-webui-19844
buinsky 10 years ago
parent
commit
44992056cf
  1. 9
      src/webui/www/public/filters.html
  2. 38
      src/webui/www/public/scripts/client.js

9
src/webui/www/public/filters.html

@ -6,12 +6,3 @@
<li id="active_filter"><a href="#" onclick="setFilter('active');"><img src="images/skin/filteractive.png"/>_(Active)</a></li> <li id="active_filter"><a href="#" onclick="setFilter('active');"><img src="images/skin/filteractive.png"/>_(Active)</a></li>
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');"><img src="images/skin/filterinactive.png"/>_(Inactive)</a></li> <li id="inactive_filter"><a href="#" onclick="setFilter('inactive');"><img src="images/skin/filterinactive.png"/>_(Inactive)</a></li>
</ul> </ul>
<script type="text/javascript">
// Remember this via Cookie
var filter = Cookie.read('selected_filter');
if(!$defined(last_filter)) {
filter = 'all';
}
$(filter+'_filter').addClass('selectedFilter');
</script>

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

@ -39,6 +39,8 @@ var stateToImg = function (state) {
return 'images/skin/' + state + '.png'; return 'images/skin/' + state + '.png';
}; };
filter = getLocalStorageItem('selected_filter', 'all');
var loadTorrentsInfoTimer; var loadTorrentsInfoTimer;
var loadTorrentsInfo = function () { var loadTorrentsInfo = function () {
var queueing_enabled = false; var queueing_enabled = false;
@ -172,6 +174,23 @@ window.addEvent('load', function () {
resizeLimit : [100, 300] resizeLimit : [100, 300]
}); });
MochaUI.Desktop.setDesktopSize(); 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({ new MochaUI.Panel({
id : 'Filters', id : 'Filters',
title : 'Panel', title : 'Panel',
@ -184,6 +203,9 @@ window.addEvent('load', function () {
}, },
loadMethod : 'xhr', loadMethod : 'xhr',
contentURL : 'filters.html', contentURL : 'filters.html',
onContentLoaded : function () {
setFilter(filter);
},
column : 'filtersColumn', column : 'filtersColumn',
height : 300 height : 300
}); });
@ -290,22 +312,6 @@ window.addEvent('load', function () {
column : 'mainColumn', column : 'mainColumn',
height : prop_h height : prop_h
}); });
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
updateTransferList();
}
}); });
function closeWindows() { function closeWindows() {

Loading…
Cancel
Save