davestacey
2/17/2015 - 8:25 PM

Take the parents taxonomy TID, loop through the taxonomy locations returning the patent location

Take the parents taxonomy TID, loop through the taxonomy locations returning the patent location

      function findParentByTID(parents, callback){
        var locations =  nsmap.geoLocations;
        var parentsArray = parents;
          // Usually just one parent
          if (!parentsArray.length === 1) {
            // So far there is only one parent object, this is here as a test.
            console.warn('parentsArray.length != 1, unusual, test: get all parents?');
          }
          // Return just the first parent, always just one so far.
          //console.log('findParent-parentsArray', parentsArray[0]);
          var parentTID = parentsArray[0]
          // loop the object and match the TID
          for (var i = locations.length - 1; i >= 0; i--) {
            if (locations[i].tid == parentTID) {
              //console.log('-findParentByTID parentInfo:', locations[i]);
              //console.log(locations[i].name);
              callback(locations[i]);
            }
          };
      } //findParentByTID