Commit 7a670d65 authored by Ad Schellevis's avatar Ad Schellevis

(dashboard, widget) spacing and small layout changes in ntp_status.widget.php,...

(dashboard, widget) spacing and small layout changes in ntp_status.widget.php, very anchient and unreadable code.... not spending more time on this now
parent b9333627
<?php <?php
/* /*
Copyright (C) 2014 Deciso B.V. Copyright (C) 2014 Deciso B.V.
Copyright (c) 2007 Scott Dale Copyright (c) 2007 Scott Dale
Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net> Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
and Jonathan Watt <jwatt@jwatt.org>. and Jonathan Watt <jwatt@jwatt.org>.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, 1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer. this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
$nocsrf = true;
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("pfsense-utils.inc"); require_once("pfsense-utils.inc");
require_once("widgets/include/ntp_status.inc"); require_once("widgets/include/ntp_status.inc");
...@@ -125,42 +123,42 @@ if ($_REQUEST['updateme']) { ...@@ -125,42 +123,42 @@ if ($_REQUEST['updateme']) {
} }
?> ?>
<table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="clock"> <table >
<tbody> <tbody>
<tr> <tr>
<td width="40%" class="vncellt">Sync Source</td> <td width="40%" class="vncellt">Sync Source</td>
<td width="60%" class="listr"> <td width="60%" class="listr">
<?php if ($ntpq_counter == 0) : <?php if ($ntpq_counter == 0) :
?> ?>
<?= gettext('No active peers available') ?> <?= gettext('No active peers available') ?>
<?php <?php
else : else :
?> ?>
<?php echo $syncsource; ?> <?php echo $syncsource; ?>
<?php <?php
endif; ?> endif; ?>
</td> </td>
</tr> </tr>
<?php if (($gps_ok) && ($gps_lat) && ($gps_lon)) : <?php if (($gps_ok) && ($gps_lat) && ($gps_lon)) :
?> ?>
<tr> <tr>
<td width="40%" class="vncellt"><?= gettext('Clock location') ?></td> <td width="40%" class="vncellt"><?= gettext('Clock location') ?></td>
<td width="60%" class="listr"> <td width="60%" class="listr">
<a target="_gmaps" href="http://maps.google.com/?q=<?php echo $gps_lat; ?>,<?php echo $gps_lon; ?>"> <a target="_gmaps" href="http://maps.google.com/?q=<?php echo $gps_lat; ?>,<?php echo $gps_lon; ?>">
<?php <?php
echo sprintf("%.5f", $gps_lat) . " " . $gps_la . ", " . sprintf("%.5f", $gps_lon) . " " . $gps_lo; ?> echo sprintf("%.5f", $gps_lat) . " " . $gps_la . ", " . sprintf("%.5f", $gps_lon) . " " . $gps_lo; ?>
</a> </a>
<?php if (isset($gps_alt)) { <?php if (isset($gps_alt)) {
echo " (" . $gps_alt . " " . $gps_alt_unit . " alt.)"; echo " (" . $gps_alt . " " . $gps_alt_unit . " alt.)";
} ?> } ?>
</td> </td>
</tr> </tr>
<?php if (isset($gps_sat) || isset($gps_satview)) : <?php if (isset($gps_sat) || isset($gps_satview)) :
?> ?>
<tr> <tr>
<td width="40%" class="vncellt"><?= gettext('Satellites') ?></td> <td width="40%" class="vncellt"><?= gettext('Satellites') ?></td>
<td width="60%" class="listr"> <td width="60%" class="listr">
<?php <?php
if (isset($gps_satview)) { if (isset($gps_satview)) {
echo gettext('in view ') . intval($gps_satview); echo gettext('in view ') . intval($gps_satview);
} }
...@@ -171,13 +169,13 @@ endif; ?> ...@@ -171,13 +169,13 @@ endif; ?>
echo gettext('in use ') . $gps_sat; echo gettext('in use ') . $gps_sat;
} }
?> ?>
</td> </td>
</tr> </tr>
<?php <?php
endif; ?> endif; ?>
<?php <?php
endif; ?> endif; ?>
</tbody> </tbody>
</table> </table>
<?php <?php
exit; exit;
...@@ -246,9 +244,9 @@ classic Netscape, or Netscape 6/W3C DOM methods is available. ...@@ -246,9 +244,9 @@ classic Netscape, or Netscape 6/W3C DOM methods is available.
The optional inLayer argument helps Netscape 4 find objects in The optional inLayer argument helps Netscape 4 find objects in
the named layer or floating DIV. */ the named layer or floating DIV. */
function simpleFindObj(name, inLayer) { function simpleFindObj(name, inLayer) {
return document[name] || (document.all && document.all[name]) return document[name] || (document.all && document.all[name])
|| (document.getElementById && document.getElementById(name)) || (document.getElementById && document.getElementById(name))
|| (document.layers && inLayer && document.layers[inLayer].document[name]); || (document.layers && inLayer && document.layers[inLayer].document[name]);
} }
/*** Beginning of Clock 2.1.2, by Andrew Shearer /*** Beginning of Clock 2.1.2, by Andrew Shearer
...@@ -279,12 +277,12 @@ Compatibility: IE 4.x and 5.0, Netscape 4.x and 6.0, Mozilla 1.0. Mac & Windows. ...@@ -279,12 +277,12 @@ Compatibility: IE 4.x and 5.0, Netscape 4.x and 6.0, Mozilla 1.0. Mac & Windows.
History: 1.0 2000-05-09 GIF-image digits History: 1.0 2000-05-09 GIF-image digits
2.0 2000-06-29 Uses text DIV layers (so 4.0 browsers req'd), & 2.0 2000-06-29 Uses text DIV layers (so 4.0 browsers req'd), &
cookies to work around Win IE stale-time bug cookies to work around Win IE stale-time bug
2.1 2002-10-12 Noted Mozilla 1.0 compatibility; released PHP version. 2.1 2002-10-12 Noted Mozilla 1.0 compatibility; released PHP version.
2.1.1 2002-10-20 Fixed octal bug in the PHP translation; the number of 2.1.1 2002-10-20 Fixed octal bug in the PHP translation; the number of
minutes & seconds were misinterpretes when less than 10 minutes & seconds were misinterpretes when less than 10
2.1.2 2003-08-07 The previous fix had introduced a bug when the 2.1.2 2003-08-07 The previous fix had introduced a bug when the
minutes or seconds were exactly 0. Thanks to Man Bui minutes or seconds were exactly 0. Thanks to Man Bui
for reporting the bug. for reporting the bug.
*/ */
var clockIncrementMillis = 1000; var clockIncrementMillis = 1000;
var localTime; var localTime;
...@@ -365,9 +363,9 @@ function clockToggleSeconds() ...@@ -365,9 +363,9 @@ function clockToggleSeconds()
} }
function clockTimeString(inHours, inMinutes, inSeconds) { function clockTimeString(inHours, inMinutes, inSeconds) {
return inHours return inHours
+ (inMinutes < 10 ? ":0" : ":") + inMinutes + (inMinutes < 10 ? ":0" : ":") + inMinutes
+ (inSeconds < 10 ? ":0" : ":") + inSeconds; + (inSeconds < 10 ? ":0" : ":") + inSeconds;
} }
function clockDisplayTime(inHours, inMinutes, inSeconds) { function clockDisplayTime(inHours, inMinutes, inSeconds) {
...@@ -465,51 +463,45 @@ function clockUpdate() ...@@ -465,51 +463,45 @@ function clockUpdate()
</script> </script>
<table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="clock"> <table class="table table-striped table-condensed">
<tbody> <tbody>
<tr> <tr>
<td width="40%" class="vncellt">Server Time</td> <td width="40%" class="vncellt">Server Time</td>
<td width="60%" class="listr"> <td width="60%" class="listr">
<div id="ClockTime"> <div id="ClockTime">
<b><?php echo(clockTimeString($gDate, $gClockShowsSeconds));?></b> <b><?php echo(clockTimeString($gDate, $gClockShowsSeconds));?></b>
</div> </div>
</td> </td>
</tr> </tr>
</tbody> <tr>
<td colspan="2" id="ntpstatus">
<?=gettext("Updating...");?>
</td>
</tr>
</tbody>
</table> </table>
<div id='ntpstatus'>
<table width="100%" border="0" cellspacing="0" cellpadding="0" summary="clock">
<tbody>
<tr>
<td width="100%" class="listr">
Updating...
</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript"> <script type="text/javascript">
function ntp_getstatus() { function ntp_getstatus() {
scroll(0,0); scroll(0,0);
var url = "/widgets/widgets/ntp_status.widget.php"; var url = "/widgets/widgets/ntp_status.widget.php";
var pars = 'updateme=yes'; var pars = 'updateme=yes';
jQuery.ajax( jQuery.ajax(
url, url,
{ {
type: 'get', type: 'get',
data: pars, data: pars,
complete: ntpstatuscallback complete: ntpstatuscallback
}); });
// Refresh the status every 1 minute // Refresh the status every 1 minute
setTimeout('ntp_getstatus()', 1*60*1000); setTimeout('ntp_getstatus()', 1*60*1000);
} }
function ntpstatuscallback(transport) { function ntpstatuscallback(transport) {
// The server returns formatted html code // The server returns formatted html code
var responseStringNtp = transport.responseText var responseStringNtp = transport.responseText
jQuery('#ntpstatus').prop('innerHTML',responseStringNtp); jQuery('#ntpstatus').prop('innerHTML',responseStringNtp);
} }
// Do the first status check 1 second after the dashboard opens // Do the first status check 1 second after the dashboard opens
setTimeout('ntp_getstatus()', 1000); setTimeout('ntp_getstatus()', 1000);
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment