Created
September 9, 2015 23:57
-
-
Save newswim/1071a4ad35e5e3bb5398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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