Changeset 2311


Ignore:
Timestamp:
Sep 2, 2013, 4:25:31 PM (5 years ago)
Author:
matthijs
Message:

luci: Fix auto-reloading for quick state changes

For pages that support auto-reloading, javascript periodicially does an
AJAX request to the Fonera to get the current state. If that state is
different from before, the page is reloaded.

However, no initial state was set, so the first AJAX request would never
trigger a reload, but always initialize the local state kept by
javascript. If the state changed between rendering the page and the
first AJAX request, no reload would be triggered even though the page
displayed does not show the right state.

Since the first AJAX request was done after 10 seconds, this situation
could easily be triggered (for example when clicking "Connect" in the 3G
interface).

Now, a first request is done directly after loading the page. This
reduces the window for this bug greatly. Ideally, the initial state
would be set while rendering the page instead of through the first AJAX
request, but the relevant templates currently do not have access to the
required context for this, so this less-then-ideal solution is preferred
over the pile of changes needed in luci otherwise.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/luci/modules/admin-fon/luasrc/view/fon_js/main.htm

    r713 r2311  
    9696function fon_site_reload(path) {
    9797        var param = new Array(path)
    98         new PeriodicalExecuter(function() {
     98        var reload = function() {
    9999                json_call(
    100100                        "<%=luci.dispatcher.build_url("fon_rpc","fon")%>",
     
    107107                                }
    108108                )
    109                 }, 10
    110         );
     109        };
     110        new PeriodicalExecuter(reload , 10);
     111        // Check state now, to get the initial state
     112        reload();
    111113}
    112114
Note: See TracChangeset for help on using the changeset viewer.