Posts: 136
Threads: 20
Joined: Jul 2015
Reputation:
0
Hi,
How to change the "visdimopacity and visdim" value dynamically
Code: var Globals = {
config: {.......,"visdimopacity":"80", visdim":"3",.......... },
updateTime: '1502280884.48142',
};
Thanks
Jean-Marc.
Jean-Marc
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
Code: require('uci')
uci.set('genohm-scada', 'core', 'visdimopacity', 80)
uci.set('genohm-scada', 'core', 'visdim', 3)
uci.commit('genohm-scada')
Posts: 136
Threads: 20
Joined: Jul 2015
Reputation:
0
10.08.2017, 11:24
Hi Admin,
Admin, thank you, it's perfect.
Jean-Marc.
Jean-Marc
Posts: 133
Threads: 28
Joined: May 2016
Reputation:
3
A stupid question. What do the parameters "visdimopacity and visdim"?
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
Visualization settings: "Dim inactive visualization after" is visdim, "Dimming level" is visdimopacity
Posts: 21
Threads: 3
Joined: Aug 2019
Reputation:
0
(10.08.2017, 05:56)admin Wrote: Code: require('uci')
uci.set('genohm-scada', 'core', 'visdimopacity', 80)
uci.set('genohm-scada', 'core', 'visdim', 3)
uci.commit('genohm-scada')
Hi Admin,
I understand what this it is supposed to do, and I want to allow the user to turn screen dimming on or off themselves. However, can you please explain how this is used in a working code example? This looks a bit like a fragment to me and I can't figure out what to do with it. I tried a few things with no joy.
Thanks!
Posts: 4646
Threads: 24
Joined: Aug 2017
Reputation:
207
It is full script, Set 'visdim', 0 to turn it off
------------------------------
Ctrl+F5
Posts: 21
Threads: 3
Joined: Aug 2019
Reputation:
0
(15.06.2020, 11:59)Daniel. Wrote: It is full script, Set 'visdim', 0 to turn it off Thank you for your reply. It seems to me that the browser needs to be refreshed for this to take effect. Is that right? Can we make it immediate (not requiring a refresh)?
I have the following code:
Code: -- Set screen dimming on/off
require('uci')
if (event.getvalue() == true) then
log('Auto dimming on')
uci.set('genohm-scada', 'core', 'visdimopacity', 80)
uci.set('genohm-scada', 'core', 'visdim', 1)
else
log('Auto dimming off')
uci.set('genohm-scada', 'core', 'visdimopacity', 80)
uci.set('genohm-scada', 'core', 'visdim', 0)
end
uci.commit('genohm-scada')
I trigger this script with a toggle button on a Visualisation screen. While it works, it does need a refresh, so my question above remains. Can we make it take effect immediately?
Thanks!
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
16.06.2020, 06:32
(This post was last modified: 16.06.2020, 06:35 by Erwin van der Zwart.)
Hi,
The changes are made server side and the client (browser) has no clue that that was done, so you always need to refresh..
Here is a custom JS to refresh to browser from server side (needs to be loaded so 1 refresh is needed after adding the JS)
Code: $(function(){
if (typeof grp != 'undefined') {
grp.listen('1/1/1', function(object, state) {
if (state == 'value') {
location.reload();
}
}, true);
}
});
Change 1/1/1 to the same address that triggers the uci update
BR,
Erwin
Posts: 21
Threads: 3
Joined: Aug 2019
Reputation:
0
Hi Erwin,
Thanks you for your quick response and explanation. I implemented this (changing the 1/1/1 to my script triggering address) and it all works as expected, with the observation that the page refreshes either 2 or 3 times, rather than just once. I can live with that, although it is curious.
Thanks!
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
16.06.2020, 13:09
(This post was last modified: 16.06.2020, 13:10 by Erwin van der Zwart.)
Hi,
Try removing “, true” on line 7
BR,
Erwin
Posts: 21
Threads: 3
Joined: Aug 2019
Reputation:
0
|