Skip to content

Instantly share code, notes, and snippets.

@newswim
Created September 9, 2015 23:57
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 newswim/1071a4ad35e5e3bb5398 to your computer and use it in GitHub Desktop.
Save newswim/1071a4ad35e5e3bb5398 to your computer and use it in GitHub Desktop.
return controllableSourceTypes.indexOf(this.type) > -1;
}
/*
Current Selected Outputs: ItemSelection.getSelection()
var televisions = Devices.find({_id:{$in:ItemSelection.getSelection()}, type:Drivers.enums.types.Television},{fields:{name:1,rank:1})
var speakers = Devices.find({_id:{$in:ItemSelection.getSelection()}, type:Drivers.enums.types.Speaker},{fields:{name:1,rank:1})
var tvSourceIds = _.intersection(_.pluck(televisions,'sources'))
var speakerSourceIds = _.intersection(_.pluck(speakers,'sources'))
{
'Audio/Video': _.intersection of tvSourceIds & speakerSourceIds
'Video Only': tvSourceIds (sorted by rank) _.difference with (Audio/Video devices above)
'Audio Only': speakerSourceIds (sorted by rank) _.difference with (Audio/Video devices above)
}
*/
/**
* Returns a nested hash of the audio/video sources that are available based
* on the outputs selected.
*
* 1) If only audio devices are selected, this should return something like
* {
* name: 'Audio Only',
* sources: [
* {Device}, --- Devices.find({},{fields:{name:1, rank:1, state:1}}) -- Sort these devices by "rank"
* {Device},
* ...
* ]
* }
*
* 2) If only video devices are selected, this should return something like
* {
* name: 'Video Only',
* sources: [
* {Device}, --- Devices.find({},{fields:{name:1, rank:1, state:1}}) -- Sort these devices by "rank"
* {Device},
* ...
* ]
* }
*
* 3) If both video and audio devices are selected, this should return something like
* {
* name: 'Audio/Video', // Devices that will affect a change on both televisions and speakers
* sources: [
* {Device}, --- Devices.find({},{fields:{name:1, rank:1, state:1}}) -- Sort these devices by "rank"
* {Device},
* ...
* ]
* }
* {
* name: 'Video Only', // Devices that will affect a change only on televisions
* sources: [
* {Device}, --- Devices.find({},{fields:{name:1, rank:1, state:1}}) -- Sort these devices by "rank"
* {Device},
* ...
* ]
* }
* {
* name: 'Audio Only', // Devices that will affect a change only on speakers
* sources: [
* {Device}, --- Devices.find({},{fields:{name:1, rank:1, state:1}}) -- Sort these devices by "rank"
* {Device},
* ...
* ]
* }
*/
,sourceGroups: function() {
var sources, result = [];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment