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

Update talk.js

parent 2273c82c
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,7 @@
}
}
let keepAlive = false;
const ancestor = [];
const names = [];
let aliveTimer = -1;
function startRec() {
......@@ -150,7 +151,7 @@
speechStat = '';
let txt = transcript.toLowerCase();
if (txt.length>0) {
const tok = txt.split(' ')[0];
let tok = txt.split(' ')[0];
if (locale[lang].open.indexOf(tok)>-1) {
mode = 'open';
$('#search').hide();
......@@ -170,7 +171,7 @@
window.openData.push(rlocale[i]);
}
}
$('#openTable').html('<tr><td>'+txt+'</td><td><input id="oname" class="oname"></input></td><td><button class="btn btn-primary" onClick="findPanel($(\"#oname\").val)">'+locale[lang].searchSubmit+'</button></td></tr>');
$('#openTable').html('<tr><td>'+txt+'</td><td><input id="oname" class="oname"></input></td><td><button class="btn btn-primary" onClick="mode=null">CANCEL</button></td></tr>');
$(function() {$(".oname").autocomplete({source: launcher, select: function(event, ui) {findPanel(ui.item.value, txt); return false;}});});
window.openData.push(txt);
showLog('window.openData1');
......@@ -217,7 +218,7 @@
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="+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" size="10"></input></td><td><button class="btn btn-primary" onClick="mode=null">CANCEL</button></td></tr>');
$(function() {$(".sname").autocomplete({source: names, select: function(event, ui) {findComponent(ui.item.value, txt); return false;}});});
showLog(snd);
fetch(snd).then((response) => {return response.text();}).then((rlocale) => {
......@@ -227,6 +228,28 @@
// mode = '';
// $('#search').hide(); $('#open').hide();
}
if (locale[lang].ujive.indexOf(tok)>-1) {
const token = document.location.search.indexOf('token=')>-1? '&token='+document.location.search.split('token=')[1].split('&')[0]: (document.location.search.indexOf('?d=')>-1? '&token='+document.location.search.split('?d=')[1].split('&')[0]: '');
const snd = './talk.php?search=ujive'+token+"&lang="+lang;
showLog('ujive');
showLog(snd);
fetch(snd).then((response) => {return response.json();}).then((rlocale) => {showLog(rlocale); alert(rlocale);});
mode = 'ujive';
ancestor.length = 0;
txt = txt.replace(tok, '').replace(' ', '');
}
if (mode=='ujive') {
showLog('ujive: '+tok);
if (!isNaN(tok)) {ancestor.push(tok); tok = 'n'+ancestor.join('_');}
if (locale[lang].back.indexOf(tok)>-1) ancestor.pop();
if (locale[lang].up.indexOf(tok)>-1) tok = 'up';
if (locale[lang].down.indexOf(tok)>-1) tok = 'down';
const token = document.location.search.indexOf('?d=')>-1? '&token='+document.location.search.split('?d=')[1].split('&')[0]: '';
const snd = './talk.php?ctree='+tok+token;
fetch(snd).then((response) => {return response.json();}).then((rlocale) => {showLog(rlocale); alert(rlocale);});
mode = '';
$('#search').hide(); $('#open').hide();
}
if (locale[lang].list.indexOf(tok)>-1) {
mode = 'list';
txt = txt.replace(tok, '').replace(' ', '');
......@@ -252,6 +275,7 @@
fetch(snd).then((response) => {return response.text();}).then((rlocale) => {showLog(rlocale); /*alert(rlocale);*/});
}
function findComponent(txt, speech) {
if (locale[lang].open.indexOf(txt)>-1) return;
showLog(txt);
showLog(speech);
const token = document.location.search.indexOf('?d=')>-1? '&token='+document.location.search.split('?d=')[1].split('&')[0]: '';
......
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