mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
minibar: moved 2 reusable functions from minibar_translations.js to minibar_support.js
This commit is contained in:
@@ -61,3 +61,35 @@ function open_popup(url,target) {
|
||||
}
|
||||
|
||||
function opener_element(id) { with(window.opener) return element(id); }
|
||||
|
||||
function supportsSVG() {
|
||||
return document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")
|
||||
}
|
||||
|
||||
function speech_buttons(to3,to2,txt) {
|
||||
var voices = window.speechSynthesis && window.speechSynthesis.getVoices() || []
|
||||
var dvs = voices.filter(function(v){return v.default})
|
||||
if(to2)
|
||||
var pick=function (v) { return v.lang==to2 }
|
||||
else {
|
||||
var to2dash=alangcode(to3)+"-"
|
||||
var pick=function(v) { return hasPrefix(v.lang,to2dash) }
|
||||
}
|
||||
function btn(v) {
|
||||
var u=new SpeechSynthesisUtterance(txt)
|
||||
u.lang=v.lang // how to use v.voiceURI or v.name?
|
||||
|
||||
function speak() {
|
||||
speechSynthesis.cancel()
|
||||
speechSynthesis.speak(u)
|
||||
}
|
||||
return button(v.lang,speak)
|
||||
}
|
||||
//console.log(voices.length,"voices")
|
||||
var vs=dvs.filter(pick)
|
||||
if(vs.length==0) vs=voices.filter(pick)
|
||||
//console.log(vs.length,"voices for "+to3+" "+to2)
|
||||
var btns=vs.map(btn)
|
||||
//console.log(btns.length,"voice buttons")
|
||||
return wrap("span",btns)
|
||||
}
|
||||
|
||||
@@ -329,35 +329,3 @@ function draw_bracketss(bs) {
|
||||
? bs.map(draw_brackets) //with gf>3.5, in some cases
|
||||
: draw_brackets(bs) // with gf<=3.5
|
||||
}
|
||||
|
||||
function supportsSVG() {
|
||||
return document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")
|
||||
}
|
||||
|
||||
function speech_buttons(to3,to2,txt) {
|
||||
var voices = window.speechSynthesis && window.speechSynthesis.getVoices() || []
|
||||
var dvs = voices.filter(function(v){return v.default})
|
||||
if(to2)
|
||||
var pick=function (v) { return v.lang==to2 }
|
||||
else {
|
||||
var to2dash=alangcode(to3)+"-"
|
||||
var pick=function(v) { return hasPrefix(v.lang,to2dash) }
|
||||
}
|
||||
function btn(v) {
|
||||
var u=new SpeechSynthesisUtterance(txt)
|
||||
u.lang=v.lang // how to use v.voiceURI or v.name?
|
||||
|
||||
function speak() {
|
||||
speechSynthesis.cancel()
|
||||
speechSynthesis.speak(u)
|
||||
}
|
||||
return button(v.lang,speak)
|
||||
}
|
||||
//console.log(voices.length,"voices")
|
||||
var vs=dvs.filter(pick)
|
||||
if(vs.length==0) vs=voices.filter(pick)
|
||||
//console.log(vs.length,"voices for "+to3+" "+to2)
|
||||
var btns=vs.map(btn)
|
||||
//console.log(btns.length,"voice buttons")
|
||||
return wrap("span",btns)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user