From 0922a54037b36f61d4509a443481743a23c29c10 Mon Sep 17 00:00:00 2001 From: Lucio Zambon <lucio.zambon@elettra.eu> Date: Thu, 4 Jul 2024 03:30:04 +0000 Subject: [PATCH] Update talk.js --- speech/talk.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/speech/talk.js b/speech/talk.js index e103b01..e429bb2 100644 --- a/speech/talk.js +++ b/speech/talk.js @@ -4,7 +4,7 @@ window.openData = []; const t0 = + new Date(); let mode = ''; - const launcher = 'https://puma-01.elettra.eu/knob/launcher.php'; + const launcherSrc = 'https://puma-01.elettra.eu/knob/launcher.php'; const lang = document.location.search.indexOf('lang=')>-1 && document.location.search.split('lang=')[1].split('&')[0]=='en'? 'en-US': 'it-IT'; // BCP 47 language const host = document.location.search.indexOf('talk=')>-1? document.location.search.split('talk=')[1].split('&')[0].replace('ee', 'pcl-elettra-cre-0').replace('ef','pcl-elettra-crf-0'): ''; function switchLocale(newlang) {document.location = './talk.php?lang='+newlang+(host.length>0? '&talk='+host: '');} @@ -18,7 +18,7 @@ if (document.location.search.indexOf('background=')>-1) { const a = document.location.search.split('background=')[1].split('&')[0]; console.log(a); - $('body').css('background-color', +a > 0? '#'+a: a); + // $('body').css('background-color', +a > 0? '#'+a: a); $('#search').hide(); $('#open').hide(); } }); @@ -69,10 +69,18 @@ $("#micstart").show(); $("#micna").hide(); $("#miclabel").hide(); - if (window.parent && window.parent.document.getElementById("talk")) window.parent.document.getElementById("talk").style.height = "250px"; + if (window.parent && window.parent.document.getElementById("talk")) { + window.parent.document.getElementById("talk").style.height = "250px"; + window.parent.document.getElementById("talk").style.position = "absolute"; + window.parent.document.getElementById("talk").style.right = ((window.parent.innerWidth-250)/2)+"px"; + window.parent.document.getElementById("talk").style.top = ((window.parent.innerHeight-250)/2)+"px"; + } } function stopRec() { - if (window.parent && window.parent.document.getElementById("talk")) window.parent.document.getElementById("talk").style.height = "30px"; + if (window.parent && window.parent.document.getElementById("talk")) { + window.parent.document.getElementById("talk").style.height = "30px"; + window.parent.document.getElementById("talk").style.position = "unset"; + } if (typeof window.SpeechRecognition == 'undefined') {$("#micstart").hide();$("#micna").show();} keepAlive = false; recognition.stop(); @@ -188,8 +196,8 @@ if (num>-1) { const exe = (window.openData[num].path? window.openData[num].path: '/runtime/bin/')+ window.openData[num].exename + '&host=' + document.location.search.split('host=')[1].split('&')[0]; showLog(exe); - showLog(launcher+"?open="+exe+"&speech="+window.openData[3]+"&lang="+lang+"&id="+window.openData[num].id); - fetch(launcher+"?open="+exe+"&speech="+window.openData[3]+"&lang="+lang+"&id="+window.openData[num].id) + showLog(launcherSrc+"?open="+exe+"&speech="+window.openData[3]+"&lang="+lang+"&id="+window.openData[num].id); + fetch(launcherSrc+"?open="+exe+"&speech="+window.openData[3]+"&lang="+lang+"&id="+window.openData[num].id) .then((response) => {return response.json();}) .then((rlocale) => {showLog(rlocale);}); /*showLog("./talk.php?speech="+window.openData[3]+"&lang="+lang+"&id="+window.openData[num].id); @@ -206,9 +214,9 @@ mode = 'search'; $('#search').show(); $('#open').hide(); // txt = txt.replace(tok+' ', '').replace('ing', 'inj').replace('inch', 'inj').split(' ').join('_').split('.').join('_').toUpperCase(); - txt = txt.replace(tok+' ', '').split(' ').join('_').split('.').join('_').toUpperCase(); + txt = txt.replace(tok+' ', '').split(' ').join('_').split('.').join('_').split('-').join('_').toUpperCase(); const token = document.location.search.indexOf('?d=')>-1? '&token='+document.location.search.split('?d=')[1].split('&')[0]: ''; - const snd = './talk.php?search='+txt+token+"&lang="+lang+"&speech="+txt; + const snd = './talk.php?search='+txt+token+"&lang="+lang+"&speech="+tok; $('#openTable').html('<tr><td colspan="5">' + locale[lang].searchCorrect + '</td></tr><tr><td>'+txt+'</td><td><input id="sname" class="sname"></input></td><td><button class="btn btn-primary" onClick="findComponent($(\"#sname\").val)">'+locale[lang].searchSubmit+'</button></td></tr>'); $(function() {$(".sname").autocomplete({source: names, select: function(event, ui) {findComponent(ui.item.value, txt); return false;}});}); showLog(snd); -- GitLab