emxsys / callattendant

A python-based automated call attendant, call blocker, and voice messaging system running on a Raspberry Pi. Screens callers and block robocalls and scams with a low-cost Raspberry Pi and modem.
https://emxsys.github.io/callattendant/
MIT License
117 stars 36 forks source link

Add a Back button to View Call page #75

Closed emxsys closed 4 years ago

emxsys commented 4 years ago

A Back button is need to return the user to the original referrer, e.g, the dashboard. If the user invokes the Change button, the back history returns the user to the Manage Caller page. Perhaps a cookie is needed.

Perhapse Manage Caller should be a modal dialog. Not sure how the page routing would work for that.

emxsys commented 4 years ago

The trick is to keep track of the number of times POST was called on Manage Caller form. Then, instead of setting window.location.href which corrupted the history, we unwind the history like this:

<script>
// Go back to the original referrer
$('#back-button').on('click', function (event) {
    if (document.referrer == window.location.href) {
        // Don't go back to self after a POST, instead, we unwind
        // the history sufficently to go back to the original referrer
        history.go({{ post_count }} * -2)
    } else {
        history.back()
    }
});
</script>