diff options
author | Scott Dale <sdale@pfsense.org> | 2007-05-15 01:09:00 +0000 |
---|---|---|
committer | Scott Dale <sdale@pfsense.org> | 2007-05-15 01:09:00 +0000 |
commit | bf5ad14297fd38946b4ba84ba41c6989aff76517 (patch) | |
tree | 19b88a825b67ebb9c517c78800a15607c4dd3b04 /usr/local/www/widgets | |
parent | 25b66ec5e31edc19a67e1dfb98977148c264f7aa (diff) | |
download | pfsense-bf5ad14297fd38946b4ba84ba41c6989aff76517.zip pfsense-bf5ad14297fd38946b4ba84ba41c6989aff76517.tar.gz |
save widget settings
Diffstat (limited to 'usr/local/www/widgets')
-rw-r--r-- | usr/local/www/widgets/javascript/traffic_graph.js | 60 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/traffic_graphs.widget.php | 74 |
2 files changed, 111 insertions, 23 deletions
diff --git a/usr/local/www/widgets/javascript/traffic_graph.js b/usr/local/www/widgets/javascript/traffic_graph.js new file mode 100644 index 0000000..8ee192a --- /dev/null +++ b/usr/local/www/widgets/javascript/traffic_graph.js @@ -0,0 +1,60 @@ +function trafficshowDiv(incDiv,swapButtons){ + //appear element + selectedDiv = incDiv + "graphdiv"; + Effect.BlindDown(selectedDiv, {duration:1}); + showSave(); + d = document; + if (swapButtons){ + selectIntLink = selectedDiv + "-min"; + textlink = d.getElementById(selectIntLink); + textlink.style.display = "inline"; + + selectIntLink = selectedDiv + "-open"; + textlink = d.getElementById(selectIntLink); + textlink.style.display = "none"; + } + selectIntLink = incDiv + "_graph-config"; + textlink = d.getElementById(selectIntLink); + textlink.value = "show"; + updateGraphDisplays(); +} + +function trafficminimizeDiv(incDiv,swapButtons){ + //fade element + selectedDiv = incDiv + "graphdiv"; + Effect.BlindUp(selectedDiv, {duration:1}); + showSave(); + d = document; + if (swapButtons){ + selectIntLink = selectedDiv + "-open"; + textlink = d.getElementById(selectIntLink); + textlink.style.display = "inline"; + + selectIntLink = selectedDiv + "-min"; + textlink = d.getElementById(selectIntLink); + textlink.style.display = "none"; + } + selectIntLink = incDiv + "_graph-config"; + textlink = d.getElementById(selectIntLink); + textlink.value = "hide"; + updateGraphDisplays(); +} + +function updateGraphDisplays(){ + var graphs = document.getElementsByClassName('graphsettings'); + var graphsdisplayed = ""; + var firstprint = false; + d = document; + for (i=0; i<graphs.length; i++){ + if (firstprint) + graphsdisplayed += ","; + var graph = graphs[i].id; + graphsdisplayed += graph + ":"; + textlink = d.getElementById(graph).value; + graphsdisplayed += textlink; + firstprint = true; + } + selectIntLink = "traffic_graphs-config"; + textlink = d.getElementById(selectIntLink); + textlink.value = graphsdisplayed; +}
\ No newline at end of file diff --git a/usr/local/www/widgets/widgets/traffic_graphs.widget.php b/usr/local/www/widgets/widgets/traffic_graphs.widget.php index 0e1f89e..0a6c1a6 100644 --- a/usr/local/www/widgets/widgets/traffic_graphs.widget.php +++ b/usr/local/www/widgets/widgets/traffic_graphs.widget.php @@ -2,12 +2,14 @@ for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; }?> - + <input type="hidden" id="traffic_graphs-config" name="traffic_graphs-config" value=""> <?php //set variables for traffic graph $width = "347"; $height = "150"; - + $showngraphlist = explode(",", $pconfig['traffic_graphs-config']); + $graphcounter = 0; + if (get_cpu_speed() >= 500) $firstgraphshown = false; else @@ -15,35 +17,61 @@ foreach ($ifdescrs as $ifdescr => $ifname){ $ifinfo = get_interface_info($ifdescr); $ifnum = convert_friendly_interface_to_real_interface_name($ifname); + $currentgraph = $showngraphlist[$graphcounter]; + $colposition = strpos($currentgraph,":"); + $currentgraph = substr($currentgraph, $colposition+1); + if($config['widgets']['traffic_graphs-config']){ + if ($currentgraph =="show"){ + $mingraphbutton = "inline"; + $showgraphbutton = "none"; + $graphdisplay = "inline"; + $interfacevalue = "show"; + } + else + { + $mingraphbutton = "none"; + $showgraphbutton = "inline"; + $graphdisplay = "none"; + $interfacevalue = "hide"; + } + } + else + { + if(!$firstgraphshown){ + $mingraphbutton = "inline"; + $showgraphbutton = "none"; + $graphdisplay = "inline"; + $interfacevalue = "show"; + } + else + { + $mingraphbutton = "none"; + $showgraphbutton = "inline"; + $graphdisplay = "none"; + $interfacevalue = "hide"; + } + } + if ($ifinfo['status'] != "down"){ ?> <div id="<?=$ifname;?>trafficdiv" style="padding: 5px"> + <input type="hidden" id="<?php echo $ifname;?>_graph-config" name="<?php echo $ifname;?>_graph-config" class="graphsettings" value="<?=$interfacevalue;?>"> <div id="<?=$ifname;?>topic" class="widgetsubheader"> <div style="float:left;width:49%"> <a href="/status_graph.php?if=<?=$ifdescr;?>"><span style="color:#000000">Current <?=$ifname;?> Traffic</span></a> </div> <div align="right" style="float:right;width:49%"> - <?php - if(!$firstgraphshown){?> - <div id="<?=$ifname;?>graphdiv-min" onclick='return minimizeDiv("<?php echo $ifname;?>graphdiv",true)' style="display:inline; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_minus.gif" alt="Minimize <?=$ifname;?> traffic graph" /></div> - <?php $firstgraphshown = true;?> - <div id="<?=$ifname;?>graphdiv-open" onclick='return showDiv("<?php echo $ifname;?>graphdiv",true)' style="display:none; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_open.gif" alt="Show <?=$ifname;?> traffic graph" /></div> - </div><div style="clear:both;"></div> - </div> - - <div id="<?=$ifname;?>graphdiv"> + <div id="<?=$ifname;?>graphdiv-min" onclick='return trafficminimizeDiv("<?php echo $ifname;?>",true)' style="display:<?php echo $mingraphbutton;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_minus.gif" alt="Minimize <?=$ifname;?> traffic graph" /></div> + <div id="<?=$ifname;?>graphdiv-open" onclick='return trafficshowDiv("<?php echo $ifname;?>",true)' style="display:<?php echo $showgraphbutton;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_open.gif" alt="Show <?=$ifname;?> traffic graph" /></div> + </div> + <div style="clear:both;"></div> + </div> + <div id="<?=$ifname;?>graphdiv" style="display:<?php echo $graphdisplay;?>"> <embed id="graph" src="graph.php?ifnum=<?=$ifnum;?>&ifname=<?=rawurlencode($ifname);?>" type="image/svg+xml" width="<? echo $width; ?>" height="<? echo $height; ?>" pluginspage="http://www.adobe.com/svg/viewer/install/auto" /> - </div> - <? } else { ?> - <div id="<?=$ifname;?>graphdiv-open" onclick='return showDiv("<?php echo $ifname;?>graphdiv",true)' style="display:inline; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_open.gif" alt="Show <?=$ifname;?> traffic graph" /></div> - <div id="<?=$ifname;?>graphdiv-min" onclick='return minimizeDiv("<?php echo $ifname;?>graphdiv",true)' style="display:none; cursor:pointer"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_minus.gif" alt="Minimize <?=$ifname;?> traffic graph" /></div> - </div><div style="clear:both;"></div> - </div> - <div id="<?=$ifname;?>graphdiv" style="display: none"> - <embed id="graph" src="graph.php?ifnum=<?=$ifnum;?>&ifname=<?=rawurlencode($ifname);?>" type="image/svg+xml" width="<? echo $width; ?>" height="<? echo $height; ?>" pluginspage="http://www.adobe.com/svg/viewer/install/auto" /> </div> - <? } ?> - </div> - <? } - } ?> + <? $firstgraphshown = true; $graphcounter++;} ?> + </div> + <? + } +?> |