2022-11-23 04:15:30 +00:00
< html >
< head >
< script src = "https://code.jquery.com/jquery-3.6.1.min.js" integrity = "sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin = "anonymous" > < / script >
2023-01-01 20:54:44 +00:00
< link rel = "stylesheet" href = "https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity = "sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin = "anonymous" >
2022-11-23 04:15:30 +00:00
< script type = "text/javascript" >
function loadLocale(){
2023-01-01 00:06:50 +00:00
var sourceUrl = "https://raw.githubusercontent.com/organicmaps/organicmaps/5f7013eb5520d1c849342b0bfac2dd53fa428340/data/sound-strings/"+$("#localeSelect").val()+".json/localize.json";
var fancyUrl = "https://github.com/organicmaps/organicmaps/blob/5f7013eb5520d1c849342b0bfac2dd53fa428340/data/sound-strings/"+$("#localeSelect").val()+".json/localize.json"
2022-11-23 04:15:30 +00:00
2022-12-01 04:44:21 +00:00
$("#sourceUrl").attr("href", fancyUrl).text($("#localeSelect").val()+".json");
2022-11-23 04:15:30 +00:00
$.getJSON(sourceUrl, function(data){
const distance = [
"in_50_meters",
"in_100_meters",
"in_200_meters",
"in_250_meters",
"in_300_meters",
"in_400_meters",
"in_500_meters",
"in_600_meters",
"in_700_meters",
"in_750_meters",
"in_800_meters",
"in_900_meters",
"in_1_kilometer",
"in_1_5_kilometers",
"in_2_kilometers",
"in_2_5_kilometers",
"in_3_kilometers",
"in_50_feet",
"in_100_feet",
"in_200_feet",
"in_300_feet",
"in_400_feet",
"in_500_feet",
"in_600_feet",
"in_700_feet",
"in_800_feet",
"in_900_feet",
"in_1000_feet",
"in_1500_feet",
"in_2000_feet",
"in_2500_feet",
"in_3000_feet",
"in_3500_feet",
"in_4000_feet",
"in_4500_feet",
"in_5000_feet",
"in_1_mile",
"in_1_5_miles",
"in_2_miles"
];
const direction = [
"take_the_1_exit",
"take_the_2_exit",
"take_the_3_exit",
"take_the_4_exit",
"take_the_5_exit",
"take_the_6_exit",
"take_the_7_exit",
"take_the_8_exit",
"take_the_9_exit",
"take_the_10_exit",
"take_the_11_exit",
"make_a_slight_right_turn",
"make_a_right_turn",
"make_a_sharp_right_turn",
"enter_the_roundabout",
"leave_the_roundabout",
"make_a_slight_left_turn",
"make_a_left_turn",
"make_a_sharp_left_turn",
"make_a_u_turn",
"go_straight",
"exit",
"destination"
];
2023-01-01 20:54:44 +00:00
const nextStreets = [
"Main Street",
"Highway 99",
"Exit 12, Main Street, London",
];
2022-11-23 04:15:30 +00:00
// dist_direction_onto_street
// then
// you_have_reached_the_destination
// unknown_camera
2023-01-01 20:54:44 +00:00
$("#out-a").html("");
$("#out-b").html("");
$("#out-c").html("");
$("#out-d").html("");
$("#out-e").html("");
$("#out-f").html("");
$("#out-g").html("");
var inputPre = "< div class = 'input-group mb-3' > < button type = 'button' class = 'playtts btn btn-outline-secondary' > 🔊< / button > < button class = 'editbutton btn btn-secondary' type = 'button' > Edit< / button > < button class = 'savebutton btn btn-success' style = 'display: none;' type = 'button' > Save< / button > < input class = 'form-control' disabled = 'disabled' type = 'text' value = '";
var inputPost = "' />< / div > ";
2022-11-23 04:15:30 +00:00
$.each(direction, function(i, dir){
// can't "you'll arrive" in the present tense
if (dir != "destination") {
2023-01-01 20:54:44 +00:00
$("#out-a").append(inputPre + data[dir] + inputPost);
2022-11-23 04:15:30 +00:00
}
});
$.each(direction, function(i, dir){
// can't "then" past your destination
if (dir != "destination") {
var nextDir = direction[(i + 1) % direction.length];
2023-01-01 20:54:44 +00:00
$("#out-b").append(inputPre + data[dir] + " " + data['then'] + " " + data[nextDir] + inputPost);
2022-11-23 04:15:30 +00:00
}
});
$.each(distance, function(i, dist){
var dir = direction[i % direction.length];
2023-01-01 20:54:44 +00:00
$("#out-c").append(inputPre + data[dist] + " " + data[dir] + inputPost);
2022-11-23 04:15:30 +00:00
});
$.each(distance, function(i, dist){
var dir = direction[i % direction.length];
// can't "then" past your destination
if (dir != "destination") {
var nextDir = direction[(i + 1) % direction.length];
2023-01-01 20:54:44 +00:00
$("#out-d").append(inputPre + data[dist] + " " + data[dir] + " " + data['then'] + " " + data[nextDir] + inputPost);
2022-11-23 04:15:30 +00:00
}
});
$.each(distance, function(i, dist){
var dir = direction[i % direction.length];
var nextDir = direction[(i + 1) % direction.length];
var ttsFmt = data['dist_direction_onto_street'];
ttsFmt = ttsFmt.replace("%1$s", data[dist].replace(/[\.。।]/g, "")); // no full stops
ttsFmt = ttsFmt.replace("%2$s", data[dir].replace(/[\.。।]/g, "")); // no full stops
2023-01-01 20:54:44 +00:00
ttsFmt = ttsFmt.replace("%3$s", nextStreets[(i+1) % nextStreets.length]);
2022-11-23 04:15:30 +00:00
2023-01-01 20:54:44 +00:00
$("#out-e").append(inputPre + ttsFmt + inputPost);
2022-11-23 04:15:30 +00:00
});
$.each(distance, function(i, dist){
var dir = direction[i % direction.length];
var nextDir = direction[(i + 1) % direction.length];
var ttsFmt = data['dist_direction_onto_street'];
ttsFmt = ttsFmt.replace("%1$s", data[dist].replace(/[\.。।]/g, "")); // no full stops
ttsFmt = ttsFmt.replace("%2$s", data[dir].replace(/[\.。।]/g, "")); // no full stops
2023-01-01 20:54:44 +00:00
ttsFmt = ttsFmt.replace("%3$s", nextStreets[(i+1) % nextStreets.length]);
$("#out-f").append(inputPre + ttsFmt + " " + data['then'] + " " + data[nextDir] + inputPost);
});
$("#out-g").append(inputPre + data['you_have_reached_the_destination'] + inputPost);
$("#out-g").append(inputPre + data['unknown_camera'] + inputPost);
2022-11-23 04:15:30 +00:00
2023-01-01 20:54:44 +00:00
$(".editbutton").click(function(){
var sibling = $($(this).siblings(".form-control")[0]);
// console.log(sibling);
// console.log(sibling.val());
sibling.data("orig-value", sibling.val());
// console.log(sibling.data("orig-value"));
sibling.prop( "disabled", false );
sibling.focus();
$(this).hide();
$(this).siblings(".savebutton").show();
2022-11-23 04:15:30 +00:00
});
2023-01-01 20:54:44 +00:00
$(".savebutton").click(function(){
var changes = [];
var thisSaveButton = $(this);
var thisSibling = $($(this).siblings(".form-control")[0]);
thisSibling.prop( "disabled", true );
thisSaveButton.hide();
thisSaveButton.siblings(".editbutton").show();
$("div.output .form-control").each(function(i,o){
var sibling = $(o);
// console.log("orig",sibling.data("orig-value"));
// console.log("val",sibling.val());
if (sibling.data("orig-value") & & sibling.data("orig-value") != sibling.val()) {
// console.log("got",sibling.val());
changes.push([sibling.data("orig-value"), sibling.val()]);
}
});
if (changes.length > 0){
var out = "";
var locale = $("#localeSelect").val();
2022-11-23 04:15:30 +00:00
2023-01-01 20:54:44 +00:00
$.each(changes, function(x,y){
// console.log(x,y);
out += "- "+locale+" = "+y[0]+"\n"+
"+ "+locale+" = "+y[1]+"\n"
});
2022-11-23 04:15:30 +00:00
2023-01-01 20:54:44 +00:00
// console.log("writing", out);
$("#submitpopup textarea").text("Translation change request:\n```\n"+
"# data/strings/sound.txt\n"+
out+"```"
);
$("#submitpopup").show();
}
});
// $("#closesubmitpopup").click(function(){
// $("#submitpopup").hide();
// });
$('.copyToClipboard').click(function () {
$('#submitpopup textarea').select();
document.execCommand('copy');
$(this).addClass("btn-success").text("Copied!");
});
$(".playtts").click(function(){
var text = $($(this).siblings(".form-control")[0]).val();
const msg = new SpeechSynthesisUtterance(
text
);
msg.voice = voices[$("#voiceSelect").val()];
synth.speak(msg);
});
2022-11-23 04:15:30 +00:00
});
}
< / script >
2023-01-01 20:54:44 +00:00
< style type = "text/css" >
div.output .input-group { width: 55em; }
div.output {
margin-bottom: 1em;
padding-bottom: 1em;
border-bottom: 1px dashed;
}
< / style >
2022-11-23 04:15:30 +00:00
< / head >
2023-01-01 20:54:44 +00:00
< body style = "padding: 1em;" >
< div style = "float: right; width: 25%" >
2022-11-23 04:15:30 +00:00
Locale file:
2023-01-01 20:54:44 +00:00
< select id = "localeSelect" class = "form-control" >
2022-11-23 04:15:30 +00:00
< option value = "ar" > ﺎﻠﻋﺮﺒﻳﺓ< / option >
< option value = "be" > Беларусь< / option >
< option value = "ca" > Català< / option >
< option value = "cs" > Čeština< / option >
< option value = "da" > Dansk< / option >
< option value = "de" > Deutsch< / option >
< option value = "el" > Ελληνικά< / option >
< option value = "en" > English< / option >
< option value = "es" > Español< / option >
2023-01-01 00:17:19 +00:00
< option value = "es-MX" > Español (MX)< / option >
2022-11-23 04:15:30 +00:00
< option value = "eu" > Euskara< / option >
< option value = "fa" > ﻑﺍﺮﺴﯾ< / option >
< option value = "fi" > Suomi< / option >
< option value = "fr" > Français< / option >
< option value = "hi" > हिंदी< / option >
< option value = "hr" > Hrvatski< / option >
< option value = "hu" > Magyar< / option >
< option value = "id" > Indonesia< / option >
< option value = "it" > Italiano< / option >
< option value = "ja" > 日本語< / option >
< option value = "ko" > 한국어< / option >
< option value = "mr" > मराठी< / option >
2023-01-01 00:17:19 +00:00
< option value = "nb" > Norsk< / option >
2022-11-23 04:15:30 +00:00
< option value = "nl" > Nederlands< / option >
< option value = "pl" > Polski< / option >
< option value = "pt" > Português< / option >
2023-01-01 00:17:19 +00:00
< option value = "pt-BR" > Português (BR)< / option >
2022-11-23 04:15:30 +00:00
< option value = "ro" > Română< / option >
< option value = "ru" > Русский< / option >
< option value = "sk" > Slovenčina< / option >
< option value = "sv" > Svenska< / option >
< option value = "sw" > Kiswahili< / option >
< option value = "th" > ภาษาไทย< / option >
< option value = "tr" > Türkçe< / option >
< option value = "uk" > Українська< / option >
< option value = "vi" > Tiếng Việt< / option >
< option value = "zh-Hans" > 中文简体< / option >
< option value = "zh-Hant" > 中文繁體< / option >
< / select > < br / > < br / >
2023-01-01 20:54:44 +00:00
TTS Voice: < select id = "voiceSelect" class = "form-control" > < / select > < br / > < br / >
<!--
2022-12-01 04:46:33 +00:00
< a id = "sourceUrl" href = "#" target = "_blank" > json< / a > < br / >
2022-12-01 06:13:37 +00:00
< a href = "https://github.com/organicmaps/organicmaps/blob/ada410b5825e2dfd7c1ed95d539292dcef7d09dc/data/strings/sound.txt" target = "_blank" > sound.txt< / a > < br / >
2022-12-01 04:46:33 +00:00
< em > Please propose any fixes by editing sound.txt or by adding a comment to the < a href = "https://github.com/organicmaps/organicmaps/pull/3130" > pull request< / a > < / em >
2023-01-01 20:54:44 +00:00
-->
<!-- position: absolute; z - index: 999; padding: 1em; box - shadow: 2px 2px 6px #999; top: 20%; left: 20%; width: 60%; background: white; border: 1px solid black;" -->
< div id = "submitpopup" style = "display: none;" >
< h3 > Copy this text: < button address = "any text" class = "btn btn-sm btn-primary copyToClipboard" > < span > Copy< / span > < / h3 >
< textarea class = "form-control" style = "height: 20em;" > < / textarea >
< h5 > Then, paste it into a new comment on < a href = "https://github.com/organicmaps/organicmaps/pull/3130" target = "_blank" > this Github pull request< / a > < / h5 >
<!--
< p style = "text-align: center; margin-top: 2em;" >
< button id = "closesubmitpopup" class = "btn btn-danger" > Done< / button >
< / p >
-->
< / div >
< / div >
< div style = "width: 74%; height: 55em; overflow: scroll; border: 1px solid #ccc; padding: 1em;" >
< div class = "output" id = "out-e" > < / div >
< div class = "output" id = "out-f" > < / div >
< div class = "output" id = "out-g" > < / div >
< div class = "output" id = "out-a" > < / div >
< div class = "output" id = "out-b" > < / div >
< div class = "output" id = "out-c" > < / div >
< div class = "output" id = "out-d" > < / div >
2022-11-23 04:15:30 +00:00
< / div >
< script type = "text/javascript" >
const synth = window.speechSynthesis;
var voices;
$(document).ready(function(){
voices = synth.getVoices();
$.each(voices, function(i, voice){
$("#voiceSelect").append('< option value = "'+i+'" lang = "'+voice.lang+'" > '+voice.name+'< / option > ');
});
if (voices.length == 0) {
$("#voiceSelect").attr("disabled", "disabled");
$("#myvoice").text('Try another browser to use TTS').attr("disabled", "disabled");
}
let params = new URLSearchParams(document.location.search);
let lang = params.get("lang");
let tts = params.get("tts");
const userLocale =
navigator.languages & & navigator.languages.length
? navigator.languages[0]
: navigator.language;
if (lang) {
$("#localeSelect").val(lang);
} else {
$("#localeSelect option").each(function(i, o){
if (userLocale.match($(o).attr('value'))) {
$("#localeSelect").val($(o).attr('value'));
}
});
}
if (tts) {
$("#voiceSelect").val(tts);
} else {
2023-01-01 20:54:44 +00:00
if (lang) {
$("#voiceSelect option").each(function(i, o){
// console.log(lang,$(o).attr('lang').substr(0,2));
if (lang.match($(o).attr('lang').substr(0,2))) {
// console.log("got it");
$("#voiceSelect").val($(o).attr('value'));
return false;
}
});
} else {
$("#voiceSelect option").each(function(i, o){
// console.log(userLocale,$(o).attr('lang'));
if (userLocale.match($(o).attr('lang'))) {
$("#voiceSelect").val($(o).attr('value'));
}
});
}
2022-11-23 04:15:30 +00:00
}
$("#localeSelect").change(function(){
params.set('lang', $("#localeSelect").val());
document.location.search = params.toString();
});
$("#voiceSelect").change(function(){
params.set('tts', $("#voiceSelect").val());
document.location.search = params.toString();
});
loadLocale();
});
< / script >
< / body >
< / html >
2023-01-01 20:54:44 +00:00