function UUID_V4() {
var S4 = function() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
};
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}
function Dialog(title,message,buttons=Array(),callback=function(){}){
var uuid=UUID_V4();
html='<div class="modal fade" id="'+uuid+'" tabindex="-1" role="dialog" aria-labelledby="'+uuid+'Label" aria-hidden="true">';
html=html+' <div class="modal-dialog modal-lg">';
html=html+' <div class="modal-content">';
html=html+' <div class="modal-header">';
html=html+' <h5 class="modal-title" id=""'+uuid+'Label">'+title+'</h5>';
html=html+' <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>';
html=html+' </div>';
html=html+' <div class="modal-body">';
html=html+' <p>'+message+'</p>';
html=html+' </div>';
html=html+' <div class="modal-footer">';
buttons.forEach(function(bt, index, array) {
if (index==0){
html=html+'<button type="button" onclick="'+callback.name+'(\''+bt+'\')" class="btn btn-secondary" data-bs-dismiss="modal">'+bt+'</button>';
} else {
html=html+'<button type="button" onclick="'+callback.name+'(\''+bt+'\')" class="btn btn-primary" data-bs-dismiss="modal">'+bt+'</button>';
};
});
html=html+' </div>';
html=html+' </div>';
html=html+' </div>';
html=html+'</div>';
$("body").append(html);
$("#"+uuid).modal("show");
$("#"+uuid).on("hidden.bs.modal", function () {
console.log("--закрыли окно");
$("#"+uuid).remove();
});
};
Dialog("Привет","Тут какой-то текст",["Ок","Отмена"],ResultTestDialog);
function ResultTestDialog(result){
console.log("!",result);
}