Wilton Ergon Posted February 14, 2022 Share Posted February 14, 2022 I have a script in the main form, and I need to change it at runtime, because the value of a variable is defined by a parameter, I tried to make this change in the create of the main form, but there was no effect procedure TFrmPrincipal.UniFormCreate(Sender: TObject); var tempoTimeOut:integer; begin tempoTimeOut := i'm getparameter..... if tempoTimeOut>0 then self.script.Text :=StringReplace(script.Text,'var IDLE_TIMEOUT = 1800;','var IDLE_TIMEOUT = '+inttostr(tempoTimeOut*60)+';',[rfIgnoreCase,rfReplaceAll]); my script... in form create, change var IDLE_TIMEOUT var IDLE_TIMEOUT = 1800; var _idleSecondsCounter = 0; document.onclick = function() { _idleSecondsCounter = 0; }; document.onmousemove = function() { _idleSecondsCounter = 0; }; document.onkeypress = function() { _idleSecondsCounter = 0; }; window.setInterval(CheckIdleTime, 1000); function CheckIdleTime() { _idleSecondsCounter++; var oPanel = document.getElementById("SecondsUntilExpire"); if (oPanel) oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + ""; if (_idleSecondsCounter >= IDLE_TIMEOUT) { ajaxRequest(FrmPrincipal.form, '_idle_timeout', []); } } the objective, and that it is possible to configure the application timeout time Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 14, 2022 Share Posted February 14, 2022 14 minutes ago, Wilton Ergon said: var IDLE_TIMEOUT = 1800; var _idleSecondsCounter = 0; Hello, You can try replacing with: window.IDLE_TIMEOUT = 1800; window._idleSecondsCounter = 0; And then change the values when you need it... Quote Link to comment Share on other sites More sharing options...
Wilton Ergon Posted February 14, 2022 Author Share Posted February 14, 2022 22 minutes ago, Sherzod said: Hello, You can try replacing with: window.IDLE_TIMEOUT = 1800; window._idleSecondsCounter = 0; And then change the values when you need it... after this change in variable declaration my main form is no longer displayed Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 14, 2022 Share Posted February 14, 2022 1 hour ago, Wilton Ergon said: after this change in variable declaration my main form is no longer displayed Yes. You must also change these variables in the code where they are used. Quote Link to comment Share on other sites More sharing options...
Wilton Ergon Posted February 14, 2022 Author Share Posted February 14, 2022 found the problem, elsewhere on the system, this script was removed, when the system was accessed by support, it was not necessary to adjust the variables as you suggested. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 14, 2022 Share Posted February 14, 2022 29 minutes ago, Wilton Ergon said: found the problem, elsewhere on the system, this script was removed, when the system was accessed by support, it was not necessary to adjust the variables as you suggested. I recommended not replacing the script at all, just changing the variables that I specified and changing the values only for those variables. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.