Jump to content

Recommended Posts

Posted

How to load some "script.js" file from local dir and execute them in uniForm.

 

I have some functions on javascript in outer file, I want to load in form when uniServerModule starts (or uniMainModule) and use them in some forms.

Posted
1 hour ago, Sherzod said:

Sorry, not enough information. 

Sorry,

I will explaine:

1. download files from here: 

2. and want to use in may project only script.js I try to load it in

uniServerModule.UniGUIServerModuleCreate ();

    CustomFiles.Add ('files/voicescript.js');

not error ocures, but cant load languages (speach engines). On Original files dir \original have html, script and css they work .

I just want to load and use script.js like Fred Montier in uniGui project.

In Fred's example the script loads all languages in uniCombobox, I want exactly that to happen in my project (loading availible speechengines in ComboBox)

 

I opened script.js and see that is like unigui projects, and understand where my problem is, uniProject from some reason cant load speach engines, to load them (but no success) i use this:

in uniForm have uniCombobox with name UniComboBoxVoices.

to call LoadVoices i use:

procedure TUniForm1.UniFormActivate(Sender: TObject);
begin
 LoadVoices (UniComboBoxVoices);

end;
 

and function from Fred:

Procedure TUniForm1.LoadVoices (Sender : TObject);
Begin
  // Loading voices - This should only run once.
  UniComboBoxVoices.Items.clear;
  uniSession.AddJS('var voices = speechSynthesis.getVoices(); ' +
                  'voices.forEach(function(voice, i) { '+
                 // 'alert(voice.name);'+
  'ajaxRequest(' +  TuniCombobox (Sender).OwnerForm.Name + '.' + TuniCombobox (Sender).Name + ', ' + Quotedstr('additem')+', ['+quotedstr('item=')+'+voice.name])});');


  //Browser Status Compatibility
  uniSession.AddJS('  if ('+quotedstr('speechSynthesis')+' in window) {'+
  'ajaxRequest(' +  TuniCombobox (Sender).OwnerForm.Name + '.lbCompatible, ' + Quotedstr('status')+', ['+quotedstr('msg=')+'+'+quotedstr('Compatible Browser')+'])' +
  ' } else {'+
   'ajaxRequest(' +  TuniCombobox (Sender).OwnerForm.Name + '.lbCompatible, ' + Quotedstr('status')+', ['+quotedstr('msg=')+'+'+quotedstr('Uncompatible Browser')+'])};');
End;

 

this should load in UniComboBoxVoices Items some voices (I see it with html from \ Original files from Fred).

May be I wrong here :

uniSession.AddJS('var voices = speechSynthesis.getVoices(); ' +
                  'voices.forEach(function(voice, i) { '+
                 // 'alert(voice.name);'+
  'ajaxRequest(' +  TuniCombobox (Sender).OwnerForm.Name + '.' + TuniCombobox (Sender).Name + ', ' + Quotedstr('additem')+', ['+quotedstr('item=')+'+voice.name])});');

 

This uniForm1 I create dynamically after login and it has a different name (from uniForm1)

Maybe the problem is not in script.js loading

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...