The simultaneous interpretation of the proceedings is provided by the United Nations with the purpose of facilitating communication, in light of the fact that there are six official languages of the United Nations. Only the speech or intervention in the original language is authentic and constitutes an authentic record of the proceedings. In case of any inconsistency between the interpretation and the speech or intervention in the original language, the latter shall prevail.
';
dialog.appendChild(spinnerHTML);
dialog.appendChild(messageHTML);
break;
case "download":
dialog.className = 'download';
dialog.appendChild(messageHTML);
break;
default:
dialog.className = '';
dialog.appendChild(messageHTML);
}
fragment.appendChild(dialog)
messageContainer.appendChild(fragment);
}
function hideDialog(e) {
let modal = document.querySelector('#page-overlay > div.overlay-content-wrap')
modal.textContent = '';
modal.parentElement.style.display = "none";
}
async function getFile(e) {
try {
e.preventDefault();
showDialog('Connecting ...', "spinner");
let fileId = e.target.getAttribute("data-audio-file");
const lang = e.target.getAttribute("data-audio-lang");
if (!fileId) return;
const tokenData = await fetch('token-azure.jspx')
.then(response => {
if (!response.ok) { throw new Error(response.status + " :: " + response.statusText) }
else return response.json()
}).catch(function(reason) {
throw new Error("" + reason);
});
const token = tokenData.access_token;
const apiEndPoint = tokenData.apiUri;
const apiSub = tokenData.apiSub;
const targetEnv = tokenData.env;
if (targetEnv === "test") {
fileId = '97b6710c-b536-4c12-ab0c-329d5cf25881';
}
if (token == null) throw new Error("Auth error");
showDialog("Preparing audio file for download ...", 'spinner');
const blob = await fetch(apiEndPoint + fileId, {
method: 'GET',
headers: {
'Authorization': 'Bearer ' + token,
'Ocp-Apim-Subscription-Key': apiSub,
'X-Gmeets-Server': targetEnv
}
})
.then(response => {
if (!response.ok) { throw new Error(response.status + " :: " + response.statusText) }
else {
return response.blob()
}
}).catch(function(reason) {throw reason});
const url = window.URL.createObjectURL(blob);
if (true) {
const fileName = "unoosa-" + lang.toLowerCase() + "-" + fileId + ".mp3";
var a = document.createElement('a');
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a)
a.remove();
window.URL.revokeObjectURL(url);
showDialog('File downloaded as ' + fileName + '', "", true)
} else {
showDialog('', "player", true, url)
}
} catch (e) {
showDialog('Unfortunately, downloads are not available at the moment ' + e, "error", true)
}
}
const links = document.querySelectorAll('button[data-audio-file]')
if (links.length > 0) {
for (let i = 0; i < links.length; ++i) {
links[i].addEventListener('click', getFile);
}
}