diff options
author | Dan McGee <dan@archlinux.org> | 2014-03-09 11:49:22 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2014-03-09 11:49:22 -0500 |
commit | 697a2b15c1e402c1c624af1ffeaf5123d7fb0e9f (patch) | |
tree | 38f8bddc706a6559534219906513edc9f49c5179 | |
parent | 2e06e74d3a2a09cbb2a2521cdd55d6543cb56674 (diff) |
Use localStorage to save/restore todolist filters
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | sitestatic/archweb.js | 19 | ||||
-rw-r--r-- | templates/todolists/view.html | 6 |
2 files changed, 24 insertions, 1 deletions
diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js index 8212e85b..457e334c 100644 --- a/sitestatic/archweb.js +++ b/sitestatic/archweb.js @@ -367,6 +367,25 @@ function filter_pkgs_reset(callback) { callback(); } +function filter_todolist_save(list_id) { + var state = $('#todolist_filter').serializeArray(); + localStorage['filter_todolist_' + list_id] = JSON.stringify(state); +} +function filter_todolist_load(list_id) { + var state = localStorage['filter_todolist_' + list_id]; + if (!state) + return; + state = JSON.parse(state); + $('#todolist_filter .arch_filter').removeAttr('checked'); + $('#todolist_filter .repo_filter').removeAttr('checked'); + $('#id_incomplete').removeAttr('checked'); + $('#id_mine_only').removeAttr('checked'); + $.each(state, function (i, v) { + // this assumes our only filters are checkboxes + $('#todolist_filter input[name="' + v['name'] + '"]').attr('checked', 'checked'); + }); +} + /* signoffs.html */ function signoff_package() { // TODO: fix usage of this diff --git a/templates/todolists/view.html b/templates/todolists/view.html index a3ee5479..0045390c 100644 --- a/templates/todolists/view.html +++ b/templates/todolists/view.html @@ -118,10 +118,14 @@ $(document).ready(function() { }); $(document).ready(function() { $('a.status-link').click(todolist_flag); - var filter_func = function() { filter_pkgs_list('#todolist_filter', '#dev-todo-pkglist tbody'); }; + var filter_func = function() { + filter_pkgs_list('#todolist_filter', '#dev-todo-pkglist tbody'); + filter_todolist_save({{ list.id }}); + }; $('#todolist_filter input').change(filter_func); $('#criteria_reset').click(function() { filter_pkgs_reset(filter_func); }); // fire function on page load to ensure the current form selections take effect + filter_todolist_load({{ list.id }}); filter_func(); }); </script> |