From e4326a439438dc172ac9ef14eeb722a88a31c127 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Fri, 16 May 2014 00:54:00 +0200 Subject: [PATCH] Persist category filters --- index.html | 14 +++++++------- js/ctrls/download.js | 32 +++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 0d81a29..d5b688c 100755 --- a/index.html +++ b/index.html @@ -246,31 +246,31 @@
diff --git a/js/ctrls/download.js b/js/ctrls/download.js index d479694..59ceaa0 100644 --- a/js/ctrls/download.js +++ b/js/ctrls/download.js @@ -188,6 +188,7 @@ function( scope.filterError = !scope.filterError; scope.filterPaused = !scope.filterPaused; scope.filterRemoved = !scope.filterRemoved; + scope.persistFilters(); }; scope.resetFilters = function() { @@ -200,9 +201,38 @@ function( scope.filterRemoved = true; scope.clearFilter(); + scope.persistFilters(); }; - scope.resetFilters(); + 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(); + 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