Skip to content

Instantly share code, notes, and snippets.

@shrutis22
Last active May 9, 2018 16:54
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 shrutis22/048b15b8bb1f5165c25accc10d69f126 to your computer and use it in GitHub Desktop.
Save shrutis22/048b15b8bb1f5165c25accc10d69f126 to your computer and use it in GitHub Desktop.
({
showEmotion : function(component, event, helper) {
var toneAnalyzeResponse = component.get( "v.toneAnalyzeResponse" );
var standardTones = [ "joy", "sadness", "anger", "fear" ];
var emotion;
for( var i = 0; i <= standardTones.length - 1; i++ ) {
if( toneAnalyzeResponse.indexOf( standardTones[i] ) !== -1 ) {
emotion = standardTones[i];
break;
}
}
helper.getGiphyImage(
emotion,
function( gifUrl ) {
component.set( "v.gifUrl", gifUrl );
component.set( "v.detectedEmotion", emotion );
}
);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment