]>
Commit | Line | Data |
---|---|---|
5c33a761 LAH |
1 | /*############################################################################# |
2 | # # | |
3 | # IPFire.org - A linux based firewall # | |
4 | # Copyright (C) 2007-2020 IPFire Team <info@ipfire.org> # | |
5 | # # | |
6 | # This program is free software: you can redistribute it and/or modify # | |
7 | # it under the terms of the GNU General Public License as published by # | |
8 | # the Free Software Foundation, either version 3 of the License, or # | |
9 | # (at your option) any later version. # | |
10 | # # | |
11 | # This program is distributed in the hope that it will be useful, # | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
14 | # GNU General Public License for more details. # | |
15 | # # | |
16 | # You should have received a copy of the GNU General Public License # | |
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
18 | # # | |
19 | #############################################################################*/ | |
20 | ||
21 | //zoneconf.cgi dynamic highlighting of interface access selection | |
22 | //(call this from "onchange" event of selection elements) | |
23 | function highlightAccess(selectObj) { | |
24 | if(!(selectObj && ('zone' in selectObj.dataset) && ('mac' in selectObj.dataset))) { | |
25 | return; //required parameters are missing | |
26 | } | |
27 | ||
28 | var zoneColor = selectObj.dataset.zone.trim().toLowerCase(); //zone color (red/green/blue/orange) CSS class | |
29 | ||
30 | function colorParentCell(obj, color, enabled = true) { //find nearest parent table cell of "obj" and set its CSS color class | |
31 | do { | |
32 | obj = obj.parentElement; | |
33 | } while(obj && (obj.nodeName.toUpperCase() !== 'TD')); | |
34 | if(obj && (['green', 'red', 'orange', 'blue'].includes(color))) { | |
35 | obj.classList.toggle(color, enabled); | |
36 | } | |
37 | } | |
38 | ||
39 | //handle other associated input fields | |
40 | if(selectObj.type.toUpperCase() === 'RADIO') { //this is a radio button group: clear all highlights | |
41 | let radios = document.getElementsByName(selectObj.name); | |
42 | radios.forEach(function(button) { | |
43 | if(button.nodeName.toUpperCase() === 'INPUT') { //make sure the found element is a button | |
44 | colorParentCell(button, zoneColor, false); //remove css | |
45 | } | |
46 | }); | |
47 | } else { //this is a dropdown menu: enable/disable additional VLAN tag input box | |
48 | let tagInput = document.getElementById('TAG-' + selectObj.dataset.zone + '-' + selectObj.dataset.mac); //tag input element selector | |
49 | if(tagInput) { | |
50 | tagInput.disabled = (selectObj.value !== 'VLAN'); //enable tag input if VLAN mode selected | |
51 | } | |
52 | } | |
53 | ||
54 | //if interface is assigned, highlight table cell in zone color | |
55 | colorParentCell(selectObj, zoneColor, (selectObj.value !== 'NONE')); | |
56 | } |