16.12.2016, 13:49 (This post was last modified: 16.12.2016, 13:55 by Roman.)
Добрый день.
Появилась задача. При присвоении объекту определенного значения нужно открыть план. Не могли бы вы мне с этим помочь? Как я понимаю слушатель должен быть привязан к объекту допустим 1/1/1 и
если объект изменил значение на 1, то showPlan(11);
если 2, то showPlan(12);
если 3, то showPlan(13);
Это как я понимаю решается через "case", я не знаю JS.
Кроме того мне это нужно не для vis, а для touch
Is there any way to hide a object from visu when there´s no value? I´m monitoring a 4 byte float kW object, but there´s no point in having it show in visu when it´s 0.00 kW.
24.12.2016, 07:57 (This post was last modified: 24.12.2016, 07:58 by buuuudzik.)
(24.12.2016, 00:08)FatMax Wrote: Is there any way to hide a object from visu when there´s no value? I´m monitoring a 4 byte float kW object, but there´s no point in having it show in visu when it´s 0.00 kW.
This script should work. You must add to this object in visualisation editor text "power" in Additional classes and change the value for nothing(now is '0 kWh', can be empty '''). You can also change the color of this text e.g. black when 0 and yellow when more than 0.
Code:
//Change text to nothing when 0,00 kWh
$(function(){
function power_update(){
// Set values
var nothing = '0 kWh' // value for nothing
power = parseFloat( $('.power').html() )
if ( power == 0 || power == nothing ){
$('.power').html(nothing);
}
}
// Check for changes on value of item with power
$(".power").bind("DOMSubtreeModified",function(){
power_update();
});
Hi everyone!
I will say Roman's quastion with another words:
is there way to make widget autoclosing function. He need 1 widget which can close itself after some time
Thanks Pawel, yes now I see that this is a solution but maybe do you know if there is some other way without creating a .lp file e.g. using lua in javascript? or exchanging some variables to this .lp?
And also can you describe the mechanism of .lp files? Because this is for me now a little abstraction. Are these scripts run residentlyin the background or only when there is some request from js or apps?
A .lp file is used for client side LUA scripting, the .lp file is executed once during page load, at that moment the LUA is executed and data is requested from server and the reply is transfered to client and you can use the reply as JSON object.
When you want new data you have to do a http (xhtml / ajax) request to the .lp file (even with arguments) to get new or other information from the server. This way you can do a normal storage.get / storage.set LUA command (basicly any LUA command available inside the LM) and transfer the reply to a JSON object to use on client side.
The content inside the .lp file is very flexible and when you master this you can build whatever you need.
So there is nothing running on de background, only on page load and when you do a xhtml / ajax request to the .lp file.
I see that this is a very nice tool. I've prepared what I wanted, script which read trends and calculate the cost of outdoor heating for defined periods and this is exported as a JSON.
I see this is a very elastic tool but is there a possibility to send an ajax request with some variables.
E.g. in .lp file there is an universal function for cost calculation and in javascript there is a possibility to select for what number of days.
19.01.2017, 21:40 (This post was last modified: 19.01.2017, 21:50 by Erwin van der Zwart.)
Hi Buuuudzik,
Yes you can send vars by the request by using xxx.xxx.xxx.xxx/yourfile.lp?argument1=yourfirstvalue&argument2=yoursecondvalue etcetera and than fetch them in your .lp file with:
19.01.2017, 21:58 (This post was last modified: 19.01.2017, 22:13 by buuuudzik.)
I didn't know about this so YES definitely this is an amazing tool! And of course thank you Erwin, you're traditionally a few(or much more) levels before me I only try to learn new things for having a good products for my clients Thanks
So this is right way for run the .lp file with some arguments from outside?
Code:
$.get( "/user/systemtime.lp?argument1=yourfirstvalue&argument2=yoursecondvalue", function( data ) {
when I write custom javascripts and when I use jQuery to find objects everytime I has in the console a lot of founded objects and I think this is not caused by too wide filter but this is something else. It looks like the objects from scada-vis are also in trends and schedulers.
For examle this 2 scripts for find a object with class '.sekator' generates the same result in console.log() (see screenshot).
Script 1:
Code:
$(function(){
var sekator = $('#plan-1').find('.sekator')
console.log(sekator)
});
Script 2:
Code:
$(function(){
var sekator = $('.sekator')
console.log(sekator)
});
Is this result from console.log() is normal or can I something improve?
Custom JS runs both visualizations, trends and schedulers. If you have some specific functions for visualization only, you can check the type like this:
Code:
$(function() {
if (!$('body').hasClass('usermode')) {
return;
}
// do something only in user visualization, not touch, trends, schedulers
});
21.01.2017, 07:45 (This post was last modified: 21.01.2017, 07:56 by buuuudzik.)
Thanks admin for advice
I've checked this on the other LM which I've cleaned to only 1 visupage and 1 trend and 2 schedulers and I see that javascripts are working then perfectly.
No such situation with searching something in other places. And also e.g this function is run only 1 time and I have in consol.log() only 1 result(but on my LM LB there is a lot of):
Code:
$(function(){
var image12 = $(".image12");
console.log(image12)
});
I've tried delete whole scripts from custom javascript from LM LB and start again but unfortunately this is not a solution.
But your advice is the solution. It looks that loading is little shorter. Perfectly. Thanks
Maybe somebody knows how can I edit the svg which is the background of a plan? I tried but I can't reach what is inside this svg, only source. It looks like this kind of images has some security or aren't editable.
SVG backgrounds are placed using <img> tag so you cannot access the SVG document via JS. You can create a layout and place your SVG as an image instead of background.