Skip to content

Commit

Permalink
rewire to pull readable and color properties; work on #317
Browse files Browse the repository at this point in the history
  • Loading branch information
kltm committed Mar 18, 2016
1 parent a212e24 commit a561e5c
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions javascript/npm/amigo2-instance-data/lib/amigo2-instance-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,57 @@ var amigo = function(more_dispatch){

// .ui subsection.
// this.ui = {};

/*
* Function: readable
*
* Get readable label for the entity, if it can be found in the
* context.
*
* Parameters:
* id - the string id of the entity
*
* Returns:
* string label, or incoming id if not found
*/
this.readable = function(id){

var retval = id;

if( anchor.data && anchor.data.context && anchor.data.context[id] ){
var entry = anchor.data.context[id];
if( entry['readable'] ){
retval = entry['readable'];
}
}
return retval;
};

/*
* Function: color
*
* Get color string for the entity, if it can be found in the
* context.
*
* Parameters:
* id - the string id of the entity
*
* Returns:
* string label, or "#888888" if not found
*/
this.color = function(id){

var retval = '#888888';

if( anchor.data && anchor.data.context && anchor.data.context[id] ){
var entry = anchor.data.context[id];
if( entry['color'] ){
retval = entry['color'];
}
}
return retval;
};

};

///
Expand Down

0 comments on commit a561e5c

Please sign in to comment.