Skip to content

Commit cc55c78

Browse files
daniep01actions-user
authored andcommitted
Prettified Code!
1 parent 4e506d6 commit cc55c78

1 file changed

Lines changed: 34 additions & 29 deletions

File tree

index.js

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ instance.prototype.init = function () {
3030
self.nodes = []
3131
self.currentChannel = ''
3232
self.accessToken = ''
33-
33+
3434
self.setupVariables()
3535
self.getAccessToken()
3636
self.getNodes()
@@ -72,7 +72,8 @@ instance.prototype.config_fields = function () {
7272
id: 'info',
7373
width: 12,
7474
label: 'Information',
75-
value: 'This module is for the Adder XDIP Receiver. Add a new module connection for each receiver in your system. The Receiver Access Password is required to change channels.',
75+
value:
76+
'This module is for the Adder XDIP Receiver. Add a new module connection for each receiver in your system. The Receiver Access Password is required to change channels.',
7677
},
7778
{
7879
type: 'textinput',
@@ -150,7 +151,7 @@ instance.prototype.action = function (action) {
150151
self.switchChannel(cmd)
151152
self.getCurrentChannel()
152153
} else {
153-
self.log('warn','Unable to find channel number for ' + opt.channelUuid)
154+
self.log('warn', 'Unable to find channel number for ' + opt.channelUuid)
154155
}
155156
break
156157
}
@@ -189,7 +190,7 @@ instance.prototype.switchChannel = function (cmd) {
189190

190191
if (self.accessToken == '') {
191192
console.log('missing access token')
192-
self.log('warn','Unable to switch channel, missing access token')
193+
self.log('warn', 'Unable to switch channel, missing access token')
193194
return
194195
}
195196

@@ -213,13 +214,14 @@ instance.prototype.switchChannel = function (cmd) {
213214
self.status(self.STATUS_OK)
214215
} else {
215216
console.log('error ' + result.response.statusCode)
216-
self.log('warn','Unable to switch to channel')
217+
self.log('warn', 'Unable to switch to channel')
217218
}
218219
},
219220
header,
220-
{ connection: {
221-
rejectUnauthorized: false,
222-
}
221+
{
222+
connection: {
223+
rejectUnauthorized: false,
224+
},
223225
}
224226
)
225227
}
@@ -262,9 +264,10 @@ instance.prototype.getChannels = function () {
262264
}
263265
},
264266
header,
265-
{ connection: {
266-
rejectUnauthorized: false,
267-
}
267+
{
268+
connection: {
269+
rejectUnauthorized: false,
270+
},
268271
}
269272
)
270273
}
@@ -278,7 +281,7 @@ instance.prototype.getNodes = function () {
278281
var header = []
279282
header['Content-Type'] = 'application/json'
280283
console.log(cmd)
281-
284+
282285
self.system.emit(
283286
'rest_get',
284287
cmd,
@@ -297,7 +300,7 @@ instance.prototype.getNodes = function () {
297300
if (name.length == 0) {
298301
name = 'Name not set! ' + i
299302
}
300-
description = result.data[i].description.trim()
303+
description = result.data[i].description.trim()
301304
// console.log(uuid)
302305
//if (uuid != 'self') {
303306
self.nodes.splice(i, 0, {
@@ -316,9 +319,10 @@ instance.prototype.getNodes = function () {
316319
}
317320
},
318321
header,
319-
{ connection: {
320-
rejectUnauthorized: false,
321-
}
322+
{
323+
connection: {
324+
rejectUnauthorized: false,
325+
},
322326
}
323327
)
324328
}
@@ -363,17 +367,18 @@ instance.prototype.getCurrentChannel = function () {
363367
}
364368
},
365369
header,
366-
{ connection: {
367-
rejectUnauthorized: false,
368-
}
370+
{
371+
connection: {
372+
rejectUnauthorized: false,
373+
},
369374
}
370375
)
371376
}
372377

373378
instance.prototype.getAccessToken = function (cmd) {
374379
var self = this
375380
var header = []
376-
header['Content-Type'] = 'application/json'
381+
header['Content-Type'] = 'application/json'
377382

378383
try {
379384
authData = JSON.parse('{"accessPassword":"' + self.config.password.toString() + '"}')
@@ -387,7 +392,7 @@ instance.prototype.getAccessToken = function (cmd) {
387392
console.log(cmd)
388393

389394
self.system.emit(
390-
'rest',
395+
'rest',
391396
cmd,
392397
authData,
393398
function (err, result) {
@@ -402,7 +407,7 @@ instance.prototype.getAccessToken = function (cmd) {
402407
self.accessToken = result.data.accessToken.toString()
403408
console.log(self.accessToken)
404409
self.setVariable('tokenStatus', 'Valid')
405-
self.log('debug','Access Token received')
410+
self.log('debug', 'Access Token received')
406411
}
407412
}
408413
} else {
@@ -413,9 +418,10 @@ instance.prototype.getAccessToken = function (cmd) {
413418
}
414419
},
415420
header,
416-
{ connection: {
417-
rejectUnauthorized: false,
418-
}
421+
{
422+
connection: {
423+
rejectUnauthorized: false,
424+
},
419425
}
420426
)
421427
}
@@ -425,7 +431,7 @@ instance.prototype.lookupChannel = function (lookupUuid) {
425431
console.log('Lookup channel for: ' + lookupUuid)
426432

427433
try {
428-
let obj = self.channels.find(o => o.uuid == lookupUuid)
434+
let obj = self.channels.find((o) => o.uuid == lookupUuid)
429435
console.log(lookupUuid + ' is channel ' + obj.channel)
430436
return obj.channel
431437
} catch (e) {
@@ -445,7 +451,7 @@ instance.prototype.lookupName = function (lookupCh) {
445451
}
446452

447453
try {
448-
let obj = self.channels.find(o => o.channel == lookupCh)
454+
let obj = self.channels.find((o) => o.channel == lookupCh)
449455
uuid = obj.uuid
450456
console.log('Lookup uuid for channel: ' + lookupCh + ' = ' + uuid)
451457
} catch (e) {
@@ -454,7 +460,7 @@ instance.prototype.lookupName = function (lookupCh) {
454460
}
455461

456462
try {
457-
let obj = self.nodes.find(p => p.id == uuid)
463+
let obj = self.nodes.find((p) => p.id == uuid)
458464
name = obj.label
459465
console.log('Lookup name for channel: ' + lookupCh + ' = ' + name)
460466
} catch (e) {
@@ -467,4 +473,3 @@ instance.prototype.lookupName = function (lookupCh) {
467473

468474
instance_skel.extendedBy(instance)
469475
exports = module.exports = instance
470-

0 commit comments

Comments
 (0)