Skip to content
caywood edited this page Feb 11, 2013 · 7 revisions

The client is a little complex because it is designed to smoothly update itself, while being robust against network failures. So it deserves a short outline.

The basic idea is to have an outer "super" page with an inner iframe.

The inner iframe gets updated while hidden in the background to prevent flicker.

If the network or the transit screen server is unreachable, the inner iFrame fails (although if the countdown timer code is enabled, it will keep arrival times ticking down to zero) but the outer page continues to refresh it so that when the network comes back up, everything gets restored.

The super-page handles updates of the screen layout on the fly by checking for a new "screen version" and creating an updated screen if the version has changed. This check happens every 45 seconds -- this is much more often than would be necessary for a deployed transit screen, but it helps when the user is designing the screen. (If the frequency were turned down to say 1x per day, the designer could still manually refresh the screen).

Outer screen webpage JS is generated by screen_wrapper.php and is at index.php/screen/index/ID where ID is the screen id when loaded and once every 25 seconds, it calls get_update.

get_update first checks pollurl (index.php/update/version/10, 
	containing a hash like "3458900bd8a00997dd9e9247f83f511b")
this is the version and indicates whether the screen needs to be changed	
if there is a version change, create a hidden inner iframe with src = callurl (index.php/screen/inner/10)
The time is passed in too, like index.php/screen/inner/10?1349926247 

In case of a version change, Screen waits for 15 seconds to allow the server to update
then calls switch_frames which checks to see if the new iframe has blocks.
if not, new iframe is removed.
if so, it: 
	removes all out of date blocks
	shows the new iframe
	and updates version

The inner iframe screen is in screen.js (which is included by screen_header.php) when loaded (using jQuery ready function), and every 45 seconds (using jQuery everyTime), it calls refresh_data for an update

first this gets the updated JSON arrival data at: index.php/update/json/10

(if screen_version has increased, reload the screen)

for each stop in the updated data, call generate_blocks to create or recreate the blocks from it.

URLs list

  • index.php/screen/index/ID - super page
  • index.php/screen/inner/ID - inner iframe
  • index.php/update/version/ID - current screen version
  • index.php/update/json/ID - current JSON arrival data