Skip to content
Snippets Groups Projects
Commit 0922a540 authored by Lucio Zambon's avatar Lucio Zambon
Browse files

Update talk.js

parent d87f9cf4
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
window.openData = []; window.openData = [];
const t0 = + new Date(); const t0 = + new Date();
let mode = ''; 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 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'): ''; 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: '');} function switchLocale(newlang) {document.location = './talk.php?lang='+newlang+(host.length>0? '&talk='+host: '');}
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
if (document.location.search.indexOf('background=')>-1) { if (document.location.search.indexOf('background=')>-1) {
const a = document.location.search.split('background=')[1].split('&')[0]; const a = document.location.search.split('background=')[1].split('&')[0];
console.log(a); console.log(a);
$('body').css('background-color', +a > 0? '#'+a: a); // $('body').css('background-color', +a > 0? '#'+a: a);
$('#search').hide(); $('#open').hide(); $('#search').hide(); $('#open').hide();
} }
}); });
...@@ -69,10 +69,18 @@ ...@@ -69,10 +69,18 @@
$("#micstart").show(); $("#micstart").show();
$("#micna").hide(); $("#micna").hide();
$("#miclabel").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() { 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();} if (typeof window.SpeechRecognition == 'undefined') {$("#micstart").hide();$("#micna").show();}
keepAlive = false; keepAlive = false;
recognition.stop(); recognition.stop();
...@@ -188,8 +196,8 @@ ...@@ -188,8 +196,8 @@
if (num>-1) { 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]; 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(exe);
showLog(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(launcher+"?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((response) => {return response.json();})
.then((rlocale) => {showLog(rlocale);}); .then((rlocale) => {showLog(rlocale);});
/*showLog("./talk.php?speech="+window.openData[3]+"&lang="+lang+"&id="+window.openData[num].id); /*showLog("./talk.php?speech="+window.openData[3]+"&lang="+lang+"&id="+window.openData[num].id);
...@@ -206,9 +214,9 @@ ...@@ -206,9 +214,9 @@
mode = 'search'; mode = 'search';
$('#search').show(); $('#open').hide(); $('#search').show(); $('#open').hide();
// txt = txt.replace(tok+' ', '').replace('ing', 'inj').replace('inch', 'inj').split(' ').join('_').split('.').join('_').toUpperCase(); // 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 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>'); $('#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;}});}); $(function() {$(".sname").autocomplete({source: names, select: function(event, ui) {findComponent(ui.item.value, txt); return false;}});});
showLog(snd); showLog(snd);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment