-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from superhawk610/wip
v2.0 Milestone
- Loading branch information
Showing
29 changed files
with
519 additions
and
185 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = obj => { | ||
let keys = Object.keys(obj) | ||
keys.forEach(k => { | ||
if (!obj[k]) delete obj[k] | ||
}) | ||
return obj | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = (obj, upgradeElementsToArrays) => { | ||
let keys = Object.keys(obj), | ||
arrays = [] | ||
keys.forEach(k => { | ||
let key = /(.+)\[\d+\]$/.exec(k) | ||
if (key && arrays.indexOf(key[1]) == -1) arrays.push(key[1]) | ||
}) | ||
|
||
arrays.forEach(a => { | ||
let _arr = {}, | ||
arr = [], | ||
highestIndex = 0 | ||
keys.forEach(k => { | ||
let index = new RegExp(`${a}\\[(\\d+)\\]`).exec(k) | ||
if (index) { | ||
highestIndex = Math.max(highestIndex, index) | ||
let item = obj[k] | ||
if (upgradeElementsToArrays && !Array.isArray(item)) item = [item] | ||
arr[index[1]] = item | ||
delete obj[k] | ||
} | ||
}) | ||
for (let i = 0; i < highestIndex; i++) { | ||
if (_arr.hasOwnProperty(i)) arr.push(_arr[i]) | ||
else arr.push(upgradeElementsToArrays ? [] : null) | ||
} | ||
obj[a] = arr | ||
}) | ||
return obj | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
'use strict'; | ||
const mongoose = require('mongoose') | ||
const Schema = mongoose.Schema | ||
'use strict' | ||
const mongoose = require('mongoose') | ||
const Schema = mongoose.Schema | ||
|
||
const ChannelSchema = new Schema({ | ||
name: String, | ||
layout: String, | ||
URLs: [String] | ||
URLs: [[String]], | ||
duration: Number | ||
}) | ||
|
||
module.exports = mongoose.model('Channel', ChannelSchema) | ||
module.exports = mongoose.model('Channel', ChannelSchema) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
'use strict'; | ||
'use strict' | ||
const mongoose = require('mongoose') | ||
const Schema = mongoose.Schema | ||
|
||
const ChromecastSchema = new Schema({ | ||
deviceId: String, // hexadecimal identifier provided by Chromecast | ||
// don't confuse this with _id provided by Mongo | ||
location: String, | ||
channel: { type: Schema.Types.ObjectId, ref: 'Channel' }, | ||
rotation: String, | ||
channel: { type: Schema.Types.ObjectId, ref: 'Channel' } | ||
}) | ||
|
||
module.exports = mongoose.model('Chromecast', ChromecastSchema) | ||
module.exports = mongoose.model('Chromecast', ChromecastSchema) |
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
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
Oops, something went wrong.