edit the title of specific block - custom.js

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
marmachine
Posts: 133
Joined: Saturday 26 March 2016 10:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

edit the title of specific block - custom.js

Post by marmachine »

Hi,

I have a block with wind data.
The block however has a title with too much information;

Code: Select all

<div data-id="88" class="mh transbg block_88 col-xs-3 hover" data-toggle="modal" data-target="#opengraph88">
  <div class="col-xs-4 col-icon">
  <em class="wi wi-wind-direction icon" style="-webkit-transform: rotate(410deg);-moz-transform: rotate(410deg);-ms-transform: rotate(410deg);-o-transform: rotate(410deg); transform: rotate(410deg);"></em>
  </div>
  <div class="col-xs-8 col-data"><strong class="title">0.7 m/s, 230° zuid-west</strong></div>
</div>
I wanted to remove a part from the title, so that 0.7 m/s, 230° zuid-west would become this: 0.7 m/s zuid-west
I had some trouble to find the right handles, but i think i already got this working and fixed with some custom js scripting, but is there an easier way to get such things done?

Code: Select all

$("div[data-id=88] div.col-data").each(function() {
            var orgtext = $("div[data-id=88] .col-data .title").text();
            var cuttext = orgtext.replace(/\,.*° /, '');
            $(this).html = $("div[data-id=88] .col-data .title").text(cuttext);
        });
Lokonli
Posts: 2292
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: edit the title of specific block - custom.js

Post by Lokonli »

Maybe you can create a custom blocktype in the function getExtendedBlockTypes in custom.js.

See blocks.js how to define blocktypes.
Lokonli
Posts: 2292
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: edit the title of specific block - custom.js

Post by Lokonli »

Lokonli wrote: Tuesday 13 August 2019 22:55 Maybe you can create a custom blocktype in the function getExtendedBlockTypes in custom.js.

See blocks.js how to define blocktypes.
hmm, I see my suggestion won't work: The title content for a wind device is created hard coded (function getStatusBlock in blocks.js)

Ideas how to make it configurable in Dashticz? What kind of parameter should we add to the block definition?

Your solution also works. An alternative could be to create a text device in Domoticz, and use some scripting to set it to the right text.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests