LogicMachine Forum
JS different reactions between 2.8.0 and 2.8.3 - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: JS different reactions between 2.8.0 and 2.8.3 (/showthread.php?tid=5404)



JS different reactions between 2.8.0 and 2.8.3 - SigmaTec - 03.05.2024

Hi all,

I writed this script to open a plan according to a user, and hiding menus if it is not an 'admin' one.

It works fine on a HW2 v2.8.0
It don't works on a SpaceLynk v2.8.3

Code:
// ------------------------------------------------------------------------------------- // Dominique Barboyon (c) 19/03/2024 // ------------------------------------------------------------------------------------- // opens a specific plan according to the user login and hides menus if it's not admin // 19/03/2024 - v1.0 // ------------------------------------------------------------------------------------- $(function(){    var xhttp = new XMLHttpRequest();    xhttp.onreadystatechange = function() {       if (xhttp.readyState == 4 && xhttp.status == 200) {          var res = xhttp.responseText;          res = res.trim();          var isuser = 0;          if (typeof(res) !== "undefined" && res !== null){             if (res == 'lota00'){                showPlan(3);                isuser = 1;             }              if (res == 'lotb05'){                showPlan(19);                isuser = 1;             }                       if (res == 'admin_craft'){                showPlan(21);                isuser = 0;             }             if (res == 'admin'){                showPlan(21);                isuser = 0;             }                        if (isuser == 1){                       $('.menu').hide();                $('.layers').css('left', 0);             }                     }               }    };    xhttp.open("GET", "/user/user.lp", true);    xhttp.send(); });


So, it seams I have to install "user.lp" on the user directory on my SpaceLynk.

As I can't acces viai FTP (security reason) to the SpaceLynk's customer, I want to try to create it via a Lua scritp as this :

Code:
local f = assert(io.open("user/user.lp", "w")) f:write("<?", '\n') f:write("require('apps')", '\n') f:write("clientuser = request.username or 'anonymous'", '\n') f:write("print(clientuser)", '\n') f:write("?>", '\n') f:close()

Question 1 : what is exactly the path ? "user/user.lp" for example.
Question 2 : Is it necessary to update access rights for user.lp to rw-rw-rw- ?

Thank's in advance !


RE: JS different reactions between 2.8.0 and 2.8.3 - admin - 03.05.2024

You don't need .lp file for this, simply use Globals.user variable.


RE: JS different reactions between 2.8.0 and 2.8.3 - SigmaTec - 03.05.2024

Perfect Admin, thank you.