Hide Buttons when a user is logged out
-
-
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);}
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login