X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fhtml%2Finclude%2Fzoneconf.js;fp=html%2Fhtml%2Finclude%2Fzoneconf.js;h=d76f0ab68ad645e676544255c1a02c03dc821349;hp=0000000000000000000000000000000000000000;hb=5c33a76135106614591684668bfe76f0ba8cdbff;hpb=fc31c28d5c1d54a81991a77fda7efbc482f04565 diff --git a/html/html/include/zoneconf.js b/html/html/include/zoneconf.js new file mode 100644 index 0000000000..d76f0ab68a --- /dev/null +++ b/html/html/include/zoneconf.js @@ -0,0 +1,56 @@ +/*############################################################################# +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2020 IPFire Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +//zoneconf.cgi dynamic highlighting of interface access selection +//(call this from "onchange" event of selection elements) +function highlightAccess(selectObj) { + if(!(selectObj && ('zone' in selectObj.dataset) && ('mac' in selectObj.dataset))) { + return; //required parameters are missing + } + + var zoneColor = selectObj.dataset.zone.trim().toLowerCase(); //zone color (red/green/blue/orange) CSS class + + function colorParentCell(obj, color, enabled = true) { //find nearest parent table cell of "obj" and set its CSS color class + do { + obj = obj.parentElement; + } while(obj && (obj.nodeName.toUpperCase() !== 'TD')); + if(obj && (['green', 'red', 'orange', 'blue'].includes(color))) { + obj.classList.toggle(color, enabled); + } + } + + //handle other associated input fields + if(selectObj.type.toUpperCase() === 'RADIO') { //this is a radio button group: clear all highlights + let radios = document.getElementsByName(selectObj.name); + radios.forEach(function(button) { + if(button.nodeName.toUpperCase() === 'INPUT') { //make sure the found element is a button + colorParentCell(button, zoneColor, false); //remove css + } + }); + } else { //this is a dropdown menu: enable/disable additional VLAN tag input box + let tagInput = document.getElementById('TAG-' + selectObj.dataset.zone + '-' + selectObj.dataset.mac); //tag input element selector + if(tagInput) { + tagInput.disabled = (selectObj.value !== 'VLAN'); //enable tag input if VLAN mode selected + } + } + + //if interface is assigned, highlight table cell in zone color + colorParentCell(selectObj, zoneColor, (selectObj.value !== 'NONE')); +}