0

How to compare multiple variablles using HTML widget & Java script

Single BS player. basically I have some images split into 3 vertical slices. each set is in its own zone. The idea is users can scroll through each slice stack to get 3 matching and complete the full image.

As each slice is displayed it sets its varaibale to 1.
So if a1=1, a2=1, a3=1 the image is complete and I want to trigger a zone message to un-hide the congratulations zone.

I have this java script and a local html page linked to an html widget but I'm not getting any zone messages.

Here's the script:-

// Function to check if all slices match
function checkMatch() {
    console.log("checkMatch is running...");

    // Image slice variables
    const a1 = 1; // Example values: Set dynamically in your code
    const a2 = 1;
    const a3 = 1;
    const t1 = 0;
    const t2 = 0;
    const t3 = 0;
    const r1 = 0;
    const r2 = 0;
    const r3 = 0;

    // Check for Blue match
    if (a1 === 1 && a2 === 1 && a3 === 1) {
        console.log("Condition met for blueVT");
        sendZoneMessage("blueVT");
    }

    // Check for Green match
    if (t1 === 1 && t2 === 1 && t3 === 1) {
        console.log("Condition met for greenVT");
        sendZoneMessage("greenVT");
    }

    // Check for Yellow match
    if (r1 === 1 && r2 === 1 && r3 === 1) {
        console.log("Condition met for yellowVT");
        sendZoneMessage("yellowVT");
    }
}

// Function to send zone message
function sendZoneMessage(message) {
    var port = new BrightSign.MessagePort(); // Create a MessagePort instance
    port.send(message); // Send the message
    console.log(`Zone message sent: ${message}`); // Debugging log
}

// Call checkMatch periodically
setInterval(checkMatch, 500); // Check matches every half second

Any help greatly accepted, happy to share any files, using latest BAconnected and firmware on the XT1143 player

5 comments

  • 0
    Avatar
    Russel Tait

    @matthew554 I dont suppose your freelance are you? we are looking for Brightsign programmers

  • 0
    Avatar
    Lee DYDOMITE Dydo

    Matt’s comments are AI nonsense. That’s not how it works. The first part is true because the code uses constants, but the rest does not match the platform. I could tell you why the rest doesn’t work. Do you need to actually hide the zone or is it OK if you leave the HTML state up and make everything in the html transparent?

  • 0
    Avatar
    Brandon

    If there's a suspicious or weird hyperlink in the reply, it's a bot.

  • 0
    Avatar
    Russel Tait

    @Lee DYDOMITE Dydo The HTML code can be totally transparent, I'm just using it to run the java script to check the 3 images zone variables match and when they match up to complete a full image, trigger the correct content video. there may be a beter way! but i'm just starting out on using scripts with brightsign players and we havent maganged to find anyone who could do this work for us!

     

  • 0
    Avatar
    Lee DYDOMITE Dydo

    Ok, that’s ideal. And yes, I understand the pain of trying to find BrightSign developers. My company does work like this and there are only a few others. Our unique selling point is that we used to be full time software developers at BrightSign, so our work is very high quality and fast. If we’re not a match I’m also happy to recommend other shops.

Please sign in to leave a comment.