`;
}
logoElement.innerHTML = html;
}
}
function HideBackButton() {
var logoElement = document.getElementById("logo");
if (logoElement) {
logoElement.innerHTML = `
`;
}
}
function goBack() {
history.back();
}
// submitEvent acts like .submit(), except it is compatible with the app, by using events instead.
function submitEvent(ele) {
console.log("in submitEvent");
if (ele.startsWith('#')) {
ele = ele.slice(1);
}
document.getElementById(ele).submit();
return;
/*
const theEvent = new CustomEvent('submit', {
bubbles: true,
cancelable: true
});
if (typeof ele === 'string' || ele instanceof String) {
if (ele.startsWith("#") == true) {
ele = ele.slice(1);
}
if (document.getElementById(ele).dispatchEvent(theEvent) == true) {
// if not cancelled, do normal submit
console.log("calling submit");
document.getElementById(ele).submit();
}
return;
}
// assume ele is the element
if (ele.dispatchEvent(theEvent) == true) {
// if not cancelled, do normal submit
console.log("calling submit");
ele.submit();
}
*/
}
// gioDestroy is a convenience function for destroy callbacks
function gioDestroy(eventCB) {
let internalGioDestroy = function(evt) {
// do not activate on infinite scroll events
if (evt.detail.target !== undefined && evt.detail.target.id != "maincontent-refresh") {
console.log("Ignoring infinite scroll event");
return;
}
console.log("Calling destroy callback");
eventCB(evt);
}
document.body.addEventListener("htmx:beforeSwap", internalGioDestroy, {once: true});
document.body.addEventListener("htmx:historyCacheMiss", internalGioDestroy, {once: true});
}
var drawerCloseFunc = function(evt) {
console.log("in drawerCloseFunc");
// Find all elements with the class 'drawer'
var drawers = document.querySelectorAll('.drawer');
// Iterate over each element and call closeDrawer() on each
drawers.forEach(function(obj) {
drawerObj.closeDrawer(obj);
});
$('.modal').modal('hide');
}
document.body.addEventListener('htmx:beforeSwap', drawerCloseFunc);
document.body.addEventListener('htmx:historyCacheMiss', drawerCloseFunc);
var keydownFunc = function(event) {
var tagName = event.target.tagName.toLowerCase();
if (tagName === 'input' || tagName === 'textarea' || event.target.isContentEditable) {
if (event.key === 'Escape') {
event.target.blur();
}
return;
}
// check if the viewimages viewer is up
let element = document.getElementById('overlay');
if (element && element.classList.contains('visible')) {
return;
}
console.log("HERE: " + event.key + " " + event.ctrlKey + " " + event.shiftKey + " " + event.metaKey);
if (event.ctrlKey && event.shiftKey && (event.key === '?' || event.key === '/')) {
event.preventDefault(); // Prevent the default action
// Show the modal dialog for keyboard shortcuts
$('#shortcutModal').modal('show');
return;
}
$('#shortcutModal').modal('hide');
if (event.key.toLowerCase() === 'g') {
// For Windows and Linux
if (event.ctrlKey) {
event.preventDefault();
showAutocompleteModal("groupnavigator");
return;
}
}
// Check if the pressed key is '/'
if ((event.key === 'f' || event.key === 'F') && event.shiftKey) {
if (navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
if (event.metaKey) {
event.preventDefault(); // Prevent the default action
// Focus on the search box
let box = document.getElementById('searchbox')
if (box != null) {
document.getElementById('searchbox').focus();
}
}
} else {
// For Windows and Linux
if (event.ctrlKey) {
event.preventDefault(); // Prevent the default action
// Focus on the search box
let box = document.getElementById('searchbox')
if (box != null) {
document.getElementById('searchbox').focus();
}
}
}
}
}
document.addEventListener('keydown', keydownFunc);
var removeDrawerCloseFunc = function(evt) {
document.body.removeEventListener('htmx:beforeSwap', drawerCloseFunc);
document.body.removeEventListener('htmx:historyCacheMiss', drawerCloseFunc);
document.removeEventListener('keydown', keydownFunc);
}
document.body.addEventListener("htmx:historyCacheMiss", removeDrawerCloseFunc, {once: true});