Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send-User-Variables-To-HTML #4

Open
leoguem opened this issue Mar 5, 2017 · 7 comments
Open

Send-User-Variables-To-HTML #4

leoguem opened this issue Mar 5, 2017 · 7 comments

Comments

@leoguem
Copy link

leoguem commented Mar 5, 2017

I am experimenting with the plugin. Trying to use variables that are filled by serial Input (later I would like to use the UDP input) and afterwards sending them to HTML using the plugin. I have not made any changes in the code, all I have done is:

  1. recreate the BrightAuthor project for a XD1030 (using all the same files, variable names as in the original project)
  2. make the user variables filled by serial input using a hms interface and a simple button by creating another zone with an serial event (as described here: http://docs.brightsign.biz/plugins/servlet/mobile#content/view/983313)
  3. creating another zone with a live-text element to check if the serial-value-to-use-variable thing works

Now, the user variable is made out of the serial input (i can see that working in the live text zone), but the user variable is not displayed in the HTML page? What am I doing wrong (BrightAuthor file attached)
serial2html.zip

@leoguem
Copy link
Author

leoguem commented Mar 6, 2017

Why do I need the plugin at all? I saw that I can basically do the same thing with JavaScript that reads the user values. I just need one single user variable that can be changed via serial or UDP to end up as a JavaScript variable. Unfortunately I can't get it done, already in contact with BS support. But I think it would a great thing to have some basic JS (just like the "take-user-variable-and-turn-it-into-a-JS-variable"-thing to have here on github. Would be a great starting point for BS projects.

@jsinai
Copy link

jsinai commented Mar 6, 2017

If all you need is the ability to save and read variables from Javascript, I would recommend using html5 local storage (see e.g. https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).

To enable it, turn on HTML Local Storage (see http://docs.brightsign.biz/display/DOC/Editing+Preferences#EditingPreferences-Storagestorage).

You could then set your variables based on UDP or serial messages in Javascript using http://docs.brightsign.biz/display/DOC/BSDatagramSocket or http://docs.brightsign.biz/display/DOC/BSSerialPort.

@leoguem
Copy link
Author

leoguem commented Mar 6, 2017

I just need to read the current brightsign user variable and put its value in a js variable, tried modifying the weather widget demo, bit cantget it to work.

<title>vizit</title> <script src="js/jquery-1.10.1.min.js"></script> <script src="js/bsp.js"></script> <script> //NOTE: this variable stores the value from the uservariables on the BrightSign unit var newposition //NOTE: this function gets the user variable from the BrightSign unit function getUserVars(callback) { console.log("getUserVars"); sUrl="http://localhost:8080/GetUserVars"; $.get(sUrl,function(data,status,jqXHR) { un=jqXHR.responseText; xmlDoc = $.parseXML( un ); $xml = $( xmlDoc ); console.log(un); console.log("fetching variables...") $xml.find('BrightSignVar').each(function(){ var name = $(this).attr('name') console.log(name); }); }); } //NOTE: this fetches the user variable with the name position switch (name){ case "position": var newposition = $(this).text(); break; $('#thenewposition').html(newposition); </script> <style> #thepage{ width:1920px; height:1080px; background-color: red; } </style>

@jpbrightsign
Copy link

you can use a Javascript get with the user variables URL on the player. The URL of the database is
http://player-ip-address:8008/GetUserVars. Once you have this URL response you can parse it as you would any XML feed.

@atoudam
Copy link

atoudam commented Oct 11, 2017

@jpbrightsign i dont think that will work, the allow cross origin flag is not set on the application server/ variables server so a get request gets denied. in theory you could do a custom variables page and set the flag however that seams more effort then simply using the plugin/ adapting the plugin further to allow the HTML widget to request variables and have the plugin reply, which im currently working on

@jpbrightsign
Copy link

I'm not sure, I may be misunderstanding. The question was:

"I just need to read the current brightsign user variable and put its value in a js variable, tried modifying the weather widget demo, bit can not get it to work."

If the user var was created with BrightAuthor and then published you can certainly get the values into JS localstorage

  1. $get or $http the uservars at http://player-ip-address:8008/GetUserVars.

  2. Push the values into HTML local storage (set.localstorage)

You don't need a pluigin for this it's quite straight forward.

I can email you a simple sample if you wish.

@atoudam
Copy link

atoudam commented Oct 11, 2017

you are understanding it correctly

i was getting a "Cross-Origin Request Blocked" error when i tested this however i have now found the source of this issue and agree that you are correct the method you outline above does work.

the only small down site is that the HTML site has to poll the uservars at http://player-ip-address:8008/GetUserVars. for changes rather then get an alert on change, not major issue though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants