diff --git a/src/pyj/viewer/router.pyj b/src/pyj/viewer/router.pyj new file mode 100644 index 0000000000..65ed18978a --- /dev/null +++ b/src/pyj/viewer/router.pyj @@ -0,0 +1,19 @@ +# vim:fileencoding=utf-8 +# License: GPL v3 Copyright: 2018, Kovid Goyal +from __python__ import bound_methods, hash_literals + +from modals import close_all_modals +from utils import parse_url_params + + +def get_current_query(newval): + if newval: + get_current_query.ans = newval + return get_current_query.ans or {} + + +def apply_url(): + close_all_modals() # needed to close any error dialogs, etc when clicking back or forward in the browser or using push_state() to go to a new page + data = parse_url_params() + data.mode = data.mode or 'read_book' + get_current_query.ans = data