bjorn/tiled — pull request #402 by dobesv (2013-03-28 21:34:37+00:00)
Title: Jsonp support

This patch adds JSONP support as requested in https://github.com/bjorn/tiled/issues/374

The JSON data is wrapped up like this:

```javascript
(function(name,data){
if(typeof onTileMapLoaded === 'undefined') {
if(typeof TileMaps === 'undefined') TileMaps = {};
TileMaps[name] = data;
} else {
onTileMapsLoaded(name,data);
}})("level1",
{
//... JSON DATA ...
});
```

This allows you to either hook the level having loaded as a callback by defining window.onTileMapLoaded or to consume the tilemap passively using window.TileMaps["level1"].

When loading a javascript file, it will skip past the JSONP stuff and just load the JSON part, so you don't have to keep any extra json or TMX file around to use this.