Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/25/21 in all areas

  1. Yes, that was the problem, thanks
    1 point
  2. Here, delayedTask is exactly for showing the mask, and the code works immediately after clicking on the button.
    1 point
  3. Other solution for Your needs: //load custom file javascript function if (FileExists (ExtractFilepath (Application.ExeName) + '\files\voicescript.js')) then CustomFiles.Add ('files/voicescript.js'); //use function unisession.AddJS('youfunctionname (functionparameters)' );
    1 point
  4. Hi, I use this to start every javascript commands from file or direct command execute: procedure JAVASCRIPT_EXEC (Sender: TObject; fType, Data, DataObjectsList : AnsiString); var I : Integer; DataList : TStringList; sObject : TObject; begin if (Sender <> nil) then begin TRY With TUniControl (Sender) do begin ScreenMask.Message := 'Please, wait ...'; ScreenMask.WaitData := False;//True; ScreenMask.Enabled := False;//True; end; EXCEPT END; end; IF (Length (Data) > 1) then begin DataList := TStringList.Create; DataList.StrictDelimiter := True; DataList.Delimiter := ';'; //read data from file if file exists If FileExists (Data) then begin DataList.LoadFromFile (Data); Data := TRIM (DataList.Text); DataList.Clear; //DataList.Free; //If Assigned(DataList) then // FreeandNil (DataList); end; end; //TUnibutton (Sender).ClientEvents.ExtEvents.Values ['click'] := 'function click(sender, e, eOpts){' + Data + '}'; //UniSession.JSCode (Data); UniSession.AddJs (Data); //UniSession.JSONDirect (Data); end; This function I can start from every component
    1 point
  5. For development, I am using a special setup, trying to reduce time from compilation to browser refresh without any issues. For this I have to use HyperServer, due to is ability to automatically reload a new application file, from the deploy folder. So I run a webserver on my development PC, apache 2.2, and I have a post-compile event in Delphi which copies the EXE file to the \deploy folder, renaming it to *.dep. I have a timer in the mainForm which discovers that the HyperServer has loaded the new application file: procedure TMainForm.reloadTimerTimer(Sender: TObject); begin with uniMainModule do if newFileDate<>fileDate then begin reloadTimer.Enabled:=false; showToast('Reloading application...'); uniSession.AddJS('document.location.reload();'); end; end; This works fine, and it runs this newFileDate function in the MainModule: function TUniMainModule.newFileDate:TDateTime; var fileDateInt:Integer; begin fileDateInt := fileAge('c:\antirust\timebok\timebok.exe'); if fileDateInt > -1 then result:=fileDateToDateTime(fileDateInt); end; Of course this function is also run at MainModule startup: procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); begin fileDate:=newFileDate; end; The MainForm timer runs at 500ms intervals, so this all works fine, as you can see in the screenshot. But - there is of course another timer running in the HyperServer, and I wonder how I can reduce its interval? It seems like the HyperServer timer runs at 10 secs interval, and I would like to lower it to about 1 second. Then I can reduce the time from compile to browser reload, to about 3 seconds - maybe.
    1 point
×
×
  • Create New...