Different way of coding

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Different way of coding

Post by poudenes »

Hi All,

Maybe its to much and not possible but maybe the way of coding can be different:

Now we have this

Code: Select all

blocks[43] = {} // RPI USB USAGE
blocks[43]['width'] = 3;
blocks[43]['title'] = 'RPi CPU';
blocks[43]['image'] = 'pi3.png';
blocks[43]['switch'] = true;
But if we can code something like this

// RPI USB USAGE

Code: Select all

blocks[43] = {} : ['width'] = 3 : ['title'] = 'RPi CPU' : ['image'] = 'pi3.png' : ['switch'] = true;
So the : i use as example to split the options for that blocks. and the ; is to end the whole line so coding will goto new blocks then

or

Code: Select all

blocks[43] = {
     ['width'] = 3;
     ['title'] = 'RPi CPU';
     ['image'] = 'pi3.png';
     ['switch'] = true
     };
This will make the config shorter and much easier to handle when you use lot of blocks.
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
MiloshCZ
Posts: 19
Joined: Monday 23 January 2017 17:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Different way of coding

Post by MiloshCZ »

I agree. Becaouse if you need change IDX, you need change it at many places.
aiolos
Posts: 127
Joined: Sunday 13 September 2015 18:58
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Nieuwegein, NL
Contact:

Re: Different way of coding

Post by aiolos »

You can define the config like this:

Code: Select all

blocks[43] = {
     width: 3,
     title: 'RPi CPU',
     image: 'pi3.png',
     switch: true
};
More information about different types of notation can be found here: https://developer.mozilla.org/en-US/doc ... th_Objects
It's basically the different ways javascript accepts object notation, or associative arrays.

These other notation can sometimes easier introduce errors in your config if you don't have a good editor that highlights the code (for example the ',' on the end of a line, instead of a ';')
Contributor to Dashticz
More on my Github profile
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Different way of coding

Post by poudenes »

Ok cool. So this will work on the config of Dashticz as well?
aiolos wrote: Wednesday 14 March 2018 21:33 You can define the config like this:

Code: Select all

blocks[43] = {
     width: 3,
     title: 'RPi CPU',
     image: 'pi3.png',
     switch: true
};
More information about different types of notation can be found here: https://developer.mozilla.org/en-US/doc ... th_Objects
It's basically the different ways javascript accepts object notation, or associative arrays.

These other notation can sometimes easier introduce errors in your config if you don't have a good editor that highlights the code (for example the ',' on the end of a line, instead of a ';')
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
DewGew
Posts: 581
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: Different way of coding

Post by DewGew »

poudenes wrote: Thursday 15 March 2018 10:23 Ok cool. So this will work on the config of Dashticz as well?
aiolos wrote: Wednesday 14 March 2018 21:33 You can define the config like this:

Code: Select all

blocks[43] = {
     width: 3,
     title: 'RPi CPU',
     image: 'pi3.png',
     switch: true
};
More information about different types of notation can be found here: https://developer.mozilla.org/en-US/doc ... th_Objects
It's basically the different ways javascript accepts object notation, or associative arrays.

These other notation can sometimes easier introduce errors in your config if you don't have a good editor that highlights the code (for example the ',' on the end of a line, instead of a ';')
Yes ,It does..
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest