1

I want my "GetContent" script to detect whether the device is "watch" and pass along an instruction to filter out candidate answers from a content.json file whose text field has a length greater than a certain number of characters.

content.json format:

{tags: ["literature"], text: "At once it struck me what quality went to form a man of achievement, especially in literature, and which Shakespeare possessed so enormously -- I mean negative capability, that is, when a man is capable of being in uncertainties, mysteries, doubts, without any irritable reaching after fact and reason. Source: John Keats", image: {url: "images/Shakespeare.jpg"}},

So the logic would be

if (watch) content = short_quotes_only
Fred Zimmerman
  • 1,178
  • 3
  • 13
  • 29

2 Answers2

1

I would recommend exploring the device property of $vivContext (Documentation)

The device property will allow you to see which type of device a user is using (bixby-mobile, bixby-tv, etc.) and provide the data you wish to show for the device being used.

Ameya
  • 880
  • 6
  • 13
0

This combination of snippets worked for me:

  device = $vivContext.device
  console.log('device', device)

  if (device == 'bixby-watch' ) { maxlength = 100
  console.log('maxlength is now', maxlength)
  }

then later in the script

//filters entitled content by length of text field in characters

content = content.filter(function(i) { return i.text.length < maxlength;
Fred Zimmerman
  • 1,178
  • 3
  • 13
  • 29