Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
(15.04.2016, 21:32)Erwin van der Zwart Wrote: Another nice custom Javascript feature: Back to startpage after x seconds when there is no user input:
The startpage will be automaticly linked to the first page of the visu that is loaded.
Paste this code into your custom Javascript and adjust time (SE_Timeout) if needed.
Code: $(function() {
// Back to Start after x seconds (in miliseconds)
var SE_Timeout = 90000; // adjust this timer value if needed (90 seconds in miliseconds)
var SE_Startpage = currentPlanId; // First page that is loaded
var eventlist = 'vclick vmousedown vmouseout touchend';
// Timer function no usage detected
function No_Usage_Detected(callback, timeout, _this) {
var timer;
return function(e) {
var _that = this;
if (timer)
clearTimeout(timer);
timer = setTimeout(function() {
callback.call(_this || _that, e);
}, timeout);
}
}
// Back to start function when timer elapsed
var SE_Goto_Startpage = No_Usage_Detected(function(e) {
if ( currentPlanId != SE_Startpage ) {
showPlan(SE_Startpage);
}
}, SE_Timeout);
// Add event listener to document to detect user input
$(document)
.on(eventlist, function() {
SE_Goto_Startpage();
});
// Add event listener to all iframes to detect user input inside iframes
$('iframe').load(function() {
var iframe = $('iframe').contents().find('html');
iframe.on(eventlist, function(event) {
SE_Goto_Startpage();
});
});
});
BR,
Erwin van der Zwart Hi Erwin,
further to this above. It is possible to log out as well.
What do you suggest?
Thanks.
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
09.03.2018, 07:23
(This post was last modified: 09.03.2018, 07:25 by Erwin van der Zwart.)
Hi,
Yes you could.
Add after line 24 a redirect to /logout (after showPlan)
BR,
Erwin
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
Hi Erwing,
What is exactly the instruction?
Simply what you wrote
Thanks.
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
(09.03.2018, 07:23)Erwin van der Zwart Wrote: Hi,
Yes you could.
Add after line 24 a redirect to /logout (after showPlan)
BR,
Erwin
So instruction is the following?
showPlan (redirect to /logout)
Thanks.
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
17.03.2018, 13:39
(This post was last modified: 17.03.2018, 13:40 by Erwin van der Zwart.)
Hi,
No, that would be to easy (:
Add this after line 24:
Code: $(location).attr("href", "/logout");
So result looks like:
Code: var SE_Goto_Startpage = No_Usage_Detected(function(e) {
if ( currentPlanId != SE_Startpage ) {
showPlan(SE_Startpage);
$(location).attr("href", "/logout");
}
}, SE_Timeout);
BR,
Erwin
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
Thank you Erwin, I'll try.
Posts: 31
Threads: 5
Joined: Oct 2017
Reputation:
0
24.03.2018, 20:29
(This post was last modified: 24.03.2018, 20:48 by Mrinj.)
Hi,
Please excuse the question but I’m newbie who’s been reading and testing and still can not connect the dotts:
How to read/write % value to a virtual object 32/1/1 from a custom created java script (in notepad), saved as html, uploaded as image to Wizer and imported in frame/url in a visualization? Do I need to have a starage.lp for multiple addresses?
Can someone please replay with a short step by step guide or a simple js example?
Best,
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Can you explain what kind of task do you have?
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
25.03.2018, 09:16
(This post was last modified: 25.03.2018, 09:19 by Erwin van der Zwart.)
Hi,
HTML files with embedded JS uploaded to the images folder and added to the visu by using a frame is a very old way to include custom JS to the visu.
Now we have (quite a while already) Custom JS so the old methode above is not needed anymore.
Just like Admin asked, what do you need to do?
BR,
Erwin
Posts: 31
Threads: 5
Joined: Oct 2017
Reputation:
0
I've been reading post (probably old), testing and maybe that's why is confusing for me. Excuse me please!
My plan was to enter a number and save/read the value to an object (in %) from an image (probably with script) that is embedded in visualization, frame and via /scada/resources/icons/image.html. I know this can be done in visualization, object and then by choosing the object address, but the idea is that multiple objects can be saved.
How can this be done with Custom JS?
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
25.03.2018, 09:35
(This post was last modified: 25.03.2018, 09:35 by Erwin van der Zwart.)
Hi,
Why don't you just add a normal value or string object(s) to the visu? Can you explain why you are thinking that you need to do this by using JS?
BR,
Erwin
Posts: 31
Threads: 5
Joined: Oct 2017
Reputation:
0
Probably it will be best and easiest with normal value in visu.
And probably I've been reading & trying to hard to understand the principles of JS and Wiser.
Thanks for your time, advice and help!
Posts: 17
Threads: 3
Joined: May 2017
Reputation:
0
Hello
Is it possible to repeat a command while I hold down a button with the short / long press script?
I need a volume button for a TV in witch the user doesn´t need to press several times to achieve the desired level.
BR,
Jefferson
Posts: 237
Threads: 31
Joined: May 2018
Reputation:
2
(06.08.2018, 20:31)suporte.arqtech Wrote: Hello
Is it possible to repeat a command while I hold down a button with the short / long press script?
I need a volume button for a TV in witch the user doesn´t need to press several times to achieve the desired level.
BR,
Jefferson
Hi,
I want to do it too.
I need to send a byte number continually while i press + or - button.
For example, while I press +, send "30" to group address 1/1/1, and when I press -, sen "31" to 1/1/1
Thanks
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
You don't need custom JS for this. Use binary objects in start/ stop mode and this script for conversion to 1-byte scaled: https://forum.logicmachine.net/showthrea...298#pid298
Posts: 237
Threads: 31
Joined: May 2018
Reputation:
2
(29.04.2019, 17:00)admin Wrote: You don't need custom JS for this. Use binary objects in start/stop mode and this script for conversion to 1-byte scaled: https://forum.logicmachine.net/showthrea...298#pid298
Thanks! It works.
I have another question.
I want to get "send fixed value" data from object when i click on element.
I know that to know the object, the code is el.data("object"), and for status object, el.data("status-object"), but i don't know others.
Is there any documentation about this?
Thanks
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Fixed value is not stored in data attributes. Why do you need this feature?
Posts: 237
Threads: 31
Joined: May 2018
Reputation:
2
(30.04.2019, 11:59)admin Wrote: Fixed value is not stored in data attributes. Why do you need this feature?
For the same example that I explained before.
I have seen that by modifying the example code for dimming lights, I can use it for my case. But I wanted to make a generic code, because the same object is used for many actions. I wanted to put the sending value in "send fixed value" in each object and take it in JS.
The button's to control the volume are in the LM visualisation, and i the solution that you give me, I have to create a JS to simulate the push button (1 on press, 0 on release) too.
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
In visualization parameters you can set the button to work in start-stop mode: send 1 on press and 0 on release.
Posts: 237
Threads: 31
Joined: May 2018
Reputation:
2
(30.04.2019, 14:04)admin Wrote: In visualization parameters you can set the button to work in start-stop mode: send 1 on press and 0 on release.
Ok, thanks!
I didn't know it
|