Persist category filters

This commit is contained in:
Nils Maier 2014-05-16 00:54:00 +02:00
parent 8b5b465231
commit e4326a4394
2 changed files with 38 additions and 8 deletions

View File

@ -246,31 +246,31 @@
<button ng-click="clearFilter()" class="btn btn-default btn-mini">Clear</button> <button ng-click="clearFilter()" class="btn btn-default btn-mini">Clear</button>
<br> <br>
<label for="filter-speed"> <label for="filter-speed">
<input type="checkbox" ng-model="filterSpeed" id="filter-speed"> <input type="checkbox" ng-model="filterSpeed" ng-change="persistFilters()" id="filter-speed">
running running
</label> </label>
<label for="filter-active"> <label for="filter-active">
<input type="checkbox" ng-model="filterActive" id="filter-active"> <input type="checkbox" ng-model="filterActive" ng-change="persistFilters()" id="filter-active">
active active
</label> </label>
<label for="filter-waiting"> <label for="filter-waiting">
<input type="checkbox" ng-model="filterWaiting" id="filter-waiting"> <input type="checkbox" ng-model="filterWaiting" ng-change="persistFilters()" id="filter-waiting">
waiting waiting
</label> </label>
<label for="filter-complete"> <label for="filter-complete">
<input type="checkbox" ng-model="filterComplete" id="filter-complete"> <input type="checkbox" ng-model="filterComplete" ng-change="persistFilters()" id="filter-complete">
complete complete
</label> </label>
<label for="filter-error"> <label for="filter-error">
<input type="checkbox" ng-model="filterError" id="filter-error"> <input type="checkbox" ng-model="filterError" ng-change="persistFilters()" id="filter-error">
error error
</label> </label>
<label for="filter-paused"> <label for="filter-paused">
<input type="checkbox" ng-model="filterPaused" id="filter-paused"> <input type="checkbox" ng-model="filterPaused" ng-change="persistFilters()" id="filter-paused">
paused paused
</label> </label>
<label for="filter-removed"> <label for="filter-removed">
<input type="checkbox" ng-model="filterRemoved" id="filter-removed"> <input type="checkbox" ng-model="filterRemoved" ng-change="persistFilters()" id="filter-removed">
removed removed
</label> </label>
<button ng-click="toggleStateFilters()" class="btn btn-default btn-mini">Toggle</button> <button ng-click="toggleStateFilters()" class="btn btn-default btn-mini">Toggle</button>

View File

@ -188,6 +188,7 @@ function(
scope.filterError = !scope.filterError; scope.filterError = !scope.filterError;
scope.filterPaused = !scope.filterPaused; scope.filterPaused = !scope.filterPaused;
scope.filterRemoved = !scope.filterRemoved; scope.filterRemoved = !scope.filterRemoved;
scope.persistFilters();
}; };
scope.resetFilters = function() { scope.resetFilters = function() {
@ -200,9 +201,38 @@ function(
scope.filterRemoved = scope.filterRemoved =
true; true;
scope.clearFilter(); scope.clearFilter();
scope.persistFilters();
}; };
scope.persistFilters = function() {
var o = JSON.stringify({
s: scope.filterSpeed,
a: scope.filterActive,
w: scope.filterWaiting,
c: scope.filterComplete,
e: scope.filterError,
p: scope.filterPaused,
r: scope.filterRemoved
});
utils.setCookie("aria2filters", o);
};
scope.loadFilters = function() {
var o = JSON.parse(utils.getCookie("aria2filters"));
if (!o) {
scope.resetFilters(); scope.resetFilters();
return;
}
scope.filterSpeed = !!o.s;
scope.filterActive = !!o.a;
scope.filterWaiting = !!o.w;
scope.filterComplete = !!o.c;
scope.filterError = !!o.e;
scope.filterPaused = !!o.p;
scope.filterRemoved = !!o.r;
};
scope.loadFilters();
// max downloads shown in one page // max downloads shown in one page