JavaScript in ViewOn : go to an other view

Hi Team,

I just want to know if it is possible to write script in my ViewOn project that send the user to a view if a Tag changes.

I have a 2 “remote control” views. I can access these views from my welcome interface : I click on a button (clicking is possible only when a Tag (RemoteAccess) is set to 1).

If I am on these views and, at that moment, RemoteAccess changes to 0 (meaning that user is not allowed to control from Viewon anymore), I want to come back to the welcome interface.

Thank’s

Hi Franck,

I think this may be possible to do in ViewON, I’m not sure if it’s something that would need to be done through Javascript or if it’s something that could be done in BASIC.

However, I have something that may be a little bit easier. You can create users with 3 different levels and control what people are allowed to see and interact with.

Hi Tim,

I couldn’t use different user levels in this case because this is not about level, this is about having the autorization from the facility. If the user is using remoteControl pages, and the authorization (remoteAccess) falls to 0, I want to “kick him out”. So I need to tell the application : “you are showing the page remoteAccess to the user, but authorization for remoteControl has fall to 0 so I want you to kick the user out from the remoteControl pages” (if ViewOn could understand).

The process is not supposed to know that someone is using the remoteControl pages. So the remoteAccess authorization can fall to 0 even if someone is using the remoteControl pages.

So, Can I make ViewOn changing the view instantly when a Tag changes ?

Below is a logical script that describe what I would like to achieve :

IF actualView == ( remoteAccessPage1 OR remoteAccessPage2 OR … ) AND remoteAccess == 0 THEN
actualView = homePage
ENDIF

Thank’s

Ok, sorry about that I think I was misunderstanding what you were trying to do before. This is something that you should be able to do using Javascript.

If you would like us to develop the code for this project we can offer this as a paid service as well. We just ask that you create a project summary and send it to us-services@hms.se and a HMS rep will get in contact withyou

Hi Tim,

No problem about that, I’m not the most understandable man in the world.

I have to say that I am a bit lost. Ususally when someone ask for a issue like this, you give us the answer and explain how it works, how to find the documentation in order to even more understand, etc … (without talking about paying)
Could you explain what is different with other subjects I asked before ?

Go back to my issue : Is there any command that allow me to change Viewon view ? (something else than Action => Load URL => Destination : )

Thank’s

Hi @Franck

As of right now we don’t have documentation for this, I’ll need to do some research on this to figure out the process for this project. With the previous subjects they had readily available examples and documentation.

I can see if I can figure this out, but depending on how long it takes to figure out the javascript, we might need to consider this being a custom solution that would fall under a paid service

Hi @Franck

I think I figured this out actually. Apparently there’s a function that lets you grab ewon tag values in Javascript that’s already implemented. I did a little test to start by just changing the background color from white to pink and back when a tag value was read. I also had a tag that would show a live read of the tag “test2” so I knew when it was going to run the function

Try this:

var value = getEwonTagVal(‘Test2’); // Update this to be the tag to monitor

if(value === 10) // If the value hits 10 it will run the function below
{
//$(“body”).css(“background-color”, “#ff52fc”); //Sets the background to Pink
window.location.assign(“http://192.168.50.123/usr/viewon/monitor1%20test.shtm”); // Changes the page you want it to go to
}else{
$(“body”).css(“background-color”, “#ffffff”); // Sets the background back to white if the value is not 10
}

1 Like

Hi Tim,

Just want to say Thank’s.
This is what I asked for and it is simple, so this is perfect.

Thank’s for this you made my day !

Hi Frank,

happy we could help!

Hello I would like to know if to change two page view with a button and a tag change. this tag is a character string.
exemple:
// changer de vue à l’appuis d’un boutton
var textes = getEwonTagVal(‘Type_Machine’); // Update this to be the tag to monitor
var bool=getewonTagval(‘click’);
if(bool===1)
{
if(textes ===‘0’)
{

      window.location.assign("http://10.231.188.58/usr/viewon/Machine_1.shtm");
 }
 if(textes==='1')
 {

 window.location.assign("http://10.231.188.58/usr/viewon/Machine_2.shtm"); 
 }

}