// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
'use strict';
/* globals init_archiving, init_configuration_alert, init_password_observers, init_slider, init_url_observers */
//
let popup = null;
let popup_iframe_container = null;
let popup_iframe = null;
let popup_working = false;
function openPopupWithSource(source) {
if (popup_working === true) {
return false;
}
popup_working = true;
popup_iframe.src = source;
popup_iframe_container.style.display = 'table-row';
popup.style.display = 'block';
}
function closePopup() {
popup.style.display = 'none';
popup_iframe_container.style.display = 'none';
popup_iframe.src = 'about:blank';
popup_working = false;
}
function init_popup() {
// Fetch elements.
popup = document.getElementById('popup');
if (popup) {
popup_iframe_container = document.getElementById('popup-iframe-container');
popup_iframe = document.getElementById('popup-iframe');
// Configure close button.
document.getElementById('popup-close').addEventListener('click', function (ev) {
closePopup();
});
// Configure close-on-click.
window.addEventListener('click', function (ev) {
if (ev.target == popup) {
closePopup();
}
});
}
}
//
function init_popup_preview_selector() {
const link = document.getElementById('popup-preview-selector');
if (!link) {
return;
}
link.addEventListener('click', function (ev) {
const selector_entries = document.getElementById('path_entries').value;
const selector_entries_filter = document.getElementById('path_entries_filter').value;
const href = link.href.replace('selector-token', encodeURIComponent(selector_entries))
.replace('selector-filter-token', encodeURIComponent(selector_entries_filter));
openPopupWithSource(href);
ev.preventDefault();
});
}
/**
* Allow a