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