2014-11-19 08:45:56 -04:00
|
|
|
_ = require('lodash')
|
2014-11-26 13:12:39 -04:00
|
|
|
|
|
|
|
# TODO: This should be fetch from the server
|
2014-11-24 08:54:35 -04:00
|
|
|
DEVICES = require('./device-data.json')
|
2014-11-19 08:45:56 -04:00
|
|
|
|
|
|
|
exports.getDisplayName = (device) ->
|
2014-11-24 09:09:39 -04:00
|
|
|
if _.indexOf(exports.getSupportedDevices(), device) isnt -1
|
|
|
|
return device
|
|
|
|
|
2014-11-24 08:54:35 -04:00
|
|
|
for key, value of DEVICES
|
|
|
|
if _.indexOf(value.names, device) isnt -1
|
2014-11-19 08:45:56 -04:00
|
|
|
return key
|
2014-11-19 08:50:11 -04:00
|
|
|
return 'Unknown'
|
2014-11-24 08:25:45 -04:00
|
|
|
|
2014-11-24 09:03:02 -04:00
|
|
|
exports.getDeviceSlug = (device) ->
|
|
|
|
displayName = exports.getDisplayName(device)
|
|
|
|
return DEVICES[displayName]?.slug or 'unknown'
|
|
|
|
|
2014-11-24 08:25:45 -04:00
|
|
|
exports.getSupportedDevices = ->
|
2014-11-24 09:03:02 -04:00
|
|
|
return _.keys(DEVICES)
|