Facility Control

 View Only
  • 1.  Use absolute path for canvas background?

    Posted 03-08-2022 18:46

    Hi there!

    Just ran into this one today, and didnt expect this one to be a problem.
    I use the following code to just set a simple background to a canvas element in DashBoard.

    Relative path:

    var img = 'image/test.png';
    ogscript.debug('Image path is: ' + img);
    ogscript.setStyle('testCanvas', 'bg-u:'+ img);

    So, that works, no problem at all, the folder that has the DashBoard also has a folder called "images" and in there is the "test.png" picture. So use of relative path is fine.

    Online URL Path:

    var img = 'https://higherlogicdownload.s3.amazonaws.com/ROSSVIDEO/eac0a45b-23a6-41ec-9a70-9a5a76a1caed/UploadedImages/Ross-Logo-Living-Live.png';
    ogscript.debug('Image path is: ' + img);
    ogscript.setStyle('testCanvas', 'bg-u:'+ img);

    Just for fun I wanted to try an online URL (as I have done this in an older version of DashBoard), and just grabbed the URL of hte ROSS logo at the top of this page (at time of writing), and the example above with a URL works just fine.

    Absolute path:

    But then I want to set the background from a filepicker with an absolute path set, and use that URL to set the background, and, well.. it fails. I created a test folder directly in C: just to to a simple path, and grab the URL from the folder from Windows File Explorer, and append the filename to it. In this case it was: C:/test/test.png

    var img = 'C:/test/test.png';
    ogscript.debug('Image path is: ' + img);
    ogscript.setStyle('testCanvas', 'bg-u:'+ img);

    Alas this does not work either... Am I missing something that would make this work?

    ------------------------------
    Aleksander Stalsberg
    Lillehammer Icehockey Club
    ------------------------------


  • 2.  RE: Use absolute path for canvas background?

    Posted 03-10-2022 08:52

    SOLVED...

    Annoyingly enough I found it...
    Turns out, the filepicker when set with the argument w.absolute:true adds a "file:/" to the front of the filepath...
    However this is not reflected in the actual filepicker field, only when you try to grab the URL by ogscript.getValue.
    This was removed in my DashBoard due to using this filepath to send to Xpression, and Xpression doesnt like the "file:/" in front of an image filepath through DataLinq...

    However, if you want to se the background of a canvas in DashBoard with an absolute path, that little prefix is needed (I assume to tell DashBoard we're not talking absolute path, and not relative). So the following code will work...

    var img = 'file:/C:/test/test.png';
    ogscript.debug('Image path is: ' + img);
    ogscript.setStyle('testCanvas', 'bg-u:'+ img);


    ------------------------------
    Aleksander Stalsberg
    Lillehammer Icehockey Club
    ------------------------------