Solved AutoTools Web Screen Update img src

Discussion in 'AutoTools' started by nmcj, Nov 14, 2017.

  1. nmcj

    nmcj Member

    Joined:
    Mar 24, 2016
    Messages:
    31
    Likes Received:
    2
    Having trouble getting an autotools update values command change the img src. The issue I am having is simply that the image does not show. When I test it in my anWrite app, it looks fine. But when I run the AutoTools Webscreen, all I get is emptiness.
    No fun!!
    Below is a snippet:
    Code (Text):
    AutoTools.setDefaultValues({
            "valueToUpdate": "flipped1.jpg"
        });

        var updateValue = function(value){
        document.querySelector("#myImg").src = value;
            AutoTools.showToast(valueToUpdate);
         //document.getElementById('myImg').src = value;
         //document.getElementById('myImg').src = valueToUpdate;
        }
       
        var autoToolsUpdateValues = function(values){
            updateValue(values.valueToUpdate);
        }
        updateValue(valueToUpdate);
     
    The full page can be found here:https://github.com/nmcjohnson/HudAnywhere/edit/master/AT-Update-2.html
     
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    5,133
    Likes Received:
    466
    Probably because you're using just the file name for the image :) Try using the full path.
     
  3. nmcj

    nmcj Member

    Joined:
    Mar 24, 2016
    Messages:
    31
    Likes Received:
    2
    OK. I'll give it a try
     
  4. nmcj

    nmcj Member

    Joined:
    Mar 24, 2016
    Messages:
    31
    Likes Received:
    2
    Well, I tried that, with no luck. The image file and the html are in the same folder, so i think that's not the issue.
    Below is the full code? Do I have something in the wrong spot?
    Code (Text):
    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <script src="autotoolsfunctions.js"></script>
        <link rel="stylesheet" type="text/css" href="autotoolsstyle.css" />
        <meta name="autotoolswebscreen" type="variablejs" id="valueToUpdate" label="Value To Update" description="Value used to update the page" defaultValue="flipped1.jpg" hint="flipped image" />
        <meta name="autotoolswebscreen" type="variablejs" id="reload" label="Reload" description="spot in HUD load process" defaultValue="fin" hint="fin,non" />
    </head>
    <body>
    <script type="text/javascript">
     
    function loadImage() {
            var reload = "fin"
              AutoTools.sendCommand(reload,'hud', true);
              AutoTools.showToast(reload)
     
            }
    </script>
    <script type="text/javascript">
        //Sets default value in case user doesn't set it
        //AutoTools.setDefaultValues({
            //"valueToUpdate": "flipped1.jpg"
        //});
        var updateValue = function(value){
        //document.querySelector("#myImg").src = value;
            AutoTools.showToast(valueToUpdate)
              document.getElementById('myImg').src = value;
        //document.getElementById('myImg').src = valueToUpdate;
              //document.querySelector("#updatable").innerHTML = value;
        }

     
        var autoToolsUpdateValues = function(values){
            updateValue(values.valueToUpdate);
        }
        updateValue(valueToUpdate);
    </script>
     
    <img id="myImg" img="" onload="loadImage()" src = "flipped1.jpg" />
        </body>
        </html>
     
  5. szmerek

    szmerek Member

    Joined:
    Jul 4, 2016
    Messages:
    101
    Likes Received:
    16
    As @joaomgcd advised use full Android path:
    Code (Text):
    src="file:///storage/emulated/0/AutoTools/folder_name_with_image/flipped1.jpg"
     
  6. Hcaserty

    Hcaserty New Member

    Joined:
    Thursday
    Messages:
    2
    Likes Received:
    0
    I gave it up for the first time, and I'm going to try it
     
  7. nmcj

    nmcj Member

    Joined:
    Mar 24, 2016
    Messages:
    31
    Likes Received:
    2
    YES!
    YESYESYES!
    I am sure that was such a basic thing, but it was killin me!
    thank you all for your patience
     
    Last edited: Nov 16, 2017 at 1:01 PM
  8. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    5,133
    Likes Received:
    466
    Thank you very much for helping @szmerek! :)
     
  9. szmerek

    szmerek Member

    Joined:
    Jul 4, 2016
    Messages:
    101
    Likes Received:
    16
    You're welcome :)
     

Share This Page