0

Writing an array to local file on XT1143

I am using BrightAuthor to publish an HTML site to a BrightSign XT1143 unit.  In the HTML site, I am referencing data stored as a JSON array in an external .js file I am referencing in the HTML site.  I need to be able to append (i.e. write new data) the array with data from the visitor's input and write that data back to the external .js file.  Does anyone have any advice on how to accomplish this?

3 comments

  • 0
    Avatar
    Adam

    two ways

    1

    stringify the json, send it in a postJs message back to a receiving function running in Brightscript

    then in Brightscript write the file back to disk

     

    2

    use node.js to write the file back to disk

     

    now the issues, because you are publishing via BA if the Json is included in the publish to begin with then it goes into the pool and using node.js or BS to find that original file and edit it is going to be a pain, you can do it but it involves interacting with the pool members within the autorun which is basically undocumented and takes a bit of probing and trial and error to figure out, and the BA autorun changes all the time without warning to your project will possibly break next time you publish.

    i would forget trying to write back to the original file and instead make a "localSettings.json" and save my user changes to that. give your "originalSettings.json" a version number / timestamp so when you do a new publish you can tell your site if it should wipe out the local settings and copy over the original Settings or if it should continue with the local version.

    node.js is probably the easier option if you know node.js and not Brightscript, personally i would go for Brightscript as node is new in brightsign and i use new things slowly and with caution

  • 0
    Avatar
    BRIEN BARR

    Can anybody offer me a starting point on this?  I am proficient in HTML and Javascript, but I am lost when it comes to BrightScript and node.js.  I have not dealt with either of those, with the exception of changing some variable names and paths in a custom plugin written in BrightScript.  I don't even know where to begin.

  • 0
    Avatar
    Adam

    i can give you a hand with this

    send me and email and we can go from there

    i have a couple templates setup for making plugins and can give you a hand with writing it.

    <my first name > at Toulouse dot co dot nz

Please sign in to leave a comment.