first update of sidebar for new data format: show the info available from the brief portal data

TODO: retrieve the full portal data and update to include that
This commit is contained in:
Jon Atkins
2013-11-30 22:26:40 +00:00
parent c197f74945
commit 7a19d30173
4 changed files with 222 additions and 110 deletions

41
code/portal_data.js Normal file
View File

@ -0,0 +1,41 @@
/// PORTAL DATA TOOLS ///////////////////////////////////////////////////
// misc functions to get portal info
// search through the links data for all that link from or to a portal. returns an object with separate lists of in
// and out links. may or may not be as accurate as the portal details, depending on how much data the API returns
window.getPortalLinks = function(guid) {
var links = { in: [], out: [] };
$.each(window.links, function(g,l) {
var d = l.options.data;
if (d.oGuid == guid) {
links.out.push(g);
}
if (d.dGuid == guid) {
links.in.push(g);
}
});
return links;
}
// search through the fields for all that reference a portal
window.getPortalFields = function(guid) {
var fields = [];
$.each(window.fields, function(g,f) {
var d = f.options.data;
if ( d.points[0].guid == guid
|| d.points[1].guid == guid
|| d.points[2].guid == guid ) {
fields.push(g);
}
});
return fields;
}