irigsoft Posted September 4, 2020 Posted September 4, 2020 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. Quote
irigsoft Posted September 4, 2020 Author Posted September 4, 2020 I use this: Customfiles.add ('files\myscript.js'), but no script functions are performed Quote
Sherzod Posted September 4, 2020 Posted September 4, 2020 1 hour ago, irigsoft said: but no script functions are performed Sorry, not enough information. Quote
irigsoft Posted September 4, 2020 Author Posted September 4, 2020 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 Quote
irigsoft Posted September 4, 2020 Author Posted September 4, 2020 I managed . Problem was : no UniComboBoxVoicesAjaxEvent No script.js needed. Quote
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.