openstreetmap/iD — pull request #2258 by hlaw (2014-06-16 20:44:00+00:00)
Title: Use grid to get country code; save code in context and display it

Further to https://github.com/openstreetmap/iD/pull/2246#issuecomment-45907119, I have incorporated the relevant code in this pull request for review.

## Functional changes
* Instead of calling nominatim for country code when displaying the address preset, the country code for the location at center of the editing window will be queried after each move (similar to the map contributor list). For the vast majority of time, the information would be obtained from loaded data without actual network access.
* The country code is saved in iD.context, making it available to all modules.
* The address preset is thus simplified - it just obtains the country code from the context. A level of call back is removed. (Some of the event code may not be needed now as the call is synchronous again, but perhaps such code may be useful in future.)

## User interface changes (for testing)
* Given that address presets (and probably other presets / behaviour in future) will depend on the country, a small status box showing the current country code is added at the lower left at sufficient zoom level.
* It would flash temporarily when the browser moves to a place with a new country code.
* For selected countries / territories (currently defined under ```js/id/ui/country_code.js```), the country code would become a link to the project page of the place under OSM wiki. This may better draw attention to the respective project pages to enhance their visibility. Should turn into json data file if the feature is useful.

## Building and testing
* Given the size I have not included the directory for country code data directly in the PR .
* Before running the code in webserver, please ```make tiles``` at the project directory first. This will pull the data from github and create the ```dist/tiles``` directory.
* build.js will incorporate one of these files (/dist/tiles/worldgrid.json), and should be run after make tiles.
* The test spec only tests for the results of getting the country codes (which are correct). When I tried to spy on the actual fakeserver calls to intercept individual file requests / response in the spec, I found that the fakeserver in one test can be called by subsequent tests, even through the environment is supposed to be setup / tear down between each test. I cannot get mocha / sinon to synchronously carry out each test in isolation.

Thank you!