diff --git a/orcinus/admin.php b/orcinus/admin.php index caaf7c0..ae64adb 100644 --- a/orcinus/admin.php +++ b/orcinus/admin.php @@ -118,6 +118,7 @@ if (!isset($_SESSION['index_page'])) $_SESSION['index_page'] = 1; if (empty($_SESSION['index_filter_category'])) $_SESSION['index_filter_category'] = ''; if (empty($_SESSION['index_filter_status'])) $_SESSION['index_filter_status'] = ''; if (empty($_SESSION['index_filter_text'])) $_SESSION['index_filter_text'] = ''; +if (empty($_SESSION['index_show_page_titles'])) $_SESSION['index_show_page_titles'] = 'off'; if (empty($_SESSION['admin_username'])) $_SESSION['admin_username'] = ''; if (!$_SESSION['admin_username']) { @@ -140,6 +141,7 @@ if (!$_SESSION['admin_username']) { } } +// We are logged in with a valid admin username } else { /* ***** Handle POST Requests ************************************** */ @@ -341,6 +343,24 @@ if (!$_SESSION['admin_username']) { } break; + // ***** Set an admin UI session variable + case 'setsession': + if (!empty($_POST->variable) && isset($_SESSION[$_POST->variable])) { + if (empty($_POST->value)) $_POST->value = ''; + $_SESSION[$_POST->variable] = $_POST->value; + + $response = array( + 'status' => 'Success', + 'message' => $_POST->value + ); + + } else { + $response = array( + 'status' => 'Error', + 'message' => 'Invalid session variable given' + ); + } + break; // ***** Not used? case 'fetch': @@ -1873,7 +1893,8 @@ if (!$_SESSION['admin_username']) {
- +
- + 2) { ?> - - - tr > th > img { visibility:hidden; } diff --git a/orcinus/js/admin.js b/orcinus/js/admin.js index 928a203..bb5b5fa 100644 --- a/orcinus/js/admin.js +++ b/orcinus/js/admin.js @@ -208,6 +208,47 @@ if (os_index_filter_by_status) { }, false); } +let os_header_url = document.getElementById('os_header_url'); +let os_index_table = document.getElementById('os_index_table'); +if (os_header_url && os_index_table) { + let input = document.createElement('input'); + input.type = 'checkbox'; + input.title = 'Show Page Titles'; + input.classList.add('form-check-input', 'fs-6', 'ms-2', 'mt-2'); + if (os_index_table.classList.contains('show-page-titles')) + input.checked = 'checked'; + os_header_url.appendChild(input); + input.addEventListener('change', function() { + if (this.checked) { + os_index_table.classList.add('show-page-titles'); + } else os_index_table.classList.remove('show-page-titles'); + + fetch(new Request('./admin.php'), { + method: 'POST', + headers: { 'Content-type': 'application/json' }, + body: JSON.stringify({ + action: 'setsession', + variable: 'index_show_page_titles', + value: (this.checked) ? 'on' : 'off' + }) + }) + .then((response) => response.text()) + .then((data) => { + try { + data = JSON.parse(data); + } catch(e) { + data = { + 'status': 'Error', + 'message': 'Invalid response from server' + }; + } + + if (data.status != 'Success') + console.log('Could not save session variable. Reason: ' + data.message); + }); + }, false); +} + let os_index_check_all = document.querySelectorAll('input[name="os_index_check_all"]'); for (let x = 0; x < os_index_check_all.length; x++) { os_index_check_all[x].addEventListener('click', function() { @@ -624,7 +665,7 @@ os_crawl_start.addEventListener('click', function(e) { clearInterval(os_crawl_interval); os_crawl_interval = setInterval(os_get_crawl_progress, 1000); - } else if (data.status = 'Error') { + } else if (data.status == 'Error') { os_crawl_log.value = data.message; os_crawl_start.innerHTML = 'Couldn\'t Start Crawl'; os_crawl_navbar.innerHTML = 'Crawler';
@@ -1917,7 +1938,7 @@ if (!$_SESSION['admin_username']) {
URLURL Showing pages
-
+
+ Unlisted