Hide Buttons when a user is logged out

Hello,
Is there a way to have the buttons of offline users (phone registered but not logged in to FOP2) be css set to display:none; ?

Thanks,

MC

Best Answer

  • edited October 2021 Accepted Answer

    This is a simple Javascript that modifies the css if the buttons are set to OUT. I am not the best scripter so I am sure there are more efficient ways to optimise this code. But hey, it works... It was added to a seperate file ( in the /var/www/html/fop2/ directory) with a javascript including it (script type="text/javascript" src="thisfile.js") in index.html.

    I DO NOT THINK IT SURVIVES A VERSION UPGRADE.

    @Nicolas, it would be nice that in index.html, you include by default a "custom.js" file in a "custom" directory that is preserved in upgrades to allow us to customise as required if need be and survive upgrades.

    //STARTS HERE
    //Maximum buttons used (in doubt, make this higher than need to be but not too high to waste browser speed looking for things that do not exist)
    var max_boton = 25;

    //What is the tag when agent is not in
    OUTname = "OUT";

    //Wait 10 seconds after document is ready to launch function to perpetuity
    $( document ).ready(function(){
    setTimeout(function() { do_hide_boton(); }, 10000);
    }
    );

    //This is the function that shows or hide the buttons
    function do_hide_boton()
    {

    //Loop thru all botons up to max_boton
    for (boton_num = 1; boton_num < max_boton; boton_num++)
    {
    // check if boton exists
    if(document.getElementById("presence"+ boton_num) !== null)
    {
    //If user is logged out OR extension is notregistered hide the button
    if(document.getElementById("presence"+ boton_num).getAttribute("data-original-title") == OUTname || document.getElementById("boton"+ boton_num).classList.contains('notregistered'))
    {
    document.getElementById("boton"+ boton_num).style.display = "none";
    }
    else
    {
    document.getElementById("boton"+ boton_num).style.display = "";
    }
    }

    } // for (boton_num = 1; boton_num <= max_boton; boton_num++)

    //Recall itself every 5000 miliseconds
    setTimeout(arguments.callee, 5000);

    }

Sign In or Register to comment.