src/main/webapp/lightpit.js

Tue, 23 Jun 2026 14:30:10 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 23 Jun 2026 14:30:10 +0200
changeset 436
a07662e829c0
permissions
-rw-r--r--

add the possibility to hide projects from the left menu - resolves #818

436
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * Copyright 2025 Mike Becker. All rights reserved.
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Redistribution and use in source and binary forms, with or without
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 * modification, are permitted provided that the following conditions are met:
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 *
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * 1. Redistributions of source code must retain the above copyright
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 * notice, this list of conditions and the following disclaimer.
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 *
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * documentation and/or other materials provided with the distribution.
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 *
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 */
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 function closeWhatsNew(showMore) {
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 if (showMore) {
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 window.open(baseHref + 'about', '_blank');
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 }
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 document.getElementById('whats-new').style.display = 'none';
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31 document.getElementById('page-area').classList.remove('blurred');
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 }
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 function applyShowAllProjects() {
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 const toggle = document.getElementById('show-all-projects');
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 if (!toggle) return; // this page does not show the navmenu
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 const checked = toggle.checked;
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 document.querySelectorAll('#sideMenu .menuEntry[data-hidden]').forEach((elem) => {
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 elem.style.display = checked ? 'initial' : 'none';
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 })
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 }
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 function toggleShowAllProjects() {
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 const toggle = document.getElementById('show-all-projects');
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 const req = new XMLHttpRequest();
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 req.open('POST', baseHref+'projects/settings');
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49 req.send('show_all_projects=' + (toggle.checked ? 'true' : 'false'));
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 applyShowAllProjects();
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 }
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 window.addEventListener('load', () => {
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 applyShowAllProjects();
a07662e829c0 add the possibility to hide projects from the left menu - resolves #818
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 });

mercurial