This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Hide an object in a plan when an user is entering on it
#5
Hi,

Try this:

Give each element a unique additional class like first object "hideobject_1", second object "hideobject_2" etcetera.

Run this script once to create the user.lp:
Code:
dst = '/www/user/user.lp'
io.writefile(dst, [[
<?
   require('apps')
   clientuser = request.username or 'anonymous'
   print(clientuser)
?>
]])
script.disable(_SCRIPTNAME)
Add this to your custom Javascript:
Code:
$(function(){
 
  var configtable = [
    { username:"admin", hideobject: [1,2] },
    { username:"erwin", hideobject: [1,2,3,4,5,6,7,8,9,10,11] },
  ];
 
  // Function to hide objects
  function hideObject(objnr){
    $(".hideobject_" + objnr).addClass("hide");
  }
 
  $.get("/user/user.lp", function(data, status){
    if (status === "success"){
      var username = data.trim();   
      for (var i in configtable) {
        if(username == configtable[i].username){
          for (var j in configtable[i].hideobject) {
            hideObject(configtable[i].hideobject[j]);
          }    
         }
      }
    }
  });

})
By adding the corresponding numbers hideobject_# in the hideobject array (next to the username) you can change the visibility of a object that is mapped to a user.

Have fun (:

BR,

Erwin
Reply


Messages In This Thread
RE: Hide an object in a plan when an user is entering on it - by Erwin van der Zwart - 05.12.2019, 15:16

Forum Jump: