Page 1 of 1
Different way of coding
Posted: Tuesday 06 March 2018 11:32
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.
Re: Different way of coding
Posted: Thursday 08 March 2018 14:09
by MiloshCZ
I agree. Becaouse if you need change IDX, you need change it at many places.
Re: Different way of coding
Posted: Wednesday 14 March 2018 21:33
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 ';')
Re: Different way of coding
Posted: Thursday 15 March 2018 10:23
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 ';')
Re: Different way of coding
Posted: Thursday 15 March 2018 11:31
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..