Skip to content

Instantly share code, notes, and snippets.

@robfe
Created August 3, 2016 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robfe/45d6c6468da6922f50804e09d39030f8 to your computer and use it in GitHub Desktop.
Save robfe/45d6c6468da6922f50804e09d39030f8 to your computer and use it in GitHub Desktop.
var mm = components.mapModel;
var colours = '#FDB813 #A7BE38 #9EA4C1 #FF8384 #FFD87D'.split(' ');
function walk(node, depth){
if(!depth || !mm.getStyleForId(node.id, 'background')){
console.log('setting '+node.title +' to ' +colours[depth], depth);
mm.selectNode(node.id);
mm.updateStyle('script', 'background', colours[depth]);
}
if(!node.ideas || colours.length == depth+1){
return;
}
for(var k of Object.getOwnPropertyNames(node.ideas)){
walk(node.ideas[k], depth+1);
}
}
walk(mm.getIdea(), 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment