92 lines
3.1 KiB
JavaScript
92 lines
3.1 KiB
JavaScript
|
|
|
||
|
|
$(document).ready(function () {
|
||
|
|
$("#presentation_settings_btn").click(editPresentationSettings);
|
||
|
|
$("#complexes_presentation_settings_btn").click(editPresentationComplexes);
|
||
|
|
// console.log($("#complexes_iframe_url"), 'TESTSSSS');
|
||
|
|
$("#complexes_iframe_url").html(`<code></code>`);
|
||
|
|
const btnElement = document.getElementById("complexes_presentation_settings_btn");
|
||
|
|
if (btnElement) {
|
||
|
|
const id = btnElement.getAttribute('data-id-c');
|
||
|
|
|
||
|
|
console.log(id, 'idddddddddddddd');
|
||
|
|
|
||
|
|
$.ajax({
|
||
|
|
url: "/admin/ajax/getComplexPresentation.php?id=" + id,
|
||
|
|
method: "get",
|
||
|
|
success: function(data) {
|
||
|
|
frame_data = JSON.parse(data)
|
||
|
|
const url = frame_data.url;
|
||
|
|
const iframe = `<iframe title="Presentation" width="1920" height="1080" src="${url}"> </iframe>`
|
||
|
|
const endDate = new Date(frame_data.end_date).toLocaleDateString("ru-RU")
|
||
|
|
$("#complexes_iframe_url > code").text(iframe)
|
||
|
|
|
||
|
|
$("#complexes_iframe_url +svg")
|
||
|
|
.on("click", function () {
|
||
|
|
copyToClipboard(iframe);
|
||
|
|
showCopiedMessage();
|
||
|
|
});
|
||
|
|
$("#complexes-pres-title-wrapper > h3").text(``) // Оплачено до ${endDate}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
} else {
|
||
|
|
console.warn('Элемент #complexes_presentation_settings_btn не найден');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
function copyToClipboard(text) {
|
||
|
|
navigator.clipboard.writeText(text)
|
||
|
|
}
|
||
|
|
|
||
|
|
function showCopiedMessage() {
|
||
|
|
const tooltip = $(".iframe_tooltip");
|
||
|
|
tooltip.show();
|
||
|
|
setTimeout(function() {
|
||
|
|
tooltip.fadeOut();
|
||
|
|
}, 2000);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
function editPresentationSettings() {
|
||
|
|
let color = document.getElementById("presentation_color").value;
|
||
|
|
const id = document.getElementById("presentation_settings_btn").getAttribute('data-id');
|
||
|
|
|
||
|
|
$.ajax({
|
||
|
|
url: "/admin/ajax/togglePresentationFrame.php?id=" + id,
|
||
|
|
method: "post",
|
||
|
|
data: { color },
|
||
|
|
success: function (data) {
|
||
|
|
console.log('already success');
|
||
|
|
|
||
|
|
$("body").removeClass("lock");
|
||
|
|
window.location.reload(true);
|
||
|
|
},
|
||
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
||
|
|
var i = errorThrown;
|
||
|
|
},
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function editPresentationComplexes() {
|
||
|
|
let main_color = document.getElementById("complexes_presentation_color").value;
|
||
|
|
let client_funnel_id = document.getElementById("complexes_presentation_client_funnel").value;
|
||
|
|
let req_funnel_id = document.getElementById("complexes_presentation_req_funnel").value;
|
||
|
|
let color_reserved = document.getElementById("complexes_presentation_reserved_color").value;
|
||
|
|
let color_free = document.getElementById("complexes_presentation_free_color").value;
|
||
|
|
const id = document.getElementById("complexes_presentation_settings_btn").getAttribute('data-id-c');
|
||
|
|
console.log(id);
|
||
|
|
|
||
|
|
$.ajax({
|
||
|
|
url: "/admin/ajax/toggleComplexesFrame.php?id=" + id,
|
||
|
|
method: "post",
|
||
|
|
data: { main_color, client_funnel_id, req_funnel_id, color_reserved, color_free },
|
||
|
|
success: function (data) {
|
||
|
|
console.log('frame saved succesifully');
|
||
|
|
$("body").removeClass("lock");
|
||
|
|
window.location.reload(true);
|
||
|
|
},
|
||
|
|
error: function () {
|
||
|
|
console.log(error);
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
}
|