Jon Atkins 7a19d30173 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
2013-11-30 22:26:40 +00:00

42 lines
983 B
JavaScript

/// 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;
}