API: JS: Server

ebollens edited this page Oct 3, 2011 · 1 revision
Clone this wiki locally

Description

This functionality is responsible for making data determined client-side (Javascript) available server-side (PHP). To do this, an anonymous function is invoked on each request of the JS handler that writes cookies based on client-side device telemetry, if they are not already set or have changed, and then reloads the page to push the data back server-side.

This functionality is defined in assets/js/core/server.js and is automatically loaded by the JS handler.

Current (MWF 1.2)

This functionality writes cookies for data from the following other libraries:

Each of these libraries have a cookieName property that define the name of the cookie written.

This functionality will reload the page in the following cases:

  • When a user arrives for the first time on a page powered by the MWF.
  • When a user changes their capabilities (and thus classification), screen dimensions or user agent.
  • When a user issues an override or unsets an override.

As such, caution should be used in allowing a user to make a POST to their first page under MWF.

Once this routine has run, this data is then exposed in the PHP API on the framework server through the objects Classification, Screen and User_Agent.

Previous (MWF 1.0-1.1)

This functionality was not necessary before MWF 1.2, as MWF 1.0-1.1 determined capabilities server-side through static metadata and then pushed the data client-side.