Dashticz, alternative dashboard based on HTML, CSS, jQuery
Moderators: leecollings, htilburgs, robgeerts
-
HansieNL
- Posts: 969
- Joined: Monday 28 September 2015 15:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
-
Contact:
Post
by HansieNL »
I got a text block with Buienradar info.
Code: Select all
blocks[345] = {} //Buienradar (text)
blocks[345]['title'] = 'Buienradar';
blocks[345]['switch'] = true;
blocks[345]['width'] = 12;
blocks[345]['image'] = '../custom/img/rain-off.png';
Code: Select all
function afterGetDevices(){
// Buienradar
if (alldevices[345].Data == 'Voorlopig droog') {
$('.block_345 .col-icon').addClass('off-ico');
$('.block_345 .col-data').addClass('off-stat');
}
else {
$('.block_345 .col-icon').removeClass('off-ico');
$('.block_345 .col-data').removeClass('off-stat');
}

I wanna also change the image icon if the text is not "Voorlopig droog". Can someone tell me how to get this done?
Thanks in advance.
Blah blah blah
-
Lokonli
- Posts: 2292
- Joined: Monday 29 August 2016 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
-
Contact:
Post
by Lokonli »
HansieNL wrote: Saturday 22 June 2019 11:17
I got a text block with Buienradar info.
Code: Select all
blocks[345] = {} //Buienradar (text)
blocks[345]['title'] = 'Buienradar';
blocks[345]['switch'] = true;
blocks[345]['width'] = 12;
blocks[345]['image'] = '../custom/img/rain-off.png';
Code: Select all
function afterGetDevices(){
// Buienradar
if (alldevices[345].Data == 'Voorlopig droog') {
$('.block_345 .col-icon').addClass('off-ico');
$('.block_345 .col-data').addClass('off-stat');
}
else {
$('.block_345 .col-icon').removeClass('off-ico');
$('.block_345 .col-data').removeClass('off-stat');
}

I wanna also change the image icon if the text is not "Voorlopig droog". Can someone tell me how to get this done?
Thanks in advance.
Try the following:
You can change the image by adding the following function to custom.js:
(it works for a normal switch. I did not test with a text block)
Code: Select all
function getStatus_345(idx,value,device){
if (device.Data == 'Voorlopig droog') {
blocks[345]['image'] = 'blinds_open.png'
}
else {
blocks[345]['image'] = 'blinds_closed.png'
}
}
-
HansieNL
- Posts: 969
- Joined: Monday 28 September 2015 15:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
-
Contact:
Post
by HansieNL »
Thanks a lot. Thanks again.
Blah blah blah
Users browsing this forum: No registered users and 1 guest