GW2 map_floor Map counter

Lists maps from map_floor.json, highlighting maps that have duplicates.

by UselessCode

HTML

<script src="http://www.uselesscode.org/jsfiddle/lib/oboe.min.js"></script>
<ul id="out"></ul>

CSS

.highlight {
    background: #fa5;
}

JavaScript

//alert('running');
var $out = $('#out'),
    regions = {},
    regionNames = {},
    mapNames = {},
    currentRegion,
    currentMap,
    walkMaps =  function (maps) {
var out = '';
$.each(maps, function (id, count) {
  var cls = count > 1 ? ' class="highlight"' : '';
  out += '<li' + cls + '>' + mapNames[id] + ' (#' + id + '): ' + count + '</li>';
});
return '<ul>' + out + '</ul>';
};

$out.html('Loading/parsing map_floor.json');
oboe.doGet('https://api.guildwars2.com/v1/map_floor.json?lang=en&continent_id=1&floor=1', function done() {
// done parsing JSON, display results
var out = '';
$.each(regions, function (id, region) {
out += '<li>' + regionNames[id] + ' (#' + id + ')' + walkMaps(region) + '</li>';
});
$out.html(out);
}).onPath('regions.*', function (obj, path) {
  // init region
  var regionId = path[1];
  currentRegion = regionId;
  regions[regionId] = {};
}).onNode('regions.*', function (obj, path) {
  regionNames[currentRegion] = obj.name;
}).onNode('regions[*].maps[*]', function (mapObj, path) {
  //console.log(path);
  var mapId = path[3],
    count = regions[currentRegion][mapId] || 0;
  regions[currentRegion][mapId] = count + 1;
  mapNames[mapId] = mapObj.name;
});