function start() {
navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
// store streaming data chunks in array
const chunks = [];
// create media recorder instance to initialize recording
recorder = new MediaRecorder(stream);
// function to be called when data is received
recorder.ondataavailable = e => {
// add stream data to chunks
chunks.push(e.data);
// if recorder is 'inactive' then recording has finished
if (recorder.state == 'inactive') {
// convert stream data chunks to a 'webm' audio format as a blob
window.publicBlobObj = new Blob(chunks, { type: 'audio/webm' });
// convert blob to URL so it can be assigned to a audio src attribute
createAudioElement(URL.createObjectURL(publicBlobObj));
}
};
// start recording with 1 second time between receiving 'ondataavailable' events
recorder.start();
// setTimeout to stop recording after 4 seconds
}).catch(console.error);
}
function stop() {
recorder.stop();
var xhr = new XMLHttpRequest();
var data = new FormData;
data.append("sound", window.publicBlobObj);
xhr.open('POST', '/User/Sound', true);
// Listen to the upload progress.
xhr.send(data);
}
var json1= {
"landLot": [
{ "value-ru": "Участок 1" },
{ "value-ru": "Участок 2" },
{ "value-ru": "Участок 3" },
{ "value-ru": "Участок 4" }
]
}
var json2= {
"fields": [
{
"name-ru": "Участок",
"enum": json1.landLot
}
]
}
json2.fields.enum;
var arr= [
{name: "row", value: "1"},
{name: "col", value: "2"},
{name: "section", value: "Бельетаж"},
{name: "row", value: "2"},
{name: "col", value: "5"},
{name: "section", value: "Бельетаж"}
], arrJSON= {}, n=1;
arr.forEach(function(i) {
arrJSON[n]= arrJSON[n] || {};
if (arrJSON[n][i.name]) {
n++;
arrJSON[n]= {};
arrJSON[n][i.name]= i.value
return;
}
arrJSON[n][i.name]= i.value;
})
console.log(arrJSON);
String.prototype.translit = String.prototype.translit || function () {
var Chars = {
'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo', 'ж': 'zh', 'з': 'z', 'и': 'i', 'й': 'y', 'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u', 'ф': 'f', 'х': 'h', 'ц': 'c', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch', 'ъ': '', 'ы': 'y', 'ь': '', 'э': 'e', 'ю': 'yu', 'я': 'ya', 'А': 'A', 'Б': 'B', 'В': 'V', 'Г': 'G', 'Д': 'D', 'Е': 'E', 'Ё': 'YO', 'Ж': 'ZH', 'З': 'Z', 'И': 'I', 'Й': 'Y', 'К': 'K', 'Л': 'L', 'М': 'M', 'Н': 'N', 'О': 'O', 'П': 'P', 'Р': 'R', 'С': 'S', 'Т': 'T', 'У': 'U', 'Ф': 'F', 'Х': 'H', 'Ц': 'C', 'Ч': 'CH', 'Ш': 'SH', 'Щ': 'SHCH', 'Ъ': '', 'Ы': 'Y', 'Ь': '', 'Э': 'E', 'Ю': 'YU', 'Я': 'YA'
},
t = this;
for (var i in Chars) { t = t.replace(new RegExp(i, 'g'), Chars[i]); }
return t;
};
console.log("транслитирировать строку".translit() );